You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by gr...@apache.org on 2004/12/25 23:26:03 UTC
svn commit: r123346 - /lenya/trunk/src/java/org/apache/lenya/cms/metadata/Metadata.java /lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUsecase.java
Author: gregor
Date: Sat Dec 25 14:26:02 2004
New Revision: 123346
URL: http://svn.apache.org/viewcvs?view=rev&rev=123346
Log:
Added metadata and generic site usecase (as a superclass for all site-area usecases)
Added:
lenya/trunk/src/java/org/apache/lenya/cms/metadata/Metadata.java (contents, props changed)
lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUsecase.java (contents, props changed)
Added: lenya/trunk/src/java/org/apache/lenya/cms/metadata/Metadata.java
Url: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/metadata/Metadata.java?view=auto&rev=123346
==============================================================================
--- (empty file)
+++ lenya/trunk/src/java/org/apache/lenya/cms/metadata/Metadata.java Sat Dec 25 14:26:02 2004
@@ -0,0 +1,120 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.metadata;
+
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentBuildException;
+import org.apache.lenya.cms.metadata.dublincore.DublinCore;
+import org.apache.lenya.cms.site.SiteUsecase;
+import org.apache.lenya.cms.usecase.UsecaseException;
+
+/**
+ * Usecase to edit metadata for a resource.
+ *
+ * @version $Id$
+ */
+public class Metadata extends SiteUsecase {
+
+ private DublinCore dc;
+ /**
+ * Ctor.
+ */
+ public Metadata() {
+ super();
+ }
+
+ /**
+ * @see org.apache.lenya.cms.usecase.AbstractUsecase#doInitialize()
+ */
+ protected void doInitialize() throws Exception {
+ super.doInitialize();
+
+ try {
+ dc = getDocument().getDublinCore();
+ } catch (Exception e) {
+ throw new DocumentBuildException("Initialization failed: ", e);
+ }
+ }
+
+ /**
+ * Validates the request parameters.
+ * @throws UsecaseException if an error occurs.
+ */
+ void validate() throws UsecaseException {
+ }
+
+ /**
+ * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckExecutionConditions()
+ */
+ protected void doCheckExecutionConditions() throws Exception {
+ validate();
+ }
+
+ /**
+ * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
+ */
+ protected void doExecute() throws Exception {
+ super.doExecute();
+
+ String creator = getParameterAsString(dc.ELEMENT_CREATOR);
+ String title = getParameterAsString(dc.ELEMENT_TITLE);
+ String description = getParameterAsString(dc.ELEMENT_DESCRIPTION);
+ String subject = getParameterAsString(dc.ELEMENT_SUBJECT);
+ String publisher = getParameterAsString(dc.ELEMENT_PUBLISHER);
+ String rights = getParameterAsString(dc.ELEMENT_RIGHTS);
+
+ dc.setValue(dc.ELEMENT_CREATOR, creator);
+ dc.setValue(dc.ELEMENT_TITLE, title);
+ dc.setValue(dc.ELEMENT_DESCRIPTION, description);
+ dc.setValue(dc.ELEMENT_SUBJECT, subject);
+ dc.setValue(dc.ELEMENT_PUBLISHER, publisher);
+ dc.setValue(dc.ELEMENT_RIGHTS, rights);
+ dc.save();
+ //TODO set workflow situation to edit here.
+ }
+
+ /**
+ * @see org.apache.lenya.cms.usecase.Usecase#setParameter(java.lang.String, java.lang.Object)
+ */
+ /* TODO load dc parameters
+ * TODO deal with exception handling, maybe in the interface?*/
+ public void setParameter(String name, Object value) {
+ super.setParameter(name, value);
+
+ if (true) {
+/* try {
+ setParameter(dc.ELEMENT_CREATOR, dc.getFirstValue(dc.ELEMENT_CREATOR));
+ setParameter(dc.ELEMENT_TITLE, dc.getFirstValue(dc.ELEMENT_TITLE));
+ setParameter(dc.ELEMENT_DESCRIPTION, dc.getFirstValue(dc.ELEMENT_CREATOR));
+ setParameter(dc.ELEMENT_SUBJECT, dc.getFirstValue(dc.ELEMENT_SUBJECT));
+ setParameter(dc.ELEMENT_PUBLISHER, dc.getFirstValue(dc.ELEMENT_PUBLISHER));
+ setParameter(dc.ELEMENT_RIGHTS, dc.getFirstValue(dc.ELEMENT_RIGHTS));
+ setParameter(dc.ELEMENT_TYPE, dc.getFirstValue(dc.ELEMENT_TYPE));
+ setParameter(dc.ELEMENT_DATE, dc.getFirstValue(dc.ELEMENT_DATE));
+ setParameter(dc.ELEMENT_FORMAT, dc.getFirstValue(dc.ELEMENT_FORMAT));
+ setParameter(dc.ELEMENT_SOURCE, dc.getFirstValue(dc.ELEMENT_SOURCE));
+ setParameter(dc.ELEMENT_LANGUAGE, dc.getFirstValue(dc.ELEMENT_LANGUAGE));
+ setParameter(dc.ELEMENT_RELATION, dc.getFirstValue(dc.ELEMENT_RELATION));
+ setParameter(dc.ELEMENT_COVERAGE, dc.getFirstValue(dc.ELEMENT_COVERAGE));
+
+ }
+ catch (Exception e) {
+ addErrorMessage("Unable to load Dublin Core metadata.");
+ }
+*/ }
+ }
+}
\ No newline at end of file
Added: lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUsecase.java
Url: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUsecase.java?view=auto&rev=123346
==============================================================================
--- (empty file)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUsecase.java Sat Dec 25 14:26:02 2004
@@ -0,0 +1,75 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.site;
+
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentBuildException;
+import org.apache.lenya.cms.usecase.DocumentUsecase;
+
+/**
+ * Super class for site related usecases.
+ *
+ * @version $Id$
+ */
+public class SiteUsecase extends DocumentUsecase {
+
+ protected static final String AREA = "area";
+ protected static final String DOCUMENTID = "documentid";
+ protected static final String LANGUAGEEXISTS = "languageexists";
+
+ /**
+ * Ctor.
+ */
+ public SiteUsecase() {
+ super();
+ }
+
+ /**
+ * @see org.apache.lenya.cms.usecase.AbstractUsecase#doInitialize()
+ */
+ protected void doInitialize() throws Exception {
+ super.doInitialize();
+ doc = getSourceDocument();
+ }
+
+ private Document doc;
+
+ /**
+ * Returns the currently edited document.
+ * @return A document.
+ */
+ protected Document getDocument() {
+ return this.doc;
+ }
+
+ /**
+ * @see org.apache.lenya.cms.usecase.Usecase#setParameter(java.lang.String, java.lang.Object)
+ */
+ /*TODO make common parameters available to site usecases: area, documentid, languageexists etc */
+ public void setParameter(String name, Object value) {
+ super.setParameter(name, value);
+
+ if (true) {
+
+ setParameter(AREA, this.doc.getArea());
+ setParameter(DOCUMENTID, this.doc.getId());
+ setParameter(LANGUAGEEXISTS, "");
+ }
+ }
+
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org