You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2013/03/11 18:02:16 UTC
svn commit: r1455235 - in /chemistry/opencmis/trunk:
chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/
chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/ma...
Author: fmui
Date: Mon Mar 11 17:02:16 2013
New Revision: 1455235
URL: http://svn.apache.org/r1455235
Log:
CMIS 1.1 AtomPub, step 4
Added:
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/QueryTypeImpl.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AclConvertTest.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AllowableActionsConvertTest.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/QueryConvertTest.java (with props)
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AbstractAtomPubService.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/DiscoveryServiceImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JaxBHelper.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConstants.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AbstractXMLConverterTest.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AclService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/DiscoveryService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AbstractAtomPubService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AbstractAtomPubService.java?rev=1455235&r1=1455234&r2=1455235&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AbstractAtomPubService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AbstractAtomPubService.java Mon Mar 11 17:02:16 2013
@@ -30,6 +30,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.xml.stream.XMLStreamWriter;
+
import org.apache.chemistry.opencmis.client.bindings.impl.CmisBindingsHelper;
import org.apache.chemistry.opencmis.client.bindings.impl.RepositoryInfoCache;
import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
@@ -74,9 +76,10 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisVersioningException;
import org.apache.chemistry.opencmis.commons.impl.Constants;
-import org.apache.chemistry.opencmis.commons.impl.JaxBHelper;
import org.apache.chemistry.opencmis.commons.impl.ReturnVersion;
import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
+import org.apache.chemistry.opencmis.commons.impl.XMLConverter;
+import org.apache.chemistry.opencmis.commons.impl.XMLUtils;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlEntryImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl;
@@ -84,7 +87,6 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PolicyIdListImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIdImpl;
-import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisAccessControlListType;
import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectType;
import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisRepositoryInfoType;
import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeDefinitionType;
@@ -922,7 +924,7 @@ public abstract class AbstractAtomPubSer
/**
* Updates the ACL of an object.
*/
- protected AtomAcl updateAcl(String repositoryId, String objectId, Acl acl, AclPropagation aclPropagation) {
+ protected AtomAcl updateAcl(String repositoryId, String objectId, final Acl acl, AclPropagation aclPropagation) {
// find the link
String link = loadLink(repositoryId, objectId, Constants.REL_ACL, Constants.MEDIATYPE_ACL);
@@ -934,13 +936,15 @@ public abstract class AbstractAtomPubSer
UrlBuilder aclUrl = new UrlBuilder(link);
aclUrl.addParameter(Constants.PARAM_ACL_PROPAGATION, aclPropagation);
- // set up object and writer
- final CmisAccessControlListType aclJaxb = convert(acl);
+ final CmisVersion cmisVersion = getCmisVersion(repositoryId);
// update
Response resp = put(aclUrl, Constants.MEDIATYPE_ACL, new Output() {
public void write(OutputStream out) throws Exception {
- JaxBHelper.marshal(JaxBHelper.CMIS_OBJECT_FACTORY.createAcl(aclJaxb), out, false);
+ XMLStreamWriter writer = XMLUtils.createWriter(out);
+ XMLUtils.startXmlDocument(writer);
+ XMLConverter.writeAcl(writer, cmisVersion, true, acl);
+ XMLUtils.endXmlDocument(writer);
}
});
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/DiscoveryServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/DiscoveryServiceImpl.java?rev=1455235&r1=1455234&r2=1455235&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/DiscoveryServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/DiscoveryServiceImpl.java Mon Mar 11 17:02:16 2013
@@ -24,6 +24,8 @@ import java.io.OutputStream;
import java.math.BigInteger;
import java.util.ArrayList;
+import javax.xml.stream.XMLStreamWriter;
+
import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomElement;
import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomEntry;
@@ -34,15 +36,16 @@ import org.apache.chemistry.opencmis.cli
import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
import org.apache.chemistry.opencmis.commons.data.ObjectData;
import org.apache.chemistry.opencmis.commons.data.ObjectList;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.impl.Constants;
-import org.apache.chemistry.opencmis.commons.impl.JaxBHelper;
import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
+import org.apache.chemistry.opencmis.commons.impl.XMLConverter;
+import org.apache.chemistry.opencmis.commons.impl.XMLUtils;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectListImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.QueryTypeImpl;
import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectType;
-import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisQueryType;
-import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumIncludeRelationships;
import org.apache.chemistry.opencmis.commons.spi.DiscoveryService;
import org.apache.chemistry.opencmis.commons.spi.Holder;
@@ -130,19 +133,24 @@ public class DiscoveryServiceImpl extend
UrlBuilder url = new UrlBuilder(link);
// compile query request
- final CmisQueryType query = new CmisQueryType();
+ final QueryTypeImpl query = new QueryTypeImpl();
query.setStatement(statement);
query.setSearchAllVersions(searchAllVersions);
query.setIncludeAllowableActions(includeAllowableActions);
- query.setIncludeRelationships(convert(EnumIncludeRelationships.class, includeRelationships));
+ query.setIncludeRelationships(includeRelationships);
query.setRenditionFilter(renditionFilter);
query.setMaxItems(maxItems);
query.setSkipCount(skipCount);
+ final CmisVersion cmisVersion = getCmisVersion(repositoryId);
+
// post the query and parse results
Response resp = post(url, Constants.MEDIATYPE_QUERY, new Output() {
public void write(OutputStream out) throws Exception {
- JaxBHelper.marshal(JaxBHelper.CMIS_OBJECT_FACTORY.createQuery(query), out, false);
+ XMLStreamWriter writer = XMLUtils.createWriter(out);
+ XMLUtils.startXmlDocument(writer);
+ XMLConverter.writeQuery(writer, cmisVersion, query);
+ XMLUtils.endXmlDocument(writer);
}
});
AtomFeed feed = parse(resp.getStream(), AtomFeed.class);
Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JaxBHelper.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JaxBHelper.java?rev=1455235&r1=1455234&r2=1455235&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JaxBHelper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JaxBHelper.java Mon Mar 11 17:02:16 2013
@@ -18,14 +18,9 @@
*/
package org.apache.chemistry.opencmis.commons.impl;
-import java.io.OutputStream;
-
import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
-import javax.xml.stream.XMLStreamWriter;
import org.apache.chemistry.opencmis.commons.impl.jaxb.ObjectFactory;
@@ -63,43 +58,4 @@ public final class JaxBHelper {
public static Unmarshaller createUnmarshaller() throws JAXBException {
return CONTEXT.createUnmarshaller();
}
-
- /**
- * Creates an Marshaller.
- */
- public static Marshaller createMarshaller() throws JAXBException {
- return CONTEXT.createMarshaller();
- }
-
- /**
- * Marshals an object to a stream.
- */
- public static <T> void marshal(JAXBElement<T> object, OutputStream out, boolean fragment) throws JAXBException {
- if (object == null) {
- return;
- }
-
- Marshaller m = CONTEXT.createMarshaller();
- if (fragment) {
- m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
- }
-
- m.marshal(object, out);
- }
-
- /**
- * Marshals an object to a XMLStreamWriter.
- */
- public static void marshal(Object object, XMLStreamWriter out, boolean fragment) throws JAXBException {
- if (object == null) {
- return;
- }
-
- Marshaller m = CONTEXT.createMarshaller();
- if (fragment) {
- m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
- }
-
- m.marshal(object, out);
- }
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConstants.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConstants.java?rev=1455235&r1=1455234&r2=1455235&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConstants.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConstants.java Mon Mar 11 17:02:16 2013
@@ -232,4 +232,13 @@ public class XMLConstants {
public static final String TAG_TYPE_TYPE_MUTABILITY_CREATE = "create";
public static final String TAG_TYPE_TYPE_MUTABILITY_UPDATE = "update";
public static final String TAG_TYPE_TYPE_MUTABILITY_DELETE = "delete";
+
+ public static final String TAG_QUERY = "query";
+ public static final String TAG_QUERY_STATEMENT = "statement";
+ public static final String TAG_QUERY_SEARCHALLVERSIONS = "searchAllVersions";
+ public static final String TAG_QUERY_INCLUDEALLOWABLEACTIONS = "includeAllowableActions";
+ public static final String TAG_QUERY_INCLUDERELATIONSHIPS = "includeRelationships";
+ public static final String TAG_QUERY_RENDITIONFILTER = "renditionFilter";
+ public static final String TAG_QUERY_MAXITEMS = "maxItems";
+ public static final String TAG_QUERY_SKIPCOUNT = "skipCount";
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java?rev=1455235&r1=1455234&r2=1455235&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java Mon Mar 11 17:02:16 2013
@@ -93,6 +93,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.enums.ContentStreamAllowed;
import org.apache.chemistry.opencmis.commons.enums.DateTimeResolution;
import org.apache.chemistry.opencmis.commons.enums.DecimalPrecision;
+import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
import org.apache.chemistry.opencmis.commons.enums.PropertyType;
import org.apache.chemistry.opencmis.commons.enums.SupportedPermissions;
import org.apache.chemistry.opencmis.commons.enums.Updatability;
@@ -136,6 +137,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyUriDefinitionImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyUriImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.QueryTypeImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.RelationshipTypeDefinitionImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.RenditionDataImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryCapabilitiesImpl;
@@ -897,6 +899,33 @@ public class XMLConverter {
writer.writeEndElement();
}
+ // -------------
+ // --- query ---
+ // -------------
+
+ public static void writeQuery(XMLStreamWriter writer, CmisVersion cmisVersion, QueryTypeImpl source)
+ throws XMLStreamException {
+ if (source == null) {
+ return;
+ }
+
+ writer.writeStartElement(NAMESPACE_CMIS, TAG_QUERY);
+ writer.writeNamespace(PREFIX_CMIS, NAMESPACE_CMIS);
+
+ XMLUtils.write(writer, PREFIX_CMIS, NAMESPACE_CMIS, TAG_QUERY_STATEMENT, source.getStatement());
+ XMLUtils.write(writer, PREFIX_CMIS, NAMESPACE_CMIS, TAG_QUERY_SEARCHALLVERSIONS, source.getSearchAllVersions());
+ XMLUtils.write(writer, PREFIX_CMIS, NAMESPACE_CMIS, TAG_QUERY_INCLUDEALLOWABLEACTIONS,
+ source.getIncludeAllowableActions());
+ XMLUtils.write(writer, PREFIX_CMIS, NAMESPACE_CMIS, TAG_QUERY_INCLUDERELATIONSHIPS,
+ source.getIncludeRelationships());
+ XMLUtils.write(writer, PREFIX_CMIS, NAMESPACE_CMIS, TAG_QUERY_RENDITIONFILTER, source.getRenditionFilter());
+ XMLUtils.write(writer, PREFIX_CMIS, NAMESPACE_CMIS, TAG_QUERY_MAXITEMS, source.getMaxItems());
+ XMLUtils.write(writer, PREFIX_CMIS, NAMESPACE_CMIS, TAG_QUERY_SKIPCOUNT, source.getSkipCount());
+
+ writeExtensions(writer, source);
+ writer.writeEndElement();
+ }
+
// -------------------------
// --- extension writers ---
// -------------------------
@@ -989,6 +1018,18 @@ public class XMLConverter {
return OBJECT_PARSER.walk(parser);
}
+ public static QueryTypeImpl convertQuery(XMLStreamReader parser) throws XMLStreamException {
+ return QUERY_PARSER.walk(parser);
+ }
+
+ public static AllowableActions convertAllowableActions(XMLStreamReader parser) throws XMLStreamException {
+ return ALLOWABLE_ACTIONS_PARSER.walk(parser);
+ }
+
+ public static Acl convertAcl(XMLStreamReader parser) throws XMLStreamException {
+ return ACL_PARSER.walk(parser);
+ }
+
// ------------------------------
// --- repository info parser ---
// ------------------------------
@@ -2495,4 +2536,57 @@ public class XMLConverter {
target.setValues(addToList(target.getValues(), readText(parser)));
}
}
+
+ // --------------------
+ // --- query parser ---
+ // --------------------
+
+ private static final XMLWalker<QueryTypeImpl> QUERY_PARSER = new XMLWalker<QueryTypeImpl>() {
+ @Override
+ protected QueryTypeImpl prepareTarget(XMLStreamReader parser, QName name) throws XMLStreamException {
+ return new QueryTypeImpl();
+ }
+
+ @Override
+ protected boolean read(XMLStreamReader parser, QName name, QueryTypeImpl target) throws XMLStreamException {
+ if (isCmisNamespace(name)) {
+ if (isTag(name, TAG_QUERY_STATEMENT)) {
+ target.setStatement(readText(parser));
+ return true;
+ }
+
+ if (isTag(name, TAG_QUERY_SEARCHALLVERSIONS)) {
+ target.setSearchAllVersions(readBoolean(parser));
+ return true;
+ }
+
+ if (isTag(name, TAG_QUERY_INCLUDEALLOWABLEACTIONS)) {
+ target.setIncludeAllowableActions(readBoolean(parser));
+ return true;
+ }
+
+ if (isTag(name, TAG_QUERY_INCLUDERELATIONSHIPS)) {
+ target.setIncludeRelationships(readEnum(parser, IncludeRelationships.class));
+ return true;
+ }
+
+ if (isTag(name, TAG_QUERY_RENDITIONFILTER)) {
+ target.setRenditionFilter(readText(parser));
+ return true;
+ }
+
+ if (isTag(name, TAG_QUERY_MAXITEMS)) {
+ target.setMaxItems(readInteger(parser));
+ return true;
+ }
+
+ if (isTag(name, TAG_QUERY_SKIPCOUNT)) {
+ target.setSkipCount(readInteger(parser));
+ return true;
+ }
+ }
+
+ return false;
+ }
+ };
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java?rev=1455235&r1=1455234&r2=1455235&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java Mon Mar 11 17:02:16 2013
@@ -214,7 +214,12 @@ public class XMLUtils {
*/
public static boolean next(XMLStreamReader parser) throws XMLStreamException {
if (parser.hasNext()) {
- parser.next();
+ try {
+ parser.next();
+ } catch (XMLStreamException e) {
+ // EOF exceptions
+ return false;
+ }
return true;
}
Added: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/QueryTypeImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/QueryTypeImpl.java?rev=1455235&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/QueryTypeImpl.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/QueryTypeImpl.java Mon Mar 11 17:02:16 2013
@@ -0,0 +1,103 @@
+/*
+ * 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.chemistry.opencmis.commons.impl.dataobjects;
+
+import java.math.BigInteger;
+
+import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+
+public class QueryTypeImpl extends AbstractExtensionData {
+
+ private static final long serialVersionUID = 1L;
+
+ private String statement;
+ private Boolean searchAllVersions;
+ private Boolean includeAllowableActions;
+ private IncludeRelationships includeRelationships;
+ private String renditionFilter;
+ private BigInteger maxItems;
+ private BigInteger skipCount;
+
+ public QueryTypeImpl() {
+ }
+
+ public String getStatement() {
+ return statement;
+ }
+
+ public void setStatement(String statement) {
+ this.statement = statement;
+ }
+
+ public Boolean getSearchAllVersions() {
+ return searchAllVersions;
+ }
+
+ public void setSearchAllVersions(Boolean searchAllVersions) {
+ this.searchAllVersions = searchAllVersions;
+ }
+
+ public Boolean getIncludeAllowableActions() {
+ return includeAllowableActions;
+ }
+
+ public void setIncludeAllowableActions(Boolean includeAllowableActions) {
+ this.includeAllowableActions = includeAllowableActions;
+ }
+
+ public IncludeRelationships getIncludeRelationships() {
+ return includeRelationships;
+ }
+
+ public void setIncludeRelationships(IncludeRelationships includeRelationships) {
+ this.includeRelationships = includeRelationships;
+ }
+
+ public String getRenditionFilter() {
+ return renditionFilter;
+ }
+
+ public void setRenditionFilter(String renditionFilter) {
+ this.renditionFilter = renditionFilter;
+ }
+
+ public BigInteger getMaxItems() {
+ return maxItems;
+ }
+
+ public void setMaxItems(BigInteger maxItems) {
+ this.maxItems = maxItems;
+ }
+
+ public BigInteger getSkipCount() {
+ return skipCount;
+ }
+
+ public void setSkipCount(BigInteger skipCount) {
+ this.skipCount = skipCount;
+ }
+
+ @Override
+ public String toString() {
+ return "QueryType [statement=" + statement + ", searchAllVersions=" + searchAllVersions
+ + ", includeAllowableActions=" + includeAllowableActions + ", includeRelationships="
+ + includeRelationships + ", renditionFilter=" + renditionFilter + ", maxItems=" + maxItems
+ + ", skipCount=" + skipCount + "]" + super.toString();
+ }
+}
Propchange: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/QueryTypeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AbstractXMLConverterTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AbstractXMLConverterTest.java?rev=1455235&r1=1455234&r2=1455235&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AbstractXMLConverterTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AbstractXMLConverterTest.java Mon Mar 11 17:02:16 2013
@@ -85,6 +85,7 @@ public abstract class AbstractXMLConvert
+ "<xs:element name=\"repositoryInfo\" type=\"cmis:cmisRepositoryInfoType\" minOccurs=\"0\" maxOccurs=\"1\" />"
+ "<xs:element name=\"type\" type=\"cmis:cmisTypeDefinitionType\" minOccurs=\"0\" maxOccurs=\"1\" />"
+ "<xs:element name=\"object\" type=\"cmis:cmisObjectType\" minOccurs=\"0\" maxOccurs=\"1\" />"
+ + "<xs:element name=\"query\" type=\"cmis:cmisQueryType\" minOccurs=\"0\" maxOccurs=\"1\" />"
+ "</xs:sequence>" //
+ "</xs:complexType>" //
+ "<xs:element name=\"test\" type=\"test:testType\"/>" //
Added: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AclConvertTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AclConvertTest.java?rev=1455235&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AclConvertTest.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AclConvertTest.java Mon Mar 11 17:02:16 2013
@@ -0,0 +1,116 @@
+/*
+ * 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.chemistry.opencmis.commons.impl.xml;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.chemistry.opencmis.commons.data.Ace;
+import org.apache.chemistry.opencmis.commons.data.Acl;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
+import org.apache.chemistry.opencmis.commons.impl.XMLConverter;
+import org.apache.chemistry.opencmis.commons.impl.XMLUtils;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlEntryImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl;
+import org.junit.Test;
+
+public class AclConvertTest extends AbstractXMLConverterTest {
+
+ @Test
+ public void testAcl() throws Exception {
+
+ // run the test a few times with different values
+ for (int i = 0; i < 10; i++) {
+ AccessControlListImpl acl = new AccessControlListImpl();
+ List<Ace> aces = new ArrayList<Ace>();
+ for (int j = 0; j < randomInt(9) + 1; j++) {
+ AccessControlEntryImpl ace = new AccessControlEntryImpl();
+ List<String> permissions = new ArrayList<String>();
+ for (int k = 0; k < randomInt(4) + 1; k++) {
+ permissions.add(randomString());
+ }
+ ace.setPermissions(permissions);
+ ace.setDirect(randomBoolean());
+ ace.setPrincipal(new AccessControlPrincipalDataImpl(randomString()));
+ aces.add(ace);
+ }
+ acl.setAces(aces);
+
+ assertAcl10(acl, true);
+ assertAcl11(acl, true);
+ }
+ }
+
+ protected void assertAcl10(Acl data, boolean validate) throws Exception {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ XMLStreamWriter writer = XMLUtils.createWriter(out);
+ XMLUtils.startXmlDocument(writer);
+ XMLConverter.writeAcl(writer, CmisVersion.CMIS_1_0, true, data);
+ XMLUtils.endXmlDocument(writer);
+
+ byte[] xml = out.toByteArray();
+
+ if (validate) {
+ validate(xml, CmisVersion.CMIS_1_0);
+ }
+
+ XMLStreamReader parser = XMLUtils.createParser(new ByteArrayInputStream(xml));
+ XMLUtils.findNextStartElemenet(parser);
+ Acl result = XMLConverter.convertAcl(parser);
+ parser.close();
+
+ assertNotNull(result);
+ assertDataObjectsEquals("ACL", data, result, null);
+ assertNull(result.getExtensions());
+ }
+
+ protected void assertAcl11(Acl data, boolean validate) throws Exception {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ XMLStreamWriter writer = XMLUtils.createWriter(out);
+ XMLUtils.startXmlDocument(writer);
+ XMLConverter.writeAcl(writer, CmisVersion.CMIS_1_1, true, data);
+ XMLUtils.endXmlDocument(writer);
+
+ byte[] xml = out.toByteArray();
+
+ if (validate) {
+ validate(xml, CmisVersion.CMIS_1_1);
+ }
+
+ XMLStreamReader parser = XMLUtils.createParser(new ByteArrayInputStream(xml));
+ XMLUtils.findNextStartElemenet(parser);
+ Acl result = XMLConverter.convertAcl(parser);
+ parser.close();
+
+ assertNotNull(result);
+ assertDataObjectsEquals("ACL", data, result, null);
+ assertNull(result.getExtensions());
+ }
+}
Propchange: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AclConvertTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AllowableActionsConvertTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AllowableActionsConvertTest.java?rev=1455235&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AllowableActionsConvertTest.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AllowableActionsConvertTest.java Mon Mar 11 17:02:16 2013
@@ -0,0 +1,106 @@
+/*
+ * 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.chemistry.opencmis.commons.impl.xml;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.HashSet;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.chemistry.opencmis.commons.data.AllowableActions;
+import org.apache.chemistry.opencmis.commons.enums.Action;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
+import org.apache.chemistry.opencmis.commons.impl.XMLConverter;
+import org.apache.chemistry.opencmis.commons.impl.XMLUtils;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.AllowableActionsImpl;
+import org.junit.Test;
+
+public class AllowableActionsConvertTest extends AbstractXMLConverterTest {
+
+ @Test
+ public void testAllowableActions() throws Exception {
+
+ // run the test a few times with different values
+ for (int i = 0; i < 10; i++) {
+ AllowableActionsImpl allowableActions = new AllowableActionsImpl();
+ HashSet<Action> actions = new HashSet<Action>();
+ for (Action action : Action.values()) {
+ if (randomBoolean()) {
+ actions.add(action);
+ }
+ }
+
+ assertAllowableActions10(allowableActions, true);
+ assertAllowableActions11(allowableActions, true);
+ }
+ }
+
+ protected void assertAllowableActions10(AllowableActions data, boolean validate) throws Exception {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ XMLStreamWriter writer = XMLUtils.createWriter(out);
+ XMLUtils.startXmlDocument(writer);
+ XMLConverter.writeAllowableActions(writer, CmisVersion.CMIS_1_0, true, data);
+ XMLUtils.endXmlDocument(writer);
+
+ byte[] xml = out.toByteArray();
+
+ if (validate) {
+ validate(xml, CmisVersion.CMIS_1_0);
+ }
+
+ XMLStreamReader parser = XMLUtils.createParser(new ByteArrayInputStream(xml));
+ XMLUtils.findNextStartElemenet(parser);
+ AllowableActions result = XMLConverter.convertAllowableActions(parser);
+ parser.close();
+
+ assertNotNull(result);
+ assertDataObjectsEquals("AllowableActions", data, result, null);
+ assertNull(result.getExtensions());
+ }
+
+ protected void assertAllowableActions11(AllowableActions data, boolean validate) throws Exception {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ XMLStreamWriter writer = XMLUtils.createWriter(out);
+ XMLUtils.startXmlDocument(writer);
+ XMLConverter.writeAllowableActions(writer, CmisVersion.CMIS_1_1, true, data);
+ XMLUtils.endXmlDocument(writer);
+
+ byte[] xml = out.toByteArray();
+
+ if (validate) {
+ validate(xml, CmisVersion.CMIS_1_1);
+ }
+
+ XMLStreamReader parser = XMLUtils.createParser(new ByteArrayInputStream(xml));
+ XMLUtils.findNextStartElemenet(parser);
+ AllowableActions result = XMLConverter.convertAllowableActions(parser);
+ parser.close();
+
+ assertNotNull(result);
+ assertDataObjectsEquals("AllowableActions", data, result, null);
+ assertNull(result.getExtensions());
+ }
+}
Propchange: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AllowableActionsConvertTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/QueryConvertTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/QueryConvertTest.java?rev=1455235&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/QueryConvertTest.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/QueryConvertTest.java Mon Mar 11 17:02:16 2013
@@ -0,0 +1,107 @@
+/*
+ * 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.chemistry.opencmis.commons.impl.xml;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
+import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.impl.XMLConverter;
+import org.apache.chemistry.opencmis.commons.impl.XMLUtils;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.QueryTypeImpl;
+import org.junit.Test;
+
+public class QueryConvertTest extends AbstractXMLConverterTest {
+
+ @Test
+ public void testQueryType() throws Exception {
+
+ // run the test a few times with different values
+ for (int i = 0; i < 10; i++) {
+ QueryTypeImpl query = new QueryTypeImpl();
+
+ query.setStatement(randomString());
+ query.setSearchAllVersions(randomBoolean());
+ query.setIncludeAllowableActions(randomBoolean());
+ query.setIncludeRelationships(randomEnum(IncludeRelationships.class));
+ query.setRenditionFilter(randomString());
+ query.setMaxItems(randomInteger());
+ query.setSkipCount(randomInteger());
+
+ assertQueryType10(query, true);
+ assertQueryType11(query, true);
+ }
+
+ }
+
+ protected void assertQueryType10(QueryTypeImpl data, boolean validate) throws Exception {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ XMLStreamWriter writer = XMLUtils.createWriter(out);
+ XMLUtils.startXmlDocument(writer);
+ XMLConverter.writeQuery(writer, CmisVersion.CMIS_1_0, data);
+ XMLUtils.endXmlDocument(writer);
+
+ byte[] xml = out.toByteArray();
+
+ if (validate) {
+ validate(xml, CmisVersion.CMIS_1_0);
+ }
+
+ XMLStreamReader parser = XMLUtils.createParser(new ByteArrayInputStream(xml));
+ XMLUtils.findNextStartElemenet(parser);
+ QueryTypeImpl result = XMLConverter.convertQuery(parser);
+ parser.close();
+
+ assertNotNull(result);
+ assertDataObjectsEquals("QueryType", data, result, null);
+ assertNull(result.getExtensions());
+ }
+
+ protected void assertQueryType11(QueryTypeImpl data, boolean validate) throws Exception {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ XMLStreamWriter writer = XMLUtils.createWriter(out);
+ XMLUtils.startXmlDocument(writer);
+ XMLConverter.writeQuery(writer, CmisVersion.CMIS_1_1, data);
+ XMLUtils.endXmlDocument(writer);
+
+ byte[] xml = out.toByteArray();
+
+ if (validate) {
+ validate(xml, CmisVersion.CMIS_1_1);
+ }
+
+ XMLStreamReader parser = XMLUtils.createParser(new ByteArrayInputStream(xml));
+ XMLUtils.findNextStartElemenet(parser);
+ QueryTypeImpl result = XMLConverter.convertQuery(parser);
+ parser.close();
+
+ assertNotNull(result);
+ assertDataObjectsEquals("QueryType", data, result, null);
+ assertNull(result.getExtensions());
+ }
+}
Propchange: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/QueryConvertTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AclService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AclService.java?rev=1455235&r1=1455234&r2=1455235&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AclService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AclService.java Mon Mar 11 17:02:16 2013
@@ -18,7 +18,6 @@
*/
package org.apache.chemistry.opencmis.server.impl.atompub;
-import static org.apache.chemistry.opencmis.commons.impl.Converter.convert;
import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBooleanParameter;
import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getEnumParameter;
import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
@@ -27,9 +26,8 @@ import java.io.OutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.Unmarshaller;
import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import org.apache.chemistry.opencmis.commons.data.Acl;
@@ -38,10 +36,8 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.impl.Constants;
-import org.apache.chemistry.opencmis.commons.impl.JaxBHelper;
import org.apache.chemistry.opencmis.commons.impl.XMLConverter;
import org.apache.chemistry.opencmis.commons.impl.XMLUtils;
-import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisAccessControlListType;
import org.apache.chemistry.opencmis.commons.server.CallContext;
import org.apache.chemistry.opencmis.commons.server.CmisService;
@@ -86,24 +82,24 @@ public class AclService {
String objectId = getStringParameter(request, Constants.PARAM_ID);
AclPropagation aclPropagation = getEnumParameter(request, Constants.PARAM_ACL_PROPAGATION, AclPropagation.class);
- Object aclRequest = null;
+ Acl aces = null;
+ XMLStreamReader parser = null;
try {
- Unmarshaller u = JaxBHelper.createUnmarshaller();
- aclRequest = u.unmarshal(request.getInputStream());
- } catch (Exception e) {
- throw new CmisInvalidArgumentException("Invalid ACL request: " + e, e);
+ parser = XMLUtils.createParser(request.getInputStream());
+ XMLUtils.findNextStartElemenet(parser);
+ aces = XMLConverter.convertAcl(parser);
+ } catch (XMLStreamException e) {
+ throw new CmisInvalidArgumentException("Invalid request!");
+ } finally {
+ if (parser != null) {
+ try {
+ parser.close();
+ } catch (XMLStreamException e2) {
+ // ignore
+ }
+ }
}
- if (!(aclRequest instanceof JAXBElement<?>)) {
- throw new CmisInvalidArgumentException("Not an ACL document!");
- }
-
- if (!(((JAXBElement<?>) aclRequest).getValue() instanceof CmisAccessControlListType)) {
- throw new CmisInvalidArgumentException("Not an ACL document!");
- }
-
- Acl aces = convert((CmisAccessControlListType) ((JAXBElement<?>) aclRequest).getValue(), null);
-
// execute
Acl acl = service.applyAcl(repositoryId, objectId, aces, aclPropagation);
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/DiscoveryService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/DiscoveryService.java?rev=1455235&r1=1455234&r2=1455235&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/DiscoveryService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/DiscoveryService.java Mon Mar 11 17:02:16 2013
@@ -18,7 +18,6 @@
*/
package org.apache.chemistry.opencmis.server.impl.atompub;
-import static org.apache.chemistry.opencmis.commons.impl.Converter.convert;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_CHANGES;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_QUERY;
import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileBaseUrl;
@@ -35,8 +34,8 @@ import java.util.GregorianCalendar;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.Unmarshaller;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
import org.apache.chemistry.opencmis.commons.data.ObjectData;
import org.apache.chemistry.opencmis.commons.data.ObjectList;
@@ -45,11 +44,11 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.impl.Constants;
-import org.apache.chemistry.opencmis.commons.impl.JaxBHelper;
import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
import org.apache.chemistry.opencmis.commons.impl.XMLConstants;
import org.apache.chemistry.opencmis.commons.impl.XMLConverter;
-import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisQueryType;
+import org.apache.chemistry.opencmis.commons.impl.XMLUtils;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.QueryTypeImpl;
import org.apache.chemistry.opencmis.commons.server.CallContext;
import org.apache.chemistry.opencmis.commons.server.CmisService;
import org.apache.chemistry.opencmis.commons.spi.Holder;
@@ -83,28 +82,29 @@ public final class DiscoveryService {
if (METHOD_POST.equals(request.getMethod())) {
// POST -> read from stream
- Object queryRequest = null;
- try {
- Unmarshaller u = JaxBHelper.createUnmarshaller();
- queryRequest = u.unmarshal(request.getInputStream());
- } catch (Exception e) {
- throw new CmisInvalidArgumentException("Invalid query request: " + e, e);
- }
-
- if (!(queryRequest instanceof JAXBElement<?>)) {
- throw new CmisInvalidArgumentException("Not a query document!");
- }
- if (!(((JAXBElement<?>) queryRequest).getValue() instanceof CmisQueryType)) {
- throw new CmisInvalidArgumentException("Not a query document!");
+ QueryTypeImpl queryType = null;
+ XMLStreamReader parser = null;
+ try {
+ parser = XMLUtils.createParser(request.getInputStream());
+ XMLUtils.findNextStartElemenet(parser);
+ queryType = XMLConverter.convertQuery(parser);
+ } catch (XMLStreamException e) {
+ throw new CmisInvalidArgumentException("Invalid query request!");
+ } finally {
+ if (parser != null) {
+ try {
+ parser.close();
+ } catch (XMLStreamException e2) {
+ // ignore
+ }
+ }
}
- CmisQueryType queryType = (CmisQueryType) ((JAXBElement<?>) queryRequest).getValue();
-
statement = queryType.getStatement();
- searchAllVersions = queryType.isSearchAllVersions();
- includeAllowableActions = queryType.isIncludeAllowableActions();
- includeRelationships = convert(IncludeRelationships.class, queryType.getIncludeRelationships());
+ searchAllVersions = queryType.getSearchAllVersions();
+ includeAllowableActions = queryType.getIncludeAllowableActions();
+ includeRelationships = queryType.getIncludeRelationships();
renditionFilter = queryType.getRenditionFilter();
maxItems = queryType.getMaxItems();
skipCount = queryType.getSkipCount();
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java?rev=1455235&r1=1455234&r2=1455235&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java Mon Mar 11 17:02:16 2013
@@ -40,8 +40,7 @@ import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.Unmarshaller;
+import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import org.apache.chemistry.opencmis.commons.PropertyIds;
@@ -92,8 +91,6 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.exceptions.CmisStreamNotSupportedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
import org.apache.chemistry.opencmis.commons.impl.Base64;
-import org.apache.chemistry.opencmis.commons.impl.Converter;
-import org.apache.chemistry.opencmis.commons.impl.JaxBHelper;
import org.apache.chemistry.opencmis.commons.impl.MimeTypes;
import org.apache.chemistry.opencmis.commons.impl.XMLConstants;
import org.apache.chemistry.opencmis.commons.impl.XMLConverter;
@@ -124,8 +121,6 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyUriImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryCapabilitiesImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryInfoImpl;
-import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectType;
-import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisProperty;
import org.apache.chemistry.opencmis.commons.impl.server.ObjectInfoImpl;
import org.apache.chemistry.opencmis.commons.server.CallContext;
import org.apache.chemistry.opencmis.commons.server.ObjectInfoHandler;
@@ -1499,7 +1494,6 @@ public class FileShareRepository {
/**
* Reads and adds properties.
*/
- @SuppressWarnings("unchecked")
private void readCustomProperties(File file, PropertiesImpl properties, Set<String> filter,
ObjectInfoImpl objectInfo) {
File propFile = getPropertiesFile(file);
@@ -1510,22 +1504,32 @@ public class FileShareRepository {
}
// parse it
- JAXBElement<CmisObjectType> obj = null;
+ ObjectData obj = null;
+ InputStream stream = null;
try {
- Unmarshaller u = JaxBHelper.createUnmarshaller();
- obj = (JAXBElement<CmisObjectType>) u.unmarshal(propFile);
+ stream = new BufferedInputStream(new FileInputStream(file));
+ XMLStreamReader parser = XMLUtils.createParser(stream);
+ XMLUtils.findNextStartElemenet(parser);
+ obj = XMLConverter.convertObject(parser);
+ parser.close();
} catch (Exception e) {
warn("Unvalid CMIS properties: " + propFile.getAbsolutePath(), e);
+ } finally {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (IOException ioe) {
+ // ignore
+ }
+ }
}
- if ((obj == null) || (obj.getValue() == null) || (obj.getValue().getProperties() == null)) {
+ if ((obj == null) || (obj.getProperties() == null)) {
return;
}
// add it to properties
- for (CmisProperty cmisProp : obj.getValue().getProperties().getProperty()) {
- PropertyData<?> prop = Converter.convert(cmisProp);
-
+ for (PropertyData<?> prop : obj.getProperties().getPropertyList()) {
// overwrite object info
if (prop instanceof PropertyString) {
String firstValueStr = ((PropertyString) prop).getFirstValue();