- move some deprecated or double classes into deprecated module
git-svn-id: https://svn.apache.org/repos/asf/lenya/trunk@1038619 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.lenya.deprecated/pom.xml b/org.apache.lenya.deprecated/pom.xml
index 80cdf20..c5aeb94 100644
--- a/org.apache.lenya.deprecated/pom.xml
+++ b/org.apache.lenya.deprecated/pom.xml
@@ -16,7 +16,26 @@
<description>Hold all deprecated classes and tests classes from 2.1/2.0</description>
<dependencies>
-
+ <dependency>
+ <groupId>org.apache.lenya</groupId>
+ <artifactId>lenya-core-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lenya</groupId>
+ <artifactId>lenya-core-usecase</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lenya</groupId>
+ <artifactId>lenya-core-workflow</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lenya</groupId>
+ <artifactId>lenya-core-cocoon</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lenya</groupId>
+ <artifactId>lenya-core-publication-api</artifactId>
+ </dependency>
<!-- TODO : see if all theses dependencies are required -->
<dependency>
<groupId>org.apache.cocoon</groupId>
diff --git a/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/publication/History.java b/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/publication/History.java
new file mode 100644
index 0000000..5433e84
--- /dev/null
+++ b/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/publication/History.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.publication;
+
+import org.apache.lenya.cms.repository.RepositoryException;
+
+/**
+ * The revision history of a document.
+ *
+ * @deprecated doublon with o.a.l.cms.repository.History
+ */
+public interface History {
+
+ /**
+ * @return The available revision numbers in descending order (starting with the newest one).
+ */
+ int[] getRevisionNumbers();
+
+ /**
+ * @return The latest revision.
+ * @throws RuntimeException if the node has no revisions yet.
+ */
+ Revision getLatestRevision();
+
+ /**
+ * @param number A revision number.
+ * @return A revision.
+ * @throws RepositoryException if no revision with this number exists.
+ */
+ Revision getRevision(int number) throws RepositoryException;
+
+}
diff --git a/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/publication/Node.java b/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/publication/Node.java
new file mode 100644
index 0000000..784e8b5
--- /dev/null
+++ b/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/publication/Node.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.publication;
+
+import org.apache.lenya.cms.repository.RepositoryException;
+import org.apache.lenya.cms.publication.LockException;
+
+/**
+ * Common interface for documents and site structures. This is a hack, we should try to find a
+ * better approach.
+ *
+ * @deprecated doublon with o.a.l.cms.repository.Node
+ */
+public interface Node {
+
+ boolean isCheckedOutBySession(String sessionId, String userId) throws RepositoryException;
+
+ void checkin() throws RepositoryException;
+
+ Session getSession();
+
+ boolean isCheckedOut() throws RepositoryException;
+
+ String getCheckoutUserId() throws RepositoryException;
+
+ void checkout() throws RepositoryException;
+
+ void lock() throws LockException, RepositoryException;
+
+ void unlock() throws RepositoryException;
+
+ void registerDirty() throws RepositoryException;
+
+ boolean isLocked() throws RepositoryException;
+
+ void forceCheckIn() throws RepositoryException;
+
+ void rollback(int revision) throws RepositoryException;
+
+ void checkout(boolean checkoutRestrictedToSession) throws RepositoryException;
+
+ String getSourceURI();
+}
diff --git a/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/repository/metadata/Element.java b/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/repository/metadata/Element.java
new file mode 100644
index 0000000..9d354ae
--- /dev/null
+++ b/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/repository/metadata/Element.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.repository.metadata;
+
+/**
+ * A meta data element.
+ *
+ * @deprecated duplicate of o.a.l.cms.metadata
+ */
+public interface Element {
+
+ /**
+ * @return the name of the element.
+ */
+ String getName();
+
+ /**
+ * @return if the element can have multiple values.
+ */
+ boolean isMultiple();
+
+ /**
+ * @return the description of the element.
+ */
+ String getDescription();
+
+ /**
+ * @return if the element value can be edited.
+ */
+ boolean isEditable();
+
+ /**
+ * Copy all values if the meta data are copied.
+ */
+ int ONCOPY_COPY = 0;
+
+ /**
+ * Don't copy the values of this element if the meta data are copied.
+ */
+ int ONCOPY_IGNORE = 1;
+
+ /**
+ * Delete all values of this element if the meta data are copied.
+ */
+ int ONCOPY_DELETE = 2;
+
+ /**
+ * @return The action to be taken when meta data are copied from one owner to another.
+ */
+ int getActionOnCopy();
+
+ /**
+ * @return If this element shall be included in search queries.
+ */
+ boolean isSearchable();
+
+}
diff --git a/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/repository/metadata/ElementSet.java b/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/repository/metadata/ElementSet.java
new file mode 100644
index 0000000..5d409b1
--- /dev/null
+++ b/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/repository/metadata/ElementSet.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.repository.metadata;
+
+/**
+ * Definition of a set of meta data elements.
+ *
+ * @deprecated duplicate of o.a.l.cms.metadata
+ */
+public interface ElementSet {
+
+ /**
+ * @return The supported elements.
+ */
+ Element[] getElements();
+
+ /**
+ * @param name The name.
+ * @return The element.
+ * @throws MetaDataException if the element with this name does not exist.
+ */
+ Element getElement(String name) throws MetaDataException;
+
+ /**
+ * @return The namespace URI of this element set.
+ */
+ String getNamespaceUri();
+
+ /**
+ * Checks if an element with a certain name is contained.
+ * @param name The name.
+ * @return A boolean value.
+ */
+ boolean containsElement(String name);
+
+}
diff --git a/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/repository/metadata/MetaData.java b/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/repository/metadata/MetaData.java
new file mode 100644
index 0000000..195378c
--- /dev/null
+++ b/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/repository/metadata/MetaData.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.repository.metadata;
+
+/**
+ * Generic meta data interface.
+ *
+ * @version $Id: MetaData.java 473861 2006-11-12 03:51:14Z gregor $
+ *
+ * @deprecated duplicate of o.a.l.cms.metadata
+ */
+public interface MetaData {
+
+ /**
+ * Returns the values for a certain key.
+ * @param key The key.
+ * @return An array of strings.
+ * @throws MetaDataException when something went wrong.
+ */
+ String[] getValues(String key) throws MetaDataException;
+
+ /**
+ * Returns the first value for a certain key.
+ * @param key The key.
+ * @return A string or <code>null</code> if no value is set for this key.
+ * @throws MetaDataException if an error occurs.
+ */
+ String getFirstValue(String key) throws MetaDataException;
+
+ /**
+ * Get all available keys.
+ * @return The keys available in this MetaData object.
+ */
+ String[] getAvailableKeys();
+
+ /**
+ * Sets the value for a certain key. All existing values will be removed.
+ * @param key The key.
+ * @param value The value to set.
+ * @throws MetaDataException when something went wrong.
+ */
+ void setValue(String key, String value) throws MetaDataException;
+
+ /**
+ * Addds a value for a certain key. The existing values will not be removed.
+ * @param key The key.
+ * @param value The value to add.
+ * @throws MetaDataException if there's already a value set and the element doesn't support multiple values.
+ */
+ void addValue(String key, String value) throws MetaDataException;
+
+ /**
+ * Replace the contents of the current meta data by the contents of other.
+ * @param other The other meta data manager.
+ * @throws MetaDataException if an error occurs.
+ */
+ void replaceBy(MetaData other) throws MetaDataException;
+
+ /**
+ * Replace the contents of the current meta data by the contents of other.
+ * All meta data is replaced, disregarding the rules given by element.getActionOnCopy().
+ * @param other The other meta data manager.
+ * @throws MetaDataException if an error occurs.
+ */
+ void forcedReplaceBy(MetaData other) throws MetaDataException;
+
+ /**
+ * @return All keys that can be used.
+ */
+ String[] getPossibleKeys();
+
+ /**
+ * Checks if a key represents a valid metadata attribute.
+ * @param key The key.
+ * @return A boolean value.
+ */
+ boolean isValidAttribute(String key);
+
+ /**
+ * Get last modification date.
+ * @return last modification date
+ * @throws MetaDataException if an error occurs.
+ */
+ long getLastModified() throws MetaDataException;
+
+ /**
+ * @return The element set this meta data object belongs to.
+ */
+ ElementSet getElementSet();
+
+ /**
+ * Removes all values for a certain key.
+ * @param key The key.
+ * @throws MetaDataException if the key is not supported.
+ */
+ void removeAllValues(String key) throws MetaDataException;
+
+}
diff --git a/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/repository/metadata/MetaDataException.java b/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/repository/metadata/MetaDataException.java
new file mode 100644
index 0000000..e08910b
--- /dev/null
+++ b/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/repository/metadata/MetaDataException.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.repository.metadata;
+
+/**
+ * Meta data exception.
+ *
+ * @deprecated duplicate of o.a.l.cms.metadata
+ */
+public class MetaDataException extends Exception {
+
+ /**
+ *
+ */
+ public MetaDataException() {
+ super();
+ }
+
+ /**
+ * @param arg0
+ * @param arg1
+ */
+ public MetaDataException(String arg0, Throwable arg1) {
+ super(arg0, arg1);
+ }
+
+ /**
+ * @param arg0
+ */
+ public MetaDataException(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * @param arg0
+ */
+ public MetaDataException(Throwable arg0) {
+ super(arg0);
+ }
+
+}
diff --git a/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/repository/metadata/MetaDataOwner.java b/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/repository/metadata/MetaDataOwner.java
new file mode 100644
index 0000000..9d4626e
--- /dev/null
+++ b/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/repository/metadata/MetaDataOwner.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.repository.metadata;
+
+/**
+ * Owner of meta-data.
+ *
+ * @version $Id: MetaDataOwner.java 473861 2006-11-12 03:51:14Z gregor $
+ */
+public interface MetaDataOwner {
+
+ /**
+ * Returns a meta data object.
+ * @param namespaceUri The namespace URI.
+ * @return A meta data object.
+ * @throws MetaDataException if an error occurs.
+ */
+ MetaData getMetaData(String namespaceUri) throws MetaDataException;
+
+ /**
+ * Returns the URIs of the meta data currently supported by the owner.
+ * @return An array of strings.
+ * @throws MetaDataException if an error occurs.
+ */
+ String[] getMetaDataNamespaceUris() throws MetaDataException;
+
+}
diff --git a/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/repository/metadata/MetaDataRegistry.java b/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/repository/metadata/MetaDataRegistry.java
new file mode 100644
index 0000000..595d8c1
--- /dev/null
+++ b/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/cms/repository/metadata/MetaDataRegistry.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.repository.metadata;
+
+/**
+ * Meta data registry.
+ *
+ * @deprecated duplicate of o.a.l.cms.metadata
+ */
+public interface MetaDataRegistry {
+
+ /**
+ * The service role.
+ */
+ String ROLE = MetaDataRegistry.class.getName();
+
+ /**
+ * @param namespaceUri The namespace URI of the element set.
+ * @return the element set.
+ * @throws MetaDataException if an error occurs.
+ */
+ ElementSet getElementSet(String namespaceUri) throws MetaDataException;
+
+ /**
+ * Checks if an element set is registered.
+ * @param namespaceUri The namespace URI.
+ * @return A boolean value.
+ * @throws MetaDataException if an error occurs.
+ */
+ boolean isRegistered(String namespaceUri) throws MetaDataException;
+
+ /**
+ * Register an element set.
+ * @param namespaceUri The namespace URI.
+ * @param elementSet The element set.
+ * @throws MetaDataException if a set is already registered for this name.
+ */
+ void register(String namespaceUri, ElementSet elementSet) throws MetaDataException;
+
+ /**
+ * @return The registered namespace URIs.
+ * @throws MetaDataException if an error occurs.
+ */
+ String[] getNamespaceUris() throws MetaDataException;
+
+}
diff --git a/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/util/ServletHelper.java b/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/util/ServletHelper.java
new file mode 100644
index 0000000..1148f20
--- /dev/null
+++ b/org.apache.lenya.deprecated/src/main/java/org/apache/lenya/util/ServletHelper.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+/* $Id$ */
+
+package org.apache.lenya.util;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
+import org.apache.excalibur.source.SourceNotFoundException;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.lenya.cms.cocoon.source.SourceUtil;
+import org.apache.xpath.XPathAPI;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+/**
+ * Servlet utility class
+ *
+ * @deprecated use org.apache.lenya.utils.ServletHelper instead because
+ * this class return the current servlet and with the C2.2 servlet protocol, we don't retrieve the "main" servlet (associated to the browser url)
+ * but the servlet generated by the servlet protocol.
+ * we may have to build a servletHelper that allow to navigate throw the servlet stack and have information on each servlet.
+ * .
+ */
+public final class ServletHelper {
+
+ /**
+ * Ctor.
+ */
+ private ServletHelper() {
+ // do nothing
+ }
+
+ /**
+ * Returns the URL inside the web application (without the context prefix).
+ * @param request The request.
+ * @return A string.
+ */
+ public static String getWebappURI(HttpServletRequest request) {
+ String context = request.getContextPath();
+ String requestUri = request.getRequestURI();
+ return getWebappURI(context, requestUri);
+ }
+
+ /**
+ * Returns the URL inside the web application (without the context prefix).
+ * @param request The request.
+ * @return A string.
+ */
+ public static String getWebappURI(Request request) {
+ String context = request.getContextPath();
+ String requestUri = request.getRequestURI();
+ return getWebappURI(context, requestUri);
+ }
+
+ /**
+ * Returns the URL inside the web application (without the context prefix).
+ * @param context The context prefix.
+ * @param requestUri The complete request URI.
+ * @return A string.
+ */
+ public static String getWebappURI(String context, String requestUri) {
+
+ if (context == null) {
+ context = "";
+ }
+ String url = requestUri.substring(context.length());
+ if (url.length() > 0 && !url.startsWith("/")) {
+ url = "/" + url;
+ }
+ return url;
+
+ }
+
+ /**
+ * Converts the request parameters to a map. If a key is mapped to multiple parameters, a string
+ * array is used as the value.
+ * @param request The request.
+ * @return A map.
+ */
+ public static Map getParameterMap(Request request) {
+ Map requestParameters = new HashMap();
+ for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) {
+ String key = (String) e.nextElement();
+ String[] values = request.getParameterValues(key);
+ Object value;
+ if (values.length == 1) {
+ value = values[0];
+ } else {
+ value = values;
+ }
+ requestParameters.put(key, value);
+ }
+ return requestParameters;
+ }
+
+ private static Boolean uploadEnabled = null;
+
+ /**
+ * Returns the value of enable-uploads in web.xml
+ * @return true if enable upload is true or not set in web.xml, else false
+ */
+ public static synchronized boolean isUploadEnabled() throws SourceNotFoundException,
+ ParserConfigurationException, SAXException, IOException, TransformerException {
+
+ if (ServletHelper.uploadEnabled == null) {
+
+ Node node;
+ String webappUrl = "context://WEB-INF/web.xml";
+ SourceResolver resolver = (SourceResolver) WebAppContextUtils
+ .getCurrentWebApplicationContext().getBean(SourceResolver.ROLE);
+ Document document = SourceUtil.readDOM(webappUrl, resolver);
+ Element root = document.getDocumentElement();
+ node = XPathAPI.selectSingleNode(root,
+ "/web-app/servlet/init-param[param-name='enable-uploads']/param-value/text()");
+
+ if (node == null) {
+ ServletHelper.uploadEnabled = Boolean.FALSE;
+ } else {
+ boolean enabled = node.getNodeValue().equals("true");
+ ServletHelper.uploadEnabled = Boolean.valueOf(enabled);
+ }
+ }
+ return ServletHelper.uploadEnabled.booleanValue();
+ }
+}
diff --git a/org.apache.lenya.deprecated/src/test/java/org/apache/lenya/cms/metadata/MetaDataTest.java b/org.apache.lenya.deprecated/src/test/java/org/apache/lenya/cms/metadata/MetaDataTest.java
new file mode 100644
index 0000000..952f83d
--- /dev/null
+++ b/org.apache.lenya.deprecated/src/test/java/org/apache/lenya/cms/metadata/MetaDataTest.java
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 java.util.Map;
+
+import org.apache.lenya.cms.AbstractAccessControlTest;
+import org.apache.lenya.cms.metadata.dublincore.DublinCore;
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.repository.metadata.Element;
+
+/**
+ * Meta data test.
+ * @deprecated implies cyclic dependencies in new structure
+ */
+public class MetaDataTest extends AbstractAccessControlTest {
+
+ /**
+ * Tests the meta data.
+ * @throws Exception
+ */
+ public void testMetaData() throws Exception {
+
+ Publication publication = getSession().getPublication("test");
+ Document doc = publication.getArea("authoring").getSite().getNode("/index").getLink("en")
+ .getDocument();
+
+ String namespaceUri = "foobar";
+ Exception e = null;
+ try {
+ doc.getMetaData(namespaceUri);
+ } catch (Exception e1) {
+ e = e1;
+ }
+ assertNotNull(e);
+
+ namespaceUri = DublinCore.DC_NAMESPACE;
+ MetaData dc = doc.getMetaData(namespaceUri);
+
+ doc.lock();
+
+ checkSetTitle(dc);
+ checkRemoveAllValues(dc);
+
+ }
+
+ protected void checkSetTitle(MetaData dc) throws MetaDataException {
+ Exception e = null;
+ try {
+ dc.setValue("foo", "bar");
+ } catch (Exception e1) {
+ e = e1;
+ }
+ assertNotNull(e);
+ dc.setValue("title", "This is the title");
+
+ e = null;
+ // addValue() should throw an exception because a value is already set
+ try {
+ dc.addValue("title", "bar");
+ } catch (Exception e1) {
+ e = e1;
+ }
+ assertNotNull(e);
+
+ }
+
+ String NAMESPACE = "http://apache.org/lenya/test/metadata";
+
+ protected void checkOnCopy(Publication pub) throws Exception {
+ MetaDataRegistryWrapper registry = null;
+ try {
+ registry = (MetaDataRegistryWrapper) getManager().lookup(MetaDataRegistry.ROLE);
+ org.apache.lenya.cms.repository.metadata.ElementSet set = new TestElementSet();
+ registry.getRepositoryMetaDataRegistry().register(NAMESPACE, set);
+ } finally {
+ getManager().release(registry);
+ }
+
+ Document source = pub.getArea(Publication.AUTHORING_AREA).getDocument("/index", "en");
+ Document target = pub.getArea(Publication.AUTHORING_AREA).getDocument("/index", "en");
+
+ MetaData sourceMeta = source.getMetaData(NAMESPACE);
+ sourceMeta.setValue("copy", "sourceCopy");
+ sourceMeta.setValue("ignore", "sourceIgnore");
+ sourceMeta.setValue("delete", "sourceDelete");
+
+ MetaData targetMeta = target.getMetaData(NAMESPACE);
+ targetMeta.setValue("ignore", "targetIgnore");
+ targetMeta.setValue("delete", "targetDelete");
+
+ targetMeta.replaceBy(sourceMeta);
+
+ assertTrue(targetMeta.getValues("copy").length == 1);
+ assertEquals(sourceMeta.getValues("copy"), targetMeta.getValues("copy"));
+
+ assertTrue(targetMeta.getValues("ignore").length == 1);
+ assertEquals(targetMeta.getFirstValue("ignore"), "targetIgnore");
+
+ assertTrue(targetMeta.getValues("delete").length == 0);
+ }
+
+ protected void checkRemoveAllValues(MetaData dc) throws MetaDataException {
+ dc.removeAllValues("title");
+ assertTrue(dc.getValues("title").length == 0);
+ }
+
+ protected class TestElement implements org.apache.lenya.cms.repository.metadata.Element {
+
+ private String name;
+ private int actionOnCopy;
+
+ protected TestElement(String name, int actionOnCopy) {
+ this.name = name;
+ this.actionOnCopy = actionOnCopy;
+ }
+
+ public int getActionOnCopy() {
+ return actionOnCopy;
+ }
+
+ public String getDescription() {
+ return "";
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean isEditable() {
+ return false;
+ }
+
+ public boolean isMultiple() {
+ return false;
+ }
+
+ public boolean isSearchable() {
+ return false;
+ }
+
+ }
+
+ protected class TestElementSet implements org.apache.lenya.cms.repository.metadata.ElementSet {
+
+ private org.apache.lenya.cms.repository.metadata.Element[] elements = {
+ new TestElement("copy", Element.ONCOPY_COPY),
+ new TestElement("ignore", Element.ONCOPY_IGNORE),
+ new TestElement("delete", Element.ONCOPY_DELETE) };
+
+ private Map<String, org.apache.lenya.cms.repository.metadata.Element> name2element;
+
+ protected TestElementSet() {
+ for (int i = 0; i < elements.length; i++) {
+ this.name2element.put(elements[i].getName(), elements[i]);
+ }
+ }
+
+ public boolean containsElement(String name) {
+ return true;
+ }
+
+ public org.apache.lenya.cms.repository.metadata.Element getElement(String name)
+ throws org.apache.lenya.cms.repository.metadata.MetaDataException {
+ return (org.apache.lenya.cms.repository.metadata.Element) this.name2element.get(name);
+ }
+
+ public org.apache.lenya.cms.repository.metadata.Element[] getElements() {
+ return elements;
+ }
+
+ public String getNamespaceUri() {
+ return NAMESPACE;
+ }
+
+ }
+
+}