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/08/23 14:48:06 UTC
svn commit: r1516830 [3/3] - in /chemistry/opencmis/trunk:
chemistry-opencmis-server/chemistry-opencmis-server-archetype/src/main/resources/archetype-resources/src/main/webapp/
chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/...
Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareUserManager.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/FileShareUserManager.java?rev=1516830&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareUserManager.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareUserManager.java Fri Aug 23 12:48:06 2013
@@ -0,0 +1,100 @@
+/*
+ * 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.fileshare;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
+import org.apache.chemistry.opencmis.commons.server.CallContext;
+
+/**
+ * Manages users for the FileShare repository.
+ */
+public class FileShareUserManager {
+
+ private final Map<String, String> logins;
+
+ public FileShareUserManager() {
+ logins = new HashMap<String, String>();
+ }
+
+ /**
+ * Returns all logins.
+ */
+ public synchronized Collection<String> getLogins() {
+ return logins.keySet();
+ }
+
+ /**
+ * Adds a login.
+ */
+ public synchronized void addLogin(String username, String password) {
+ if (username == null || password == null) {
+ return;
+ }
+
+ logins.put(username.trim(), password);
+ }
+
+ /**
+ * Takes user and password from the CallContext and checks them.
+ */
+ public synchronized String authenticate(CallContext context) {
+ // try to get the remote user first
+ // HttpServletRequest request = (HttpServletRequest)
+ // context.get(CallContext.HTTP_SERVLET_REQUEST);
+ // if (request != null && request.getRemoteUser() != null) {
+ // return request.getRemoteUser();
+ // }
+
+ // check user and password
+ if (!authenticate(context.getUsername(), context.getPassword())) {
+ throw new CmisPermissionDeniedException("Invalid username or password.");
+ }
+
+ return context.getUsername();
+ }
+
+ /**
+ * Authenticates a user against the configured logins.
+ */
+ private synchronized boolean authenticate(String username, String password) {
+ String pwd = logins.get(username);
+ if (pwd == null) {
+ return false;
+ }
+
+ return pwd.equals(password);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+
+ for (String user : logins.keySet()) {
+ sb.append('[');
+ sb.append(user);
+ sb.append(']');
+ }
+
+ return sb.toString();
+ }
+}
Propchange: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareUserManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareUtils.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/FileShareUtils.java?rev=1516830&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareUtils.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareUtils.java Fri Aug 23 12:48:06 2013
@@ -0,0 +1,148 @@
+/*
+ * 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.fileshare;
+
+import java.util.GregorianCalendar;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.TimeZone;
+
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.data.Properties;
+import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.commons.data.PropertyDateTime;
+import org.apache.chemistry.opencmis.commons.data.PropertyId;
+import org.apache.chemistry.opencmis.commons.data.PropertyString;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+
+public final class FileShareUtils {
+
+ private FileShareUtils() {
+ }
+
+ /**
+ * Returns the boolean value of the given value or the default value if the
+ * given value is <code>null</code>.
+ */
+ public static boolean getBooleanParameter(Boolean value, boolean def) {
+ if (value == null) {
+ return def;
+ }
+
+ return value.booleanValue();
+ }
+
+ /**
+ * Converts milliseconds into a {@link GregorianCalendar} object, setting
+ * the timezone to GMT and cutting milliseconds off.
+ */
+ public static GregorianCalendar millisToCalendar(long millis) {
+ GregorianCalendar result = new GregorianCalendar();
+ result.setTimeZone(TimeZone.getTimeZone("GMT"));
+ result.setTimeInMillis((long) (Math.ceil((double) millis / 1000) * 1000));
+
+ return result;
+ }
+
+ /**
+ * Splits a filter statement into a collection of properties. If
+ * <code>filter</code> is <code>null</code>, empty or one of the properties
+ * is '*' , an empty collection will be returned.
+ */
+ public static Set<String> splitFilter(String filter) {
+ if (filter == null) {
+ return null;
+ }
+
+ if (filter.trim().length() == 0) {
+ return null;
+ }
+
+ Set<String> result = new HashSet<String>();
+ for (String s : filter.split(",")) {
+ s = s.trim();
+ if (s.equals("*")) {
+ return null;
+ } else if (s.length() > 0) {
+ result.add(s);
+ }
+ }
+
+ // set a few base properties
+ // query name == id (for base type properties)
+ result.add(PropertyIds.OBJECT_ID);
+ result.add(PropertyIds.OBJECT_TYPE_ID);
+ result.add(PropertyIds.BASE_TYPE_ID);
+
+ return result;
+ }
+
+ /**
+ * Gets the type id from a set of properties.
+ */
+ public static String getObjectTypeId(Properties properties) {
+ PropertyData<?> typeProperty = properties.getProperties().get(PropertyIds.OBJECT_TYPE_ID);
+ if (!(typeProperty instanceof PropertyId)) {
+ throw new CmisInvalidArgumentException("Type Id must be set!");
+ }
+
+ String typeId = ((PropertyId) typeProperty).getFirstValue();
+ if (typeId == null) {
+ throw new CmisInvalidArgumentException("Type Id must be set!");
+ }
+
+ return typeId;
+ }
+
+ /**
+ * Returns the first value of an id property.
+ */
+ public static String getIdProperty(Properties properties, String name) {
+ PropertyData<?> property = properties.getProperties().get(name);
+ if (!(property instanceof PropertyId)) {
+ return null;
+ }
+
+ return ((PropertyId) property).getFirstValue();
+ }
+
+ /**
+ * Returns the first value of a string property.
+ */
+ public static String getStringProperty(Properties properties, String name) {
+ PropertyData<?> property = properties.getProperties().get(name);
+ if (!(property instanceof PropertyString)) {
+ return null;
+ }
+
+ return ((PropertyString) property).getFirstValue();
+ }
+
+ /**
+ * Returns the first value of a datetime property.
+ */
+ public static GregorianCalendar getDateTimeProperty(Properties properties, String name) {
+ PropertyData<?> property = properties.getProperties().get(name);
+ if (!(property instanceof PropertyDateTime)) {
+ return null;
+ }
+
+ return ((PropertyDateTime) property).getFirstValue();
+ }
+}
Propchange: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/resources/log4j.properties
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/resources/log4j.properties?rev=1516830&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/resources/log4j.properties (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/resources/log4j.properties Fri Aug 23 12:48:06 2013
@@ -0,0 +1,39 @@
+# 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.
+
+
+# sample log4j.properties
+
+log4j.rootCategory=WARN, R, O
+
+# Stdout
+log4j.appender.O=org.apache.log4j.ConsoleAppender
+
+# File
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.File=log4j.log
+
+# Control the maximum log file size
+log4j.appender.R.MaxFileSize=100KB
+
+# Archive log files (one backup file here)
+log4j.appender.R.MaxBackupIndex=1
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.O.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c: %m%n
+log4j.appender.O.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c: %m%n
+
+log4j.logger.org.apache.chemistry.opencmis.fileshare=INFO
+# log4j.logger.org.apache.chemistry.opencmis.server.support.filter=INFO
\ No newline at end of file
Propchange: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/resources/log4j.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/webapp/WEB-INF/classes/repository.properties
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/webapp/WEB-INF/classes/repository.properties?rev=1516830&r1=1516829&r2=1516830&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/webapp/WEB-INF/classes/repository.properties (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/webapp/WEB-INF/classes/repository.properties Fri Aug 23 12:48:06 2013
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-class=org.apache.chemistry.opencmis.fileshare.FileShareServiceFactory
+class=org.apache.chemistry.opencmis.fileshare.FileShareCmisServiceFactory
login.1 = test:test
login.2 = cmisuser:password
Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/webapp/index.jsp?rev=1516830&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/webapp/index.jsp (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/webapp/index.jsp Fri Aug 23 12:48:06 2013
@@ -0,0 +1,107 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
+<%@ page import="org.apache.chemistry.opencmis.fileshare.*" %>
+<%@ page import="org.apache.chemistry.opencmis.commons.definitions.*" %>
+<%
+ FileShareCmisServiceFactory factory = (FileShareCmisServiceFactory) application.getAttribute("org.apache.chemistry.opencmis.servicesfactory");
+%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+ <link rel="stylesheet" type="text/css" href="css/opencmis.css">
+ <title>OpenCMIS FileShare Server</title>
+ <style type="text/css">
+ <!--
+ body {
+ font-family: Verdana, arial, sans-serif;
+ color: black;
+ font-size: 12px;
+ }
+
+ h1 {
+ font-size: 24px;
+ line-height: normal;
+ font-weight: bold;
+ background-color: #f0f0f0;
+ color: #003366;
+ border-bottom: 1px solid #3c78b5;
+ padding: 2px;
+ margin: 4px 0px 4px 0px;
+ }
+
+ h2 {
+ font-size: 18px;
+ line-height: normal;
+ font-weight: bold;
+ background-color: #f0f0f0;
+ border-bottom: 1px solid #3c78b5;
+ padding: 2px;
+ margin: 4px 0px 4px 0px;
+ }
+
+ hr {
+ color: 3c78b5;
+ height: 1;
+ }
+
+ td {
+ border: 1px solid #dddddd;
+ padding: 2px;
+ }
+ -->
+ </style>
+</head>
+<body>
+
+<h1>OpenCMIS FileShare Server</h1>
+
+<p style="font-weight: bold">The OpenCMIS FileShare server is up and running.</p>
+<p>You need a CMIS client to access this server. Download the <a href="http://chemistry.apache.org/java/developing/tools/dev-tools-workbench.html">CMIS Workbench</a>.</p>
+
+<h2>Access Information</h2>
+
+<h3>CMIS 1.1</h3>
+
+<p>Web Services Binding: <a href="services11/cmis?wsdl">WSDL</a></p>
+<p>AtomPub Binding: <a href="atom11">Service Document</a></p>
+<p>Browser Binding: <a href="browser">Service Document</a></p>
+
+<h3>CMIS 1.0</h3>
+
+<p>Web Services Binding: <a href="services/cmis?wsdl">WSDL</a></p>
+<p>AtomPub Binding: <a href="atom">Service Document</a></p>
+
+
+<h2>Configured Repositories</h2>
+
+<table>
+<tr><th>Repository Id</th><th>Root Directory</th></tr>
+<% for (FileShareRepository fsr: factory.getRepositoryManager().getRepositories()) { %>
+<tr><td><%= fsr.getRepositoryId() %></td><td><%= fsr.getRootDirectory() %></td></tr>
+<% } %>
+</table>
+
+
+<h2>Users</h2>
+
+<table>
+<tr><th>Login</th></tr>
+<% for (String login: factory.getUserManager().getLogins()) { %>
+<tr><td><%= login %></td></tr>
+<% } %>
+</table>
+
+
+<h2>Types</h2>
+
+<table>
+<tr><th>Type Id</th><th>Name</th><th>Base Type Id</th></tr>
+<% for (TypeDefinition type: factory.getTypeManager().getInternalTypeDefinitions()) { %>
+<tr><td><%= type.getId() %></td><td><%= type.getDisplayName() %></td><td><%= type.getBaseTypeId().value() %></td></tr>
+<% } %>
+</table>
+
+
+</body>
+</html>
\ No newline at end of file
Propchange: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/webapp/index.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeDefinitionFactory.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeDefinitionFactory.java?rev=1516830&r1=1516829&r2=1516830&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeDefinitionFactory.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeDefinitionFactory.java Fri Aug 23 12:48:06 2013
@@ -122,7 +122,7 @@ public final class TypeDefinitionFactory
itemTypeDefinitionClass = ItemTypeDefinitionImpl.class;
secondaryTypeDefinitionClass = SecondaryTypeDefinitionImpl.class;
- defaultNamespace = "http://defaultNamespace";
+ defaultNamespace = null;
defaultControllableAcl = false;
defaultControllablePolicy = false;
defaultQueryable = true;
@@ -627,6 +627,16 @@ public final class TypeDefinitionFactory
*/
public TypeDefinitionList createTypeDefinitionList(Map<String, TypeDefinition> allTypes, String typeId,
Boolean includePropertyDefinitions, BigInteger maxItems, BigInteger skipCount) {
+ return createTypeDefinitionList(allTypes, typeId, includePropertyDefinitions, maxItems, skipCount, null);
+ }
+
+ /**
+ * Creates a {@link TypeDefinitionList} for
+ * {@link RepositoryService#getTypeChildren(String, String, Boolean, BigInteger, BigInteger, ExtensionsData)}
+ * .
+ */
+ public TypeDefinitionList createTypeDefinitionList(Map<String, TypeDefinition> allTypes, String typeId,
+ Boolean includePropertyDefinitions, BigInteger maxItems, BigInteger skipCount, CmisVersion cmisVersion) {
if (typeId != null && !allTypes.containsKey(typeId)) {
throw new CmisObjectNotFoundException("Type '" + typeId + "' does not exist!");
}
@@ -659,11 +669,7 @@ public final class TypeDefinitionFactory
for (TypeDefinition typeDef : allTypes.values()) {
if ((typeId == null && typeDef.getParentTypeId() == null)
|| (typeId != null && typeId.equals(typeDef.getParentTypeId()))) {
- if (includePropertyDefinitionsBool) {
- targetList.add(typeDef);
- } else {
- targetList.add(copy(typeDef, false));
- }
+ targetList.add(copy(typeDef, includePropertyDefinitionsBool, cmisVersion));
}
}
@@ -706,6 +712,16 @@ public final class TypeDefinitionFactory
*/
public List<TypeDefinitionContainer> createTypeDescendants(Map<String, TypeDefinition> allTypes, String typeId,
BigInteger depth, Boolean includePropertyDefinitions) {
+ return createTypeDescendants(allTypes, typeId, depth, includePropertyDefinitions, null);
+ }
+
+ /**
+ * Creates a list of {@link TypeDefinitionContainer} for
+ * {@link RepositoryService#getTypeDescendants(String, String, BigInteger, Boolean, ExtensionsData)}
+ * .
+ */
+ public List<TypeDefinitionContainer> createTypeDescendants(Map<String, TypeDefinition> allTypes, String typeId,
+ BigInteger depth, Boolean includePropertyDefinitions, CmisVersion cmisVersion) {
int depthInt = (depth == null ? -1 : depth.intValue());
if (depthInt == 0) {
throw new CmisInvalidArgumentException("Depth must not be 0!");
@@ -722,6 +738,7 @@ public final class TypeDefinitionFactory
boolean includePropertyDefinitionsBool = (includePropertyDefinitions == null ? false
: includePropertyDefinitions.booleanValue());
+ // gather parent ids
Map<String, Set<String>> typeDefChildren = new HashMap<String, Set<String>>();
for (TypeDefinition typeDef : allTypes.values()) {
@@ -738,26 +755,29 @@ public final class TypeDefinitionFactory
return Collections.<TypeDefinitionContainer> emptyList();
}
+ // build container tree
List<TypeDefinitionContainer> result = new ArrayList<TypeDefinitionContainer>();
for (String child : children) {
result.add(createTypeDefinitionContainer(allTypes, typeDefChildren, child, depthInt - 1,
- includePropertyDefinitionsBool));
+ includePropertyDefinitionsBool, cmisVersion));
}
return result;
}
private TypeDefinitionContainer createTypeDefinitionContainer(Map<String, TypeDefinition> allTypes,
- Map<String, Set<String>> typeDefChildren, String typeId, int depth, boolean includePropertyDefinitions) {
+ Map<String, Set<String>> typeDefChildren, String typeId, int depth, boolean includePropertyDefinitions,
+ CmisVersion cmisVersion) {
TypeDefinitionContainerImpl result = new TypeDefinitionContainerImpl();
- result.setTypeDefinition(includePropertyDefinitions ? allTypes.get(typeId) : copy(allTypes.get(typeId), false));
+ result.setTypeDefinition(includePropertyDefinitions ? copy(allTypes.get(typeId), true, cmisVersion) : copy(
+ allTypes.get(typeId), false, cmisVersion));
if (depth != 0) {
if (typeDefChildren.containsKey(typeId)) {
for (String child : typeDefChildren.get(typeId)) {
result.getChildren().add(
createTypeDefinitionContainer(allTypes, typeDefChildren, child, depth < 0 ? -1 : depth - 1,
- includePropertyDefinitions));
+ includePropertyDefinitions, cmisVersion));
}
}
}
@@ -978,11 +998,14 @@ public final class TypeDefinitionFactory
*/
protected void copyPropertyDefinitions(TypeDefinition source, MutableTypeDefinition target,
CmisVersion cmisVersion, boolean markAsInherited) {
+ assert source != null;
+ assert target != null;
+
if (source != null && source.getPropertyDefinitions() != null) {
for (PropertyDefinition<?> propDef : source.getPropertyDefinitions().values()) {
if (cmisVersion == CmisVersion.CMIS_1_0) {
if (NEW_CMIS11_PROPERTIES.contains(propDef.getId())) {
- break;
+ continue;
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/TypeDefinitionFactoryTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/TypeDefinitionFactoryTest.java?rev=1516830&r1=1516829&r2=1516830&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/TypeDefinitionFactoryTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/TypeDefinitionFactoryTest.java Fri Aug 23 12:48:06 2013
@@ -64,6 +64,32 @@ public class TypeDefinitionFactoryTest {
}
@Test
+ public void testCopy11() {
+ TypeDefinitionFactory tdf = TypeDefinitionFactory.newInstance();
+ CmisVersion cmisVersion = CmisVersion.CMIS_1_1;
+
+ TypeDefinition docType1 = tdf.createBaseDocumentTypeDefinition(cmisVersion);
+ TypeDefinition docType2 = tdf.copy(docType1, false, cmisVersion);
+ TypeDefinition docType3 = tdf.copy(docType1, true, cmisVersion);
+
+ assertTrue(docType2.getPropertyDefinitions().isEmpty());
+ assertEquals(docType1.getPropertyDefinitions().size(), docType3.getPropertyDefinitions().size());
+ }
+
+ @Test
+ public void testCopy10() {
+ TypeDefinitionFactory tdf = TypeDefinitionFactory.newInstance();
+ CmisVersion cmisVersion = CmisVersion.CMIS_1_0;
+
+ TypeDefinition docType1 = tdf.createBaseDocumentTypeDefinition(cmisVersion);
+ TypeDefinition docType2 = tdf.copy(docType1, false, cmisVersion);
+ TypeDefinition docType3 = tdf.copy(docType1, true, cmisVersion);
+
+ assertTrue(docType2.getPropertyDefinitions().isEmpty());
+ assertEquals(docType1.getPropertyDefinitions().size(), docType3.getPropertyDefinitions().size());
+ }
+
+ @Test
public void testCreateTypeDefinitionList() {
TypeDefinitionFactory tdf = TypeDefinitionFactory.newInstance();
CmisVersion cmisVersion = CmisVersion.CMIS_1_1;
Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/BaseTypesTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/BaseTypesTest.java?rev=1516830&r1=1516829&r2=1516830&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/BaseTypesTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/BaseTypesTest.java Fri Aug 23 12:48:06 2013
@@ -71,7 +71,7 @@ public class BaseTypesTest extends Abstr
addResult(createResult(FAILURE, "Base type has an invalid id: " + typeId));
}
- if (typeDef.getPropertyDefinitions() != null) {
+ if (typeDef.getPropertyDefinitions() != null && typeDef.getPropertyDefinitions().size() > 0) {
addResult(createResult(WARNING, "Property type definitions were not requested but delivered. Type id: "
+ typeId));
}