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 2015/04/28 18:40:11 UTC
svn commit: r1676576 - in /chemistry/opencmis/trunk:
chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/
chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry...
Author: fmui
Date: Tue Apr 28 16:40:11 2015
New Revision: 1676576
URL: http://svn.apache.org/r1676576
Log:
more code clean up
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/SessionParameterMap.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/CmisBindingHelper.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceContext.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-browser/src/main/java/org/apache/chemistry/opencmis/browser/BrowseServlet.java
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/runner/WebRunnerServlet.java
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/mapper/PropertyMapperExif.java
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/specexamples/SpecExamples.java
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/fractal/FractalGenerator.java
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/loremipsum/LoremIpsum.java
chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java
chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ProxyDetector.java
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/SessionParameterMap.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/SessionParameterMap.java?rev=1676576&r1=1676575&r2=1676576&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/SessionParameterMap.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/SessionParameterMap.java Tue Apr 28 16:40:11 2015
@@ -703,7 +703,11 @@ public class SessionParameterMap extends
try {
load(stream);
} finally {
- stream.close();
+ try {
+ stream.close();
+ } finally {
+ // ignore
+ }
}
}
@@ -787,7 +791,11 @@ public class SessionParameterMap extends
try {
store(stream);
} finally {
- stream.close();
+ try {
+ stream.close();
+ } finally {
+ // ignore
+ }
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/CmisBindingHelper.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/CmisBindingHelper.java?rev=1676576&r1=1676575&r2=1676576&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/CmisBindingHelper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/CmisBindingHelper.java Tue Apr 28 16:40:11 2015
@@ -49,7 +49,12 @@ public final class CmisBindingHelper {
parameters.put(SessionParameter.BINDING_TYPE, BindingType.CUSTOM.value());
}
- BindingType bt = BindingType.fromValue(parameters.get(SessionParameter.BINDING_TYPE));
+ BindingType bt = null;
+ try {
+ bt = BindingType.fromValue(parameters.get(SessionParameter.BINDING_TYPE));
+ } catch (IllegalArgumentException iae) {
+ throw new CmisRuntimeException("Invalid binding type!");
+ }
switch (bt) {
case ATOMPUB:
@@ -63,7 +68,7 @@ public final class CmisBindingHelper {
case CUSTOM:
return createCustomBinding(parameters, authenticationProvider, typeDefCache);
default:
- throw new CmisRuntimeException("Ambiguous session parameter: " + parameters);
+ throw new CmisRuntimeException("Invalid binding type!");
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.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/AtomEntryParser.java?rev=1676576&r1=1676575&r2=1676576&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java Tue Apr 28 16:40:11 2015
@@ -55,12 +55,16 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.server.TempStoreOutputStream;
import org.apache.chemistry.opencmis.server.shared.CappedInputStream;
import org.apache.chemistry.opencmis.server.shared.TempStoreOutputStreamFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Parser for Atom Entries.
*/
public final class AtomEntryParser {
+ private static final Logger LOG = LoggerFactory.getLogger(AtomEntryParser.class);
+
private static final long MAX_STREAM_LENGTH = 10 * 1024 * 1024;
private static final String TAG_ENTRY = "entry";
@@ -229,7 +233,13 @@ public final class AtomEntryParser {
release();
throw re;
} finally {
- parser.close();
+ try {
+ parser.close();
+ } catch (XMLStreamException xse) {
+ if (LOG.isWarnEnabled()) {
+ LOG.warn("Parser couldn't be closed: {}", xse.toString(), xse);
+ }
+ }
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.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/CmisAtomPubServlet.java?rev=1676576&r1=1676575&r2=1676576&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java Tue Apr 28 16:40:11 2015
@@ -207,7 +207,11 @@ public class CmisAtomPubServlet extends
}
} finally {
// we are done.
- response.flushBuffer();
+ try {
+ response.flushBuffer();
+ } catch (IOException ioe) {
+ LOG.error("Could not flush resposne: {}", ioe.toString(), ioe);
+ }
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.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/ObjectService.java?rev=1676576&r1=1676575&r2=1676576&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java Tue Apr 28 16:40:11 2015
@@ -659,7 +659,7 @@ public class ObjectService {
IOUtils.copy(in, out, BUFFER_SIZE);
out.flush();
} finally {
- in.close();
+ IOUtils.closeQuietly(in);
}
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.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/browser/CmisBrowserBindingServlet.java?rev=1676576&r1=1676575&r2=1676576&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java Tue Apr 28 16:40:11 2015
@@ -276,7 +276,11 @@ public class CmisBrowserBindingServlet e
}
// we are done.
- response.flushBuffer();
+ try {
+ response.flushBuffer();
+ } catch (IOException ioe) {
+ LOG.error("Could not flush resposne: {}", ioe.toString(), ioe);
+ }
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.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/browser/ObjectService.java?rev=1676576&r1=1676575&r2=1676576&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java Tue Apr 28 16:40:11 2015
@@ -801,7 +801,7 @@ public class ObjectService {
IOUtils.copy(in, out, BUFFER_SIZE);
out.flush();
} finally {
- in.close();
+ IOUtils.closeQuietly(in);
}
}
}
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=1676576&r1=1676575&r2=1676576&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 Tue Apr 28 16:40:11 2015
@@ -723,7 +723,9 @@ public class FileShareRepository {
File propFile = getPropertiesFile(file);
if (propFile.exists()) {
File newPropFile = new File(parent, propFile.getName());
- propFile.renameTo(newPropFile);
+ if (!propFile.renameTo(newPropFile)) {
+ LOG.error("Could not rename properties file: {}", propFile.getName());
+ }
}
}
}
@@ -927,7 +929,9 @@ public class FileShareRepository {
if (newFile.isFile()) {
if (propFile.exists()) {
File newPropFile = new File(parent, newName + SHADOW_EXT);
- propFile.renameTo(newPropFile);
+ if (!propFile.renameTo(newPropFile)) {
+ LOG.error("Could not rename properties file: {}", propFile.getName());
+ }
}
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java?rev=1676576&r1=1676575&r2=1676576&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java Tue Apr 28 16:40:11 2015
@@ -206,239 +206,218 @@ public class BaseServiceValidatorImpl im
}
protected void checkCreatablePropertyTypes(String repositoryId,
- Collection<PropertyDefinition<?>> propertyDefinitions )
- {
+ Collection<PropertyDefinition<?>> propertyDefinitions) {
RepositoryInfo repositoryInfo = fStoreManager.getRepositoryInfo(repositoryId);
RepositoryCapabilities repositoryCapabilities = repositoryInfo.getCapabilities();
CreatablePropertyTypes creatablePropertyTypes = repositoryCapabilities.getCreatablePropertyTypes();
-
+
Set<PropertyType> creatablePropertyTypeSet = creatablePropertyTypes.canCreate();
- for (PropertyDefinition<?> propertyDefinition : propertyDefinitions)
- {
+ for (PropertyDefinition<?> propertyDefinition : propertyDefinitions) {
if (!creatablePropertyTypeSet.contains(propertyDefinition.getPropertyType()))
- throw new CmisConstraintException("propertyDefinition " + propertyDefinition.getId() +
- "is of not creatable type " + propertyDefinition.getPropertyType());
-
+ throw new CmisConstraintException("propertyDefinition " + propertyDefinition.getId()
+ + "is of not creatable type " + propertyDefinition.getPropertyType());
+
// mandatory properties must have a default value
- if (propertyDefinition.isRequired() &&
- (propertyDefinition.getDefaultValue() == null))
- {
- throw new CmisConstraintException("property: " + propertyDefinition.getId() +
- "required properties must have a default value");
+ if (propertyDefinition.isRequired() && (propertyDefinition.getDefaultValue() == null)) {
+ throw new CmisConstraintException("property: " + propertyDefinition.getId()
+ + "required properties must have a default value");
}
}
}
-
+
protected void checkSettableAttributes(String repositoryId, TypeDefinition oldTypeDefinition,
- TypeDefinition newTypeDefinition )
- {
+ TypeDefinition newTypeDefinition) {
RepositoryInfo repositoryInfo = fStoreManager.getRepositoryInfo(repositoryId);
RepositoryCapabilities repositoryCapabilities = repositoryInfo.getCapabilities();
NewTypeSettableAttributes newTypeSettableAttributes = repositoryCapabilities.getNewTypeSettableAttributes();
-
+
if (null == newTypeSettableAttributes)
return; // no restrictions defined
- if (newTypeSettableAttributes.canSetControllableAcl() &&
- newTypeSettableAttributes.canSetControllablePolicy() &&
- newTypeSettableAttributes.canSetCreatable() &&
- newTypeSettableAttributes.canSetDescription() &&
- newTypeSettableAttributes.canSetDisplayName() &&
- newTypeSettableAttributes.canSetFileable() &&
- newTypeSettableAttributes.canSetFulltextIndexed() &&
- newTypeSettableAttributes.canSetId() &&
- newTypeSettableAttributes.canSetIncludedInSupertypeQuery() &&
- newTypeSettableAttributes.canSetLocalName() &&
- newTypeSettableAttributes.canSetLocalNamespace() &&
- newTypeSettableAttributes.canSetQueryable() &&
- newTypeSettableAttributes.canSetQueryName())
- return; // all is allowed
- if (!newTypeSettableAttributes.canSetControllableAcl() &&
- oldTypeDefinition.isControllableAcl() != newTypeDefinition.isControllableAcl())
- throw new CmisConstraintException("controllableAcl is not settable in repository " + repositoryId + ", but " +
- oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in controllableAcl");
- if (!newTypeSettableAttributes.canSetControllablePolicy() &&
- oldTypeDefinition.isControllablePolicy() != newTypeDefinition.isControllablePolicy())
- throw new CmisConstraintException("controllablePolicy is not settable in repository " + repositoryId + ", but " +
- oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in controllablePolicy");
- if (!newTypeSettableAttributes.canSetCreatable() &&
- oldTypeDefinition.isCreatable() != newTypeDefinition.isCreatable())
- throw new CmisConstraintException("isCreatable is not settable in repository " + repositoryId + ", but " +
- oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in isCreatable");
- if (!newTypeSettableAttributes.canSetDescription() &&
- oldTypeDefinition.getDescription() != newTypeDefinition.getDescription())
- throw new CmisConstraintException("description is not settable in repository " + repositoryId + ", but " +
- oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in their description");
- if (!newTypeSettableAttributes.canSetDisplayName() &&
- oldTypeDefinition.getDisplayName() != newTypeDefinition.getDisplayName())
- throw new CmisConstraintException("displayName is not settable in repository " + repositoryId + ", but " +
- oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in their displayName");
- if (!newTypeSettableAttributes.canSetFileable() &&
- oldTypeDefinition.isFileable() != newTypeDefinition.isFileable())
- throw new CmisConstraintException("fileable is not settable in repository " + repositoryId + ", but " +
- oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in isFileable");
- if (!newTypeSettableAttributes.canSetFulltextIndexed() &&
- oldTypeDefinition.isFulltextIndexed() != newTypeDefinition.isFulltextIndexed())
- throw new CmisConstraintException("fulltextIndexed is not settable in repository " + repositoryId + ", but " +
- oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in isFulltextIndexed");
- // TODO how can the ids differ?
- if (!newTypeSettableAttributes.canSetId() &&
- oldTypeDefinition.getId() != newTypeDefinition.getId())
- throw new CmisConstraintException("id is not settable in repository " + repositoryId + ", but " +
- oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in their id");
- if (!newTypeSettableAttributes.canSetIncludedInSupertypeQuery() &&
- oldTypeDefinition.isIncludedInSupertypeQuery() != newTypeDefinition.isIncludedInSupertypeQuery())
- throw new CmisConstraintException("includedInSupertypeQuery is not settable in repository " + repositoryId + ", but " +
- oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in their isIncludedInSupertypeQuery");
- if (!newTypeSettableAttributes.canSetLocalName() &&
- oldTypeDefinition.getLocalName() != newTypeDefinition.getLocalName())
- throw new CmisConstraintException("localName is not settable in repository " + repositoryId + ", but " +
- oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in their localName");
- if (!newTypeSettableAttributes.canSetLocalNamespace() &&
- oldTypeDefinition.getLocalNamespace() != newTypeDefinition.getLocalNamespace())
- throw new CmisConstraintException("localNamespace is not settable in repository " + repositoryId + ", but " +
- oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in their localNamespace");
- if (!newTypeSettableAttributes.canSetQueryable() &&
- oldTypeDefinition.isQueryable() != newTypeDefinition.isQueryable())
- throw new CmisConstraintException("queryable is not settable in repository " + repositoryId + ", but " +
- oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in their isQueryable");
- if (!newTypeSettableAttributes.canSetQueryName() &&
- oldTypeDefinition.getQueryName() != newTypeDefinition.getQueryName())
- throw new CmisConstraintException("queryName is not settable in repository " + repositoryId + ", but " +
- oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in their queryName");
- }
-
- protected void checkUpdatePropertyDefinitions(Map<String,PropertyDefinition<?>> oldPropertyDefinitions,
- Map<String,PropertyDefinition<?>> newPropertyDefinitions)
- {
- for(PropertyDefinition<?> newPropertyDefinition : newPropertyDefinitions.values())
- {
+ if (newTypeSettableAttributes.canSetControllableAcl() && newTypeSettableAttributes.canSetControllablePolicy()
+ && newTypeSettableAttributes.canSetCreatable() && newTypeSettableAttributes.canSetDescription()
+ && newTypeSettableAttributes.canSetDisplayName() && newTypeSettableAttributes.canSetFileable()
+ && newTypeSettableAttributes.canSetFulltextIndexed() && newTypeSettableAttributes.canSetId()
+ && newTypeSettableAttributes.canSetIncludedInSupertypeQuery()
+ && newTypeSettableAttributes.canSetLocalName() && newTypeSettableAttributes.canSetLocalNamespace()
+ && newTypeSettableAttributes.canSetQueryable() && newTypeSettableAttributes.canSetQueryName())
+ return; // all is allowed
+ if (!newTypeSettableAttributes.canSetControllableAcl()
+ && oldTypeDefinition.isControllableAcl() != newTypeDefinition.isControllableAcl())
+ throw new CmisConstraintException("controllableAcl is not settable in repository " + repositoryId
+ + ", but " + oldTypeDefinition.getId() + " and " + newTypeDefinition.getId()
+ + " differ in controllableAcl");
+ if (!newTypeSettableAttributes.canSetControllablePolicy()
+ && oldTypeDefinition.isControllablePolicy() != newTypeDefinition.isControllablePolicy())
+ throw new CmisConstraintException("controllablePolicy is not settable in repository " + repositoryId
+ + ", but " + oldTypeDefinition.getId() + " and " + newTypeDefinition.getId()
+ + " differ in controllablePolicy");
+ if (!newTypeSettableAttributes.canSetCreatable()
+ && oldTypeDefinition.isCreatable() != newTypeDefinition.isCreatable())
+ throw new CmisConstraintException("isCreatable is not settable in repository " + repositoryId + ", but "
+ + oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in isCreatable");
+ if (!newTypeSettableAttributes.canSetDescription()
+ && !oldTypeDefinition.getDescription().equals(newTypeDefinition.getDescription()))
+ throw new CmisConstraintException("description is not settable in repository " + repositoryId + ", but "
+ + oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in their description");
+ if (!newTypeSettableAttributes.canSetDisplayName()
+ && !oldTypeDefinition.getDisplayName().equals(newTypeDefinition.getDisplayName()))
+ throw new CmisConstraintException("displayName is not settable in repository " + repositoryId + ", but "
+ + oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in their displayName");
+ if (!newTypeSettableAttributes.canSetFileable()
+ && oldTypeDefinition.isFileable() != newTypeDefinition.isFileable())
+ throw new CmisConstraintException("fileable is not settable in repository " + repositoryId + ", but "
+ + oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in isFileable");
+ if (!newTypeSettableAttributes.canSetFulltextIndexed()
+ && oldTypeDefinition.isFulltextIndexed() != newTypeDefinition.isFulltextIndexed())
+ throw new CmisConstraintException("fulltextIndexed is not settable in repository " + repositoryId
+ + ", but " + oldTypeDefinition.getId() + " and " + newTypeDefinition.getId()
+ + " differ in isFulltextIndexed");
+ // TODO how can the ids differ?
+ if (!newTypeSettableAttributes.canSetId() && oldTypeDefinition.getId() != newTypeDefinition.getId())
+ throw new CmisConstraintException("id is not settable in repository " + repositoryId + ", but "
+ + oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in their id");
+ if (!newTypeSettableAttributes.canSetIncludedInSupertypeQuery()
+ && oldTypeDefinition.isIncludedInSupertypeQuery() != newTypeDefinition.isIncludedInSupertypeQuery())
+ throw new CmisConstraintException("includedInSupertypeQuery is not settable in repository " + repositoryId
+ + ", but " + oldTypeDefinition.getId() + " and " + newTypeDefinition.getId()
+ + " differ in their isIncludedInSupertypeQuery");
+ if (!newTypeSettableAttributes.canSetLocalName()
+ && !oldTypeDefinition.getLocalName().equals(newTypeDefinition.getLocalName()))
+ throw new CmisConstraintException("localName is not settable in repository " + repositoryId + ", but "
+ + oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in their localName");
+ if (!newTypeSettableAttributes.canSetLocalNamespace()
+ && !oldTypeDefinition.getLocalNamespace().equals(newTypeDefinition.getLocalNamespace()))
+ throw new CmisConstraintException("localNamespace is not settable in repository " + repositoryId + ", but "
+ + oldTypeDefinition.getId() + " and " + newTypeDefinition.getId()
+ + " differ in their localNamespace");
+ if (!newTypeSettableAttributes.canSetQueryable()
+ && oldTypeDefinition.isQueryable() != newTypeDefinition.isQueryable())
+ throw new CmisConstraintException("queryable is not settable in repository " + repositoryId + ", but "
+ + oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in their isQueryable");
+ if (!newTypeSettableAttributes.canSetQueryName()
+ && !oldTypeDefinition.getQueryName().equals(newTypeDefinition.getQueryName()))
+ throw new CmisConstraintException("queryName is not settable in repository " + repositoryId + ", but "
+ + oldTypeDefinition.getId() + " and " + newTypeDefinition.getId() + " differ in their queryName");
+ }
+
+ protected void checkUpdatePropertyDefinitions(Map<String, PropertyDefinition<?>> oldPropertyDefinitions,
+ Map<String, PropertyDefinition<?>> newPropertyDefinitions) {
+ for (PropertyDefinition<?> newPropertyDefinition : newPropertyDefinitions.values()) {
PropertyDefinition<?> oldPropertyDefinition = oldPropertyDefinitions.get(newPropertyDefinition.getId());
-
+
if (oldPropertyDefinition.isInherited())
- throw new CmisConstraintException("property: " + oldPropertyDefinition.getId() +
- " update of inherited properties is not allowed");
+ throw new CmisConstraintException("property: " + oldPropertyDefinition.getId()
+ + " update of inherited properties is not allowed");
if (!(oldPropertyDefinition.isRequired()) && newPropertyDefinition.isRequired())
- throw new CmisConstraintException("property: " + oldPropertyDefinition.getId() +
- " optional properties must not be changed to required");
+ throw new CmisConstraintException("property: " + oldPropertyDefinition.getId()
+ + " optional properties must not be changed to required");
if (oldPropertyDefinition.getPropertyType() != newPropertyDefinition.getPropertyType())
- throw new CmisConstraintException("property: " + oldPropertyDefinition.getId() +
- " cannot update the propertyType (" + oldPropertyDefinition.getPropertyType() + ")");
+ throw new CmisConstraintException("property: " + oldPropertyDefinition.getId()
+ + " cannot update the propertyType (" + oldPropertyDefinition.getPropertyType() + ")");
if (oldPropertyDefinition.getCardinality() != newPropertyDefinition.getCardinality())
- throw new CmisConstraintException("property: " + oldPropertyDefinition.getId() +
- " cannot update the cardinality (" + oldPropertyDefinition.getCardinality() + ")");
-
- if (oldPropertyDefinition.isOpenChoice() && !newPropertyDefinition.isOpenChoice() )
- throw new CmisConstraintException("property: " + oldPropertyDefinition.getId() +
- " open choice cannot change from true to false");
-
+ throw new CmisConstraintException("property: " + oldPropertyDefinition.getId()
+ + " cannot update the cardinality (" + oldPropertyDefinition.getCardinality() + ")");
+
+ if (oldPropertyDefinition.isOpenChoice() && !newPropertyDefinition.isOpenChoice())
+ throw new CmisConstraintException("property: " + oldPropertyDefinition.getId()
+ + " open choice cannot change from true to false");
+
// check choices
- if (!oldPropertyDefinition.isOpenChoice())
- {
+ if (!oldPropertyDefinition.isOpenChoice()) {
List<?> oldChoices = oldPropertyDefinition.getChoices();
if (null == oldChoices)
- throw new CmisConstraintException("property: " + oldPropertyDefinition.getId() +
- " there should be any choices when it's no open choice");
+ throw new CmisConstraintException("property: " + oldPropertyDefinition.getId()
+ + " there should be any choices when it's no open choice");
List<?> newChoices = newPropertyDefinition.getChoices();
if (null == newChoices)
- throw new CmisConstraintException("property: " + newPropertyDefinition.getId() +
- " there should be any choices when it's no open choice");
+ throw new CmisConstraintException("property: " + newPropertyDefinition.getId()
+ + " there should be any choices when it's no open choice");
ListIterator<?> newChoicesIterator = newChoices.listIterator();
- for (Object oldChoiceObject : oldChoices)
- {
+ for (Object oldChoiceObject : oldChoices) {
Object newChoiceObject = newChoicesIterator.next();
if (!(oldChoiceObject instanceof Choice))
- throw new CmisConstraintException("property: " + newPropertyDefinition.getId() +
- " old choice object is not of class Choice: " + oldChoiceObject.toString());
+ throw new CmisConstraintException("property: " + newPropertyDefinition.getId()
+ + " old choice object is not of class Choice: " + oldChoiceObject.toString());
if (!(newChoiceObject instanceof Choice))
- throw new CmisConstraintException("property: " + newPropertyDefinition.getId() +
- " new choice object is not of class Choice: " + newChoiceObject.toString());
+ throw new CmisConstraintException("property: " + newPropertyDefinition.getId()
+ + " new choice object is not of class Choice: " + newChoiceObject.toString());
Choice<?> oldChoice = (Choice<?>) oldChoiceObject;
Choice<?> newChoice = (Choice<?>) newChoiceObject;
List<?> oldValues = oldChoice.getValue();
List<?> newValues = newChoice.getValue();
- for (Object oldValue : oldValues)
- {
- if (! newValues.contains(oldValue))
- throw new CmisConstraintException("property: " + newPropertyDefinition.getId() +
- " value: " + oldValue.toString() + " is not in new values of the new choice");
- }
- }
+ for (Object oldValue : oldValues) {
+ if (!newValues.contains(oldValue))
+ throw new CmisConstraintException("property: " + newPropertyDefinition.getId() + " value: "
+ + oldValue.toString() + " is not in new values of the new choice");
+ }
+ }
}
-
+
// check restrictions
- if (oldPropertyDefinition instanceof PropertyDecimalDefinition)
- {
+ if (oldPropertyDefinition instanceof PropertyDecimalDefinition) {
PropertyDecimalDefinition oldPropertyDecimalDefinition = (PropertyDecimalDefinition) oldPropertyDefinition;
PropertyDecimalDefinition newPropertyDecimalDefinition = (PropertyDecimalDefinition) newPropertyDefinition;
-
+
BigDecimal oldMinValue = oldPropertyDecimalDefinition.getMinValue();
BigDecimal newMinValue = newPropertyDecimalDefinition.getMinValue();
- if (null != newMinValue &&
- (oldMinValue == null || (newMinValue.compareTo( oldMinValue) > 0)))
- throw new CmisConstraintException("property: " + oldPropertyDefinition.getId() +
- " minValue " + oldMinValue + " cannot be further restricted to " + newMinValue);
-
+ if (null != newMinValue && (oldMinValue == null || (newMinValue.compareTo(oldMinValue) > 0)))
+ throw new CmisConstraintException("property: " + oldPropertyDefinition.getId() + " minValue "
+ + oldMinValue + " cannot be further restricted to " + newMinValue);
+
BigDecimal oldMaxValue = oldPropertyDecimalDefinition.getMaxValue();
BigDecimal newMaxValue = newPropertyDecimalDefinition.getMaxValue();
- if (null != newMaxValue &&
- (oldMaxValue == null || (newMaxValue.compareTo( oldMaxValue) < 0)))
- throw new CmisConstraintException("property: " + oldPropertyDefinition.getId() +
- " maxValue " + oldMaxValue + " cannot be further restricted to " + newMaxValue);
+ if (null != newMaxValue && (oldMaxValue == null || (newMaxValue.compareTo(oldMaxValue) < 0)))
+ throw new CmisConstraintException("property: " + oldPropertyDefinition.getId() + " maxValue "
+ + oldMaxValue + " cannot be further restricted to " + newMaxValue);
}
- if (oldPropertyDefinition instanceof PropertyIntegerDefinition)
- {
+ if (oldPropertyDefinition instanceof PropertyIntegerDefinition) {
PropertyIntegerDefinition oldPropertyIntegerDefinition = (PropertyIntegerDefinition) oldPropertyDefinition;
PropertyIntegerDefinition newPropertyIntegerDefinition = (PropertyIntegerDefinition) newPropertyDefinition;
-
+
BigInteger oldMinValue = oldPropertyIntegerDefinition.getMinValue();
BigInteger newMinValue = newPropertyIntegerDefinition.getMinValue();
- if (null != newMinValue &&
- (oldMinValue == null || (newMinValue.compareTo( oldMinValue) > 0)))
- throw new CmisConstraintException("property: " + oldPropertyDefinition.getId() +
- " minValue " + oldMinValue + " cannot be further restricted to " + newMinValue);
-
+ if (null != newMinValue && (oldMinValue == null || (newMinValue.compareTo(oldMinValue) > 0)))
+ throw new CmisConstraintException("property: " + oldPropertyDefinition.getId() + " minValue "
+ + oldMinValue + " cannot be further restricted to " + newMinValue);
+
BigInteger oldMaxValue = oldPropertyIntegerDefinition.getMaxValue();
BigInteger newMaxValue = newPropertyIntegerDefinition.getMaxValue();
- if (null != newMaxValue &&
- (oldMaxValue == null || (newMaxValue.compareTo( oldMaxValue) < 0)))
- throw new CmisConstraintException("property: " + oldPropertyDefinition.getId() +
- " maxValue " + oldMaxValue + " cannot be further restricted to " + newMaxValue);
+ if (null != newMaxValue && (oldMaxValue == null || (newMaxValue.compareTo(oldMaxValue) < 0)))
+ throw new CmisConstraintException("property: " + oldPropertyDefinition.getId() + " maxValue "
+ + oldMaxValue + " cannot be further restricted to " + newMaxValue);
}
- if (oldPropertyDefinition instanceof PropertyStringDefinition)
- {
+ if (oldPropertyDefinition instanceof PropertyStringDefinition) {
PropertyStringDefinition oldPropertyStringDefinition = (PropertyStringDefinition) oldPropertyDefinition;
PropertyStringDefinition newPropertyStringDefinition = (PropertyStringDefinition) newPropertyDefinition;
-
+
BigInteger oldMaxValue = oldPropertyStringDefinition.getMaxLength();
BigInteger newMaxValue = newPropertyStringDefinition.getMaxLength();
- if (null != newMaxValue &&
- (oldMaxValue == null || (newMaxValue.compareTo( oldMaxValue) < 0)))
- throw new CmisConstraintException("property: " + oldPropertyDefinition.getId() +
- " maxValue " + oldMaxValue + " cannot be further restricted to " + newMaxValue);
+ if (null != newMaxValue && (oldMaxValue == null || (newMaxValue.compareTo(oldMaxValue) < 0)))
+ throw new CmisConstraintException("property: " + oldPropertyDefinition.getId() + " maxValue "
+ + oldMaxValue + " cannot be further restricted to " + newMaxValue);
}
}
-
+
// check for removed properties
- for(PropertyDefinition<?> oldPropertyDefinition : oldPropertyDefinitions.values())
- {
+ for (PropertyDefinition<?> oldPropertyDefinition : oldPropertyDefinitions.values()) {
PropertyDefinition<?> newPropertyDefinition = newPropertyDefinitions.get(oldPropertyDefinition.getId());
- if (null == newPropertyDefinition)
- {
- throw new CmisConstraintException("property: " + oldPropertyDefinition.getId() +
- " cannot remove that property");
+ if (null == newPropertyDefinition) {
+ throw new CmisConstraintException("property: " + oldPropertyDefinition.getId()
+ + " cannot remove that property");
}
}
}
-
- protected void checkUpdateType (TypeDefinition updateType, TypeDefinition type)
- {
- if (updateType.getId() != type.getId())
- throw new CmisConstraintException("type to update must be of the same id: " + updateType.getId() + ", " + type.getId());
+
+ protected void checkUpdateType(TypeDefinition updateType, TypeDefinition type) {
+ if (!updateType.getId().equals(type.getId()))
+ throw new CmisConstraintException("type to update must be of the same id: " + updateType.getId() + ", "
+ + type.getId());
if (updateType.getBaseTypeId() != type.getBaseTypeId())
- throw new CmisConstraintException("base type to update must be the same: " + updateType.getBaseTypeId() + ", " + type.getBaseTypeId());
- // anything else should be ignored
+ throw new CmisConstraintException("base type to update must be the same: " + updateType.getBaseTypeId()
+ + ", " + type.getBaseTypeId());
+ // anything else should be ignored
}
-
+
protected TypeDefinition checkExistingTypeId(String repositoryId, String typeId) {
if (null == typeId) {
@@ -453,13 +432,12 @@ public class BaseServiceValidatorImpl im
return tdc.getTypeDefinition();
}
-
- protected void checkBasicType(TypeDefinition type)
- {
- if (type.getId() == type.getBaseTypeId().value())
- throw new CmisInvalidArgumentException("type " + type.getId() + " is a basic type, basic types are read-only");
+ protected void checkBasicType(TypeDefinition type) {
+ if (type.getId().equals(type.getBaseTypeId().value()))
+ throw new CmisInvalidArgumentException("type " + type.getId()
+ + " is a basic type, basic types are read-only");
}
-
+
@Override
public void getRepositoryInfos(CallContext context, ExtensionsData extension) {
}
@@ -489,8 +467,7 @@ public class BaseServiceValidatorImpl im
}
@Override
- public StoredObject getChildren(CallContext context, String repositoryId, String folderId,
- ExtensionsData extension) {
+ public StoredObject getChildren(CallContext context, String repositoryId, String folderId, ExtensionsData extension) {
return checkStandardParameters(repositoryId, folderId);
}
@@ -606,8 +583,7 @@ public class BaseServiceValidatorImpl im
}
@Override
- public StoredObject getObjectByPath(CallContext context, String repositoryId, String path,
- ExtensionsData extension) {
+ public StoredObject getObjectByPath(CallContext context, String repositoryId, String path, ExtensionsData extension) {
return checkStandardParametersByPath(repositoryId, path, context.getUsername());
}
@@ -824,7 +800,7 @@ public class BaseServiceValidatorImpl im
return checkStandardParameters(repositoryId, objectId);
}
-
+
@Override
public void createType(CallContext callContext, String repositoryId, TypeDefinition type, ExtensionsData extension) {
checkRepositoryId(repositoryId);
@@ -846,10 +822,10 @@ public class BaseServiceValidatorImpl im
}
@Override
- public TypeDefinition updateType(CallContext callContext,
- String repositoryId, TypeDefinition type, ExtensionsData extension) {
+ public TypeDefinition updateType(CallContext callContext, String repositoryId, TypeDefinition type,
+ ExtensionsData extension) {
checkRepositoryId(repositoryId);
-
+
TypeDefinition updateType = checkExistingTypeId(repositoryId, type.getId());
checkUpdateType(updateType, type);
checkBasicType(type);
@@ -858,17 +834,17 @@ public class BaseServiceValidatorImpl im
throw new CmisConstraintException("type: " + type.getId() + " does not allow mutability update");
}
checkCreatablePropertyTypes(repositoryId, type.getPropertyDefinitions().values());
- checkSettableAttributes(repositoryId, updateType, type );
+ checkSettableAttributes(repositoryId, updateType, type);
checkUpdatePropertyDefinitions(updateType.getPropertyDefinitions(), type.getPropertyDefinitions());
return updateType;
}
@Override
- public TypeDefinition deleteType(CallContext callContext, String repositoryId,
- String typeId, ExtensionsData extension) {
+ public TypeDefinition deleteType(CallContext callContext, String repositoryId, String typeId,
+ ExtensionsData extension) {
checkRepositoryId(repositoryId);
-
- TypeDefinition deleteType = checkExistingTypeId(repositoryId, typeId);
+
+ TypeDefinition deleteType = checkExistingTypeId(repositoryId, typeId);
checkBasicType(deleteType);
// check if type can be deleted
if (!(deleteType.getTypeMutability().canDelete())) {
@@ -876,5 +852,5 @@ public class BaseServiceValidatorImpl im
}
return deleteType;
}
-
+
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceContext.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceContext.java?rev=1676576&r1=1676575&r2=1676576&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceContext.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceContext.java Tue Apr 28 16:40:11 2015
@@ -19,7 +19,7 @@
package org.apache.chemistry.opencmis.inmemory.server;
import org.apache.chemistry.opencmis.commons.server.CallContext;
-import org.apache.chemistry.opencmis.server.support.CmisServiceWrapper;
+import org.apache.chemistry.opencmis.server.support.wrapper.ConformanceCmisServiceWrapper;
/**
* Helper class to associate context information with each incoming call.
@@ -28,14 +28,14 @@ import org.apache.chemistry.opencmis.ser
public final class InMemoryServiceContext {
private static final class ContextHolder {
- private CmisServiceWrapper<InMemoryService> wrapper;
+ private ConformanceCmisServiceWrapper wrapper;
private CallContext callContext;
- private ContextHolder(CmisServiceWrapper<InMemoryService> wrapper) {
+ private ContextHolder(ConformanceCmisServiceWrapper wrapper) {
this.wrapper = wrapper;
}
- public CmisServiceWrapper<InMemoryService> getServiceWrapper() {
+ public ConformanceCmisServiceWrapper getServiceWrapper() {
return wrapper;
}
@@ -53,7 +53,7 @@ public final class InMemoryServiceContex
private InMemoryServiceContext() {
}
- public static synchronized void setWrapperService(CmisServiceWrapper<InMemoryService> wrapperService) {
+ public static synchronized void setWrapperService(ConformanceCmisServiceWrapper wrapperService) {
threadLocalService.remove();
if (null != wrapperService) {
ContextHolder holder = new ContextHolder(wrapperService);
@@ -66,8 +66,8 @@ public final class InMemoryServiceContex
if (null == holder) {
return null;
} else {
- CmisServiceWrapper<InMemoryService> wrapperService = holder.getServiceWrapper();
- return wrapperService == null ? null : wrapperService.getWrappedService();
+ ConformanceCmisServiceWrapper wrapperService = holder.getServiceWrapper();
+ return wrapperService == null ? null : (InMemoryService) wrapperService.getWrappedService();
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java?rev=1676576&r1=1676575&r2=1676576&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java Tue Apr 28 16:40:11 2015
@@ -61,8 +61,8 @@ import org.apache.chemistry.opencmis.inm
import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
import org.apache.chemistry.opencmis.inmemory.storedobj.impl.StoreManagerFactory;
import org.apache.chemistry.opencmis.inmemory.storedobj.impl.StoreManagerImpl;
-import org.apache.chemistry.opencmis.server.support.CmisServiceWrapper;
import org.apache.chemistry.opencmis.server.support.TypeManager;
+import org.apache.chemistry.opencmis.server.support.wrapper.ConformanceCmisServiceWrapper;
import org.apache.chemistry.opencmis.util.repository.ObjectGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -158,9 +158,9 @@ public class InMemoryServiceFactoryImpl
InMemoryService inMemoryService = InMemoryServiceContext.getCmisService();
if (inMemoryService == null) {
LOG.debug("Creating new InMemoryService instance!");
- CmisServiceWrapper<InMemoryService> wrapperService;
+ ConformanceCmisServiceWrapper wrapperService;
inMemoryService = new InMemoryService(storeManager);
- wrapperService = new CmisServiceWrapper<InMemoryService>(inMemoryService, DEFAULT_MAX_ITEMS_TYPES,
+ wrapperService = new ConformanceCmisServiceWrapper(inMemoryService, DEFAULT_MAX_ITEMS_TYPES,
DEFAULT_DEPTH_TYPES, DEFAULT_MAX_ITEMS_OBJECTS, DEFAULT_DEPTH_OBJECTS);
InMemoryServiceContext.setWrapperService(wrapperService);
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java?rev=1676576&r1=1676575&r2=1676576&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java Tue Apr 28 16:40:11 2015
@@ -134,18 +134,14 @@ public class DocumentVersionImpl extends
List<DocumentVersion> allVers = fContainer.getAllVersions();
boolean hasPwc = null != fContainer.getPwc();
boolean isLatestVersion;
+
if (hasPwc) {
// CMIS 1.1 forbids it for PWC
isLatestVersion = allVers.size() > 1 && allVers.get(allVers.size() - 2).equals(this);
} else {
isLatestVersion = allVers.get(allVers.size() - 1).equals(this);
}
- if (hasPwc) {
- // CMIS 1.1 forbids it for PWC
- isLatestVersion = allVers.size() > 1 && allVers.get(allVers.size() - 2).equals(this);
- } else {
- isLatestVersion = allVers.get(allVers.size() - 1).equals(this);
- }
+
return isLatestVersion;
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-browser/src/main/java/org/apache/chemistry/opencmis/browser/BrowseServlet.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-browser/src/main/java/org/apache/chemistry/opencmis/browser/BrowseServlet.java?rev=1676576&r1=1676575&r2=1676576&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-browser/src/main/java/org/apache/chemistry/opencmis/browser/BrowseServlet.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-browser/src/main/java/org/apache/chemistry/opencmis/browser/BrowseServlet.java Tue Apr 28 16:40:11 2015
@@ -116,7 +116,7 @@ public class BrowseServlet extends HttpS
Document xslDoc = builder.parse(stream);
addStylesheet(stylesheetKey, new DOMSource(xslDoc), isOverride);
- LOG.info("Stylesheet: '" + stylesheetKey + "' -> '" + stylesheetFileName + "'");
+ LOG.info("Stylesheet: '{}' -> '{}'", stylesheetKey, stylesheetFileName);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
} finally {
@@ -133,13 +133,13 @@ public class BrowseServlet extends HttpS
String initAuxRoot = config.getInitParameter(INIT_PARAM_AUXROOT);
if (initAuxRoot != null) {
fAuxRoot = initAuxRoot;
- LOG.info("Auxiliary root: " + fAuxRoot);
+ LOG.info("Auxiliary root: {}", fAuxRoot);
}
String initAllow = config.getInitParameter(INIT_PARAM_ALLOW);
if (initAllow != null) {
fAllow = initAllow;
- LOG.info("Allow pattern: " + fAllow);
+ LOG.info("Allow pattern: {}", fAllow);
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/runner/WebRunnerServlet.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/runner/WebRunnerServlet.java?rev=1676576&r1=1676575&r2=1676576&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/runner/WebRunnerServlet.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/runner/WebRunnerServlet.java Tue Apr 28 16:40:11 2015
@@ -74,11 +74,15 @@ public class WebRunnerServlet extends Ht
printHeader(pw);
Map<String, String> parameters = new HashMap<String, String>();
- for (Map.Entry<String, String[]> entry : ((Map<String, String[]>) req.getParameterMap()).entrySet()) {
- if ((entry.getValue() == null) || (entry.getValue().length < 1)) {
- continue;
+ Map<String, String[]> parameterMap = (Map<String, String[]>) req.getParameterMap();
+
+ if (parameterMap != null) {
+ for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
+ if (entry.getValue() == null || entry.getValue().length < 1) {
+ continue;
+ }
+ parameters.put(entry.getKey(), entry.getValue()[0]);
}
- parameters.put(entry.getKey(), entry.getValue()[0]);
}
try {
Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/mapper/PropertyMapperExif.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/mapper/PropertyMapperExif.java?rev=1676576&r1=1676575&r2=1676576&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/mapper/PropertyMapperExif.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/mapper/PropertyMapperExif.java Tue Apr 28 16:40:11 2015
@@ -131,11 +131,11 @@ public class PropertyMapperExif extends
String propId = null;
String hexStr = getHexString(tag.getTagType());
- if (GpsDirectory.class.equals(dir.getClass())) {
+ if (GpsDirectory.class == dir.getClass()) {
propId = propMapGps.get(hexStr);
- } else if (ExifDirectory.class.equals(dir.getClass())) {
+ } else if (ExifDirectory.class == dir.getClass()) {
propId = propMapExif.get(hexStr);
- } else if (JpegDirectory.class.equals(dir.getClass())) {
+ } else if (JpegDirectory.class == dir.getClass()) {
propId = propMapJpeg.get(hexStr);
} else {
propId = null;
@@ -163,15 +163,15 @@ public class PropertyMapperExif extends
String hexStr = getHexString(tag.getTagType());
// Handle all tags corresponding to their directory specifics
- if (GpsDirectory.class.equals(dir.getClass())) {
+ if (GpsDirectory.class == dir.getClass()) {
// first check for those tags that need special consideration:
if (GpsDirectory.TAG_GPS_LONGITUDE == tag.getTagType()) {
Object ref = dir.getObject(GpsDirectory.TAG_GPS_LONGITUDE_REF);
- boolean mustInv = ref != null && ref.equals("W");
+ boolean mustInv = (ref instanceof String) && ((String) ref).equals("W");
return convertGps(tag, dir, mustInv);
} else if (GpsDirectory.TAG_GPS_LATITUDE == tag.getTagType()) {
Object ref = dir.getObject(GpsDirectory.TAG_GPS_LONGITUDE_REF);
- boolean mustInv = ref != null && ref.equals("S");
+ boolean mustInv = (ref instanceof String) && ((String) ref).equals("S");
return convertGps(tag, dir, mustInv);
} else {
String propId = propMapGps.get(hexStr);
@@ -184,8 +184,7 @@ public class PropertyMapperExif extends
LOG.error("Ignoring EXIF tag '" + tag + "\' no property type mapped to this tag.");
}
Object src = dir.getObject(tag.getTagType());
- Class<?> clazz = src.getClass();
- if (clazz.equals(Rational.class)) {
+ if (src instanceof Rational) {
// expect a CMIS decimal property
if (propType != PropertyType.DECIMAL) {
throw new MapperException("Tag value has type Rational and expected CMIS Decimal, but found: "
@@ -193,19 +192,19 @@ public class PropertyMapperExif extends
}
double d = ((Rational) src).doubleValue();
res = d;
- } else if (clazz.equals(String.class)) {
+ } else if (src instanceof String) {
if (propType != PropertyType.STRING && propType != PropertyType.ID && propType != PropertyType.URI
&& propType != PropertyType.HTML && propType != PropertyType.DATETIME) {
throw new MapperException("Tag value has type String and expected CMIS String, but found: "
+ propType + " for tag: " + tag);
}
- String s = ((String) src);
+ String s = (String) src;
res = s;
} else {
res = null;
}
}
- } else if (ExifDirectory.class.equals(dir.getClass())) {
+ } else if (ExifDirectory.class == dir.getClass()) {
// is there a property mapped to this tag?
String propId = propMapExif.get(hexStr);
LOG.debug("Found EXIF tag '" + tag + "\', property mapped is: " + propId);
@@ -224,7 +223,7 @@ public class PropertyMapperExif extends
LOG.error("Found a multi-value tag " + tag + ": multi value not implemented");
return null;
}
- if (clazz.equals(Rational.class)) {
+ if (clazz == Rational.class) {
// expect a CMIS decimal property
if (propType != PropertyType.DECIMAL) {
throw new MapperException("Tag value has type Rational and expected CMIS Decimal, but found: "
@@ -244,7 +243,7 @@ public class PropertyMapperExif extends
double d = ((Rational) src).doubleValue();
res = d;
}
- } else if (clazz.equals(Integer.class)) {
+ } else if (clazz == Integer.class) {
if (propType != PropertyType.INTEGER) {
throw new MapperException("Tag value has type Integer and expected CMIS Integer, but found: "
+ propType + " for tag: " + tag);
@@ -252,7 +251,7 @@ public class PropertyMapperExif extends
// convert to a long
long l = ((Integer) src).longValue();
res = l;
- } else if (clazz.equals(String.class)) {
+ } else if (clazz == String.class) {
if (propType != PropertyType.STRING && propType != PropertyType.ID && propType != PropertyType.URI
&& propType != PropertyType.HTML && propType != PropertyType.DATETIME) {
throw new MapperException("Tag value has type String and expected CMIS String, but found: "
@@ -277,10 +276,10 @@ public class PropertyMapperExif extends
}
res = cal;
} else {
- String s = ((String) src);
+ String s = (String) src;
res = s;
}
- } else if (clazz.equals(Date.class)) {
+ } else if (clazz == Date.class) {
if (propType != PropertyType.DATETIME) {
throw new MapperException("Tag value has type Date and expected CMIS DateTime, but found: "
+ propType + " for tag: " + tag);
@@ -291,13 +290,13 @@ public class PropertyMapperExif extends
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(date);
res = cal;
- } else if (clazz.equals(Boolean.class)) {
+ } else if (clazz == Boolean.class) {
if (propType != PropertyType.BOOLEAN) {
throw new MapperException("Tag value has type Boolean and expected CMIS Boolean, but found: "
+ propType + " for tag: " + tag);
}
// convert to a String
- Boolean b = ((Boolean) src);
+ Boolean b = (Boolean) src;
res = b;
} else {
LOG.debug("Tag value has unsupported type: " + clazz.getName() + " for EXIF tag: " + tag);
@@ -318,7 +317,7 @@ public class PropertyMapperExif extends
Object src = dir.getObject(tag.getTagType());
Class<?> clazz = src.getClass();
- if (clazz.equals(Integer.class)) {
+ if (clazz == Integer.class) {
if (propType != PropertyType.INTEGER) {
throw new MapperException("Tag value has type Integer and expected CMIS Integer, but found: "
+ propType + " for tag: " + tag);
Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/specexamples/SpecExamples.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/specexamples/SpecExamples.java?rev=1676576&r1=1676575&r2=1676576&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/specexamples/SpecExamples.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/specexamples/SpecExamples.java Tue Apr 28 16:40:11 2015
@@ -662,7 +662,7 @@ public class SpecExamples {
addDirectory(zout, dir, dirToZip);
}
} catch (Exception e) {
- LOG.error("Creating ZIP file failed: " + e);
+ LOG.error("Creating ZIP file failed: {}", e.toString(), e);
} finally {
IOUtils.closeQuietly(zout);
IOUtils.closeQuietly(fout);
@@ -679,7 +679,7 @@ public class SpecExamples {
if (files[i].isDirectory()) {
addDirectory(zout, prefix + File.separator + files[i].getName(), files[i]);
} else {
- LOG.debug("Create Zip, adding file " + files[i].getName());
+ LOG.debug("Create Zip, adding file {}", files[i].getName());
byte[] buffer = new byte[BUFSIZE];
FileInputStream fin = new FileInputStream(files[i]);
try {
@@ -693,7 +693,11 @@ public class SpecExamples {
}
} finally {
IOUtils.closeQuietly(fin);
- zout.closeEntry();
+ try {
+ zout.closeEntry();
+ } catch (IOException ioe) {
+ LOG.debug("Closing zip entry failed: {}", ioe.toString(), ioe);
+ }
}
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/fractal/FractalGenerator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/fractal/FractalGenerator.java?rev=1676576&r1=1676575&r2=1676576&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/fractal/FractalGenerator.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/fractal/FractalGenerator.java Tue Apr 28 16:40:11 2015
@@ -32,11 +32,11 @@ import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.security.SecureRandom;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
-import java.util.Random;
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
@@ -97,7 +97,7 @@ public class FractalGenerator {
juliaPoint = null; // new ComplexPoint();
maxIterations = DEFAULT_MAX_ITERATIONS;
- Random ran = new Random();
+ SecureRandom ran = new SecureRandom();
color = colorSchemes[ran.nextInt(colorSchemes.length)];
parts = ran.nextInt(13) + 3;
LOG.debug("Parts: " + parts);
Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/loremipsum/LoremIpsum.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/loremipsum/LoremIpsum.java?rev=1676576&r1=1676575&r2=1676576&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/loremipsum/LoremIpsum.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/loremipsum/LoremIpsum.java Tue Apr 28 16:40:11 2015
@@ -20,6 +20,7 @@ package org.apache.chemistry.opencmis.ut
import java.io.IOException;
import java.io.StringWriter;
+import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -198,7 +199,7 @@ public class LoremIpsum {
String delim;
}
- private Random randomGenerator = new Random();
+ private SecureRandom randomGenerator = new SecureRandom();
/**
* Generates random strings of "lorem ipsum" text, based on the word
Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java?rev=1676576&r1=1676575&r2=1676576&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java Tue Apr 28 16:40:11 2015
@@ -154,7 +154,8 @@ public final class ClientHelper {
}
public static boolean isMacOSX() {
- return System.getProperty("os.name").startsWith("Mac OS X");
+ String osname = System.getProperty("os.name");
+ return osname == null ? false : osname.startsWith("Mac OS X");
}
public static void installKeyBindings() {
Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ProxyDetector.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ProxyDetector.java?rev=1676576&r1=1676575&r2=1676576&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ProxyDetector.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ProxyDetector.java Tue Apr 28 16:40:11 2015
@@ -310,7 +310,8 @@ public class ProxyDetector {
}
private static boolean isWindows() {
- return System.getProperty("os.name").startsWith("Windows");
+ String osname = System.getProperty("os.name");
+ return osname == null ? false : osname.startsWith("Windows");
}
/**