Pulled configurable OpenCMIS properties out of Spring context and some minor formatting

# OpenCMIS
 opencmis.connector.default.store=${spaces.store}
 opencmis.connector.default.rootPath=/${spaces.company_home.childname}
 opencmis.connector.default.typesDefaultMaxItems=500
 opencmis.connector.default.typesDefaultDepth=-1
 opencmis.connector.default.objectsDefaultMaxItems=10000
 opencmis.connector.default.objectsDefaultDepth=100
 opencmis.connector.default.openHttpSession=false


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32595 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2011-12-07 12:57:25 +00:00
parent 514af39053
commit 4eccacfa12
7 changed files with 136 additions and 75 deletions

View File

@@ -60,12 +60,12 @@
<bean id="CMISService_Control" class="org.alfresco.opencmis.AlfrescoCmisServiceInterceptor" />
<bean id="CMISConnector" class="org.alfresco.opencmis.CMISConnector">
<property name="store" value="${spaces.store}" />
<property name="rootPath" value="/${spaces.company_home.childname}" />
<property name="typesDefaultMaxItems" value="500" />
<property name="typesDefaultDepth" value="-1" />
<property name="objectsDefaultMaxItems" value="10000" />
<property name="objectsDefaultDepth" value="100" />
<property name="store" value="${opencmis.connector.default.store}" />
<property name="rootPath" value="${opencmis.connector.default.rootPath}" />
<property name="typesDefaultMaxItems" value="${opencmis.connector.default.typesDefaultMaxItems}" />
<property name="typesDefaultDepth" value="${opencmis.connector.default.typesDefaultDepth}" />
<property name="objectsDefaultMaxItems" value="${opencmis.connector.default.objectsDefaultMaxItems}" />
<property name="objectsDefaultDepth" value="${opencmis.connector.default.objectsDefaultDepth}" />
<property name="renditionKindMapping">
<map>
<entry key="cmis:thumbnail">
@@ -82,8 +82,7 @@
</map>
</property>
<!-- Uncomment the following line to support sticky sessions. Make sure the CMIS client supports cookies. -->
<!-- <property name="openHttpSession" value="true" /> -->
<property name="openHttpSession" value="${opencmis.connector.default.openHttpSession}" />
<property name="OpenCMISDictionaryService" ref="OpenCMISDictionaryService" />
<property name="OpenCMISQueryService" ref="OpenCMISQueryService" />

View File

@@ -598,6 +598,15 @@ nfs.user.mappings.default.gid=0
protocols.storeName=${spaces.store}
protocols.rootPath=/${spaces.company_home.childname}
# OpenCMIS
opencmis.connector.default.store=${spaces.store}
opencmis.connector.default.rootPath=/${spaces.company_home.childname}
opencmis.connector.default.typesDefaultMaxItems=500
opencmis.connector.default.typesDefaultDepth=-1
opencmis.connector.default.objectsDefaultMaxItems=10000
opencmis.connector.default.objectsDefaultDepth=100
opencmis.connector.default.openHttpSession=false
# IMAP
imap.server.enabled=false
imap.server.port=143

View File

@@ -842,7 +842,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
nodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, props);
}
getCheckOutCheckInService().checkout(nodeRef);
} else if ((versioningState == VersioningState.MAJOR) || (versioningState == VersioningState.MINOR))
}
else if ((versioningState == VersioningState.MAJOR) || (versioningState == VersioningState.MINOR))
{
if (!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE))
{
@@ -853,7 +854,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
}
Map<String, Serializable> versionProperties = new HashMap<String, Serializable>(5);
versionProperties.put(VersionModel.PROP_VERSION_TYPE,
versionProperties.put(
VersionModel.PROP_VERSION_TYPE,
versioningState == VersioningState.MAJOR ? VersionType.MAJOR : VersionType.MINOR);
versionProperties.put(VersionModel.PROP_DESCRIPTION, "Initial Version");
@@ -948,7 +950,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
// association have no ACL - return an empty list of ACEs
result.setAcl(new AccessControlListImpl((List<Ace>) Collections.EMPTY_LIST));
}
} else
}
else
{
// set properties
result.setProperties(nodeProps);
@@ -1016,7 +1019,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
{
// render root path
displayPath.append("/");
} else
}
else
{
// render CMIS scoped path
i++;
@@ -1080,7 +1084,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
{
result.setStream(contentReader.getContentInputStream());
result.setLength(BigInteger.valueOf(contentReader.getSize()));
} else
}
else
{
long off = (offset == null ? 0 : offset.longValue());
long len = (length == null ? contentReader.getSize() : length.longValue()) - off;
@@ -1092,12 +1097,14 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
result.setStream(new RangeInputStream(contentReader.getContentInputStream(), off, len));
result.setLength(BigInteger.valueOf(len));
}
} catch (Exception e)
}
catch (Exception e)
{
if (e instanceof CmisBaseException)
{
throw (CmisBaseException) e;
} else
}
else
{
throw new CmisRuntimeException("Failed to retrieve content: " + e.getMessage(), e);
}
@@ -1173,7 +1180,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
if (accessor instanceof DirectProperty)
{
value = nodeProps.get(accessor.getMappedProperty());
} else
}
else
{
value = propDef.getPropertyAccessor().getValue(info);
}
@@ -1301,7 +1309,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
propertyValues.add(new CmisExtensionElementImpl(CMIS_NAMESPACE, "value", null,
convertAspectPropertyValue(o)));
}
} else
}
else
{
propertyValues.add(new CmisExtensionElementImpl(CMIS_NAMESPACE, "value", null,
convertAspectPropertyValue(value)));
@@ -1326,7 +1335,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
try
{
df = DatatypeFactory.newInstance();
} catch (DatatypeConfigurationException e)
}
catch (DatatypeConfigurationException e)
{
throw new IllegalArgumentException("Aspect conversation exception: " + e.getMessage(), e);
}
@@ -1348,7 +1358,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
if (value instanceof List)
{
((PropertyBooleanImpl) result).setValues((List<Boolean>) value);
} else
}
else
{
((PropertyBooleanImpl) result).setValue((Boolean) value);
}
@@ -1359,7 +1370,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
{
((PropertyDateTimeImpl) result).setValues((List<GregorianCalendar>) DefaultTypeConverter.INSTANCE
.convert(GregorianCalendar.class, (List<?>) value));
} else
}
else
{
((PropertyDateTimeImpl) result).setValue(DefaultTypeConverter.INSTANCE.convert(GregorianCalendar.class,
value));
@@ -1371,7 +1383,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
{
((PropertyDecimalImpl) result).setValues((List<BigDecimal>) DefaultTypeConverter.INSTANCE.convert(
BigDecimal.class, (List<?>) value));
} else
}
else
{
((PropertyDecimalImpl) result).setValue(DefaultTypeConverter.INSTANCE.convert(BigDecimal.class, value));
}
@@ -1381,7 +1394,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
if (value instanceof List)
{
((PropertyHtmlImpl) result).setValues((List<String>) value);
} else
}
else
{
((PropertyHtmlImpl) result).setValue((String) value);
}
@@ -1391,12 +1405,14 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
if (value instanceof List)
{
((PropertyIdImpl) result).setValues((List<String>) value);
} else
}
else
{
if (value instanceof NodeRef)
{
((PropertyIdImpl) result).setValue(value.toString());
} else
}
else
{
((PropertyIdImpl) result).setValue((String) value);
}
@@ -1408,7 +1424,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
{
((PropertyIntegerImpl) result).setValues((List<BigInteger>) DefaultTypeConverter.INSTANCE.convert(
BigInteger.class, (List<?>) value));
} else
}
else
{
((PropertyIntegerImpl) result).setValue(DefaultTypeConverter.INSTANCE.convert(BigInteger.class, value));
}
@@ -1418,7 +1435,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
if (value instanceof List)
{
((PropertyStringImpl) result).setValues((List<String>) value);
} else
}
else
{
((PropertyStringImpl) result).setValue((String) value);
}
@@ -1428,7 +1446,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
if (value instanceof List)
{
((PropertyUriImpl) result).setValues((List<String>) value);
} else
}
else
{
((PropertyUriImpl) result).setValue((String) value);
}
@@ -1467,7 +1486,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
if (s.equals("*"))
{
return null;
} else if (s.length() > 0)
}
else if (s.length() > 0)
{
result.add(s);
}
@@ -1599,7 +1619,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
result.getObjects().add(
createCMISObject(createNodeInfo(assocRef), filter, includeAllowableActions,
IncludeRelationships.NONE, RENDITION_NONE, false, false));
} else
}
else
{
hasMore = true;
}
@@ -1655,7 +1676,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
}
ace.getPermissions().add(entry.getPermission());
} else if (entry.getAccessStatus() == AccessStatus.DENIED)
}
else if (entry.getAccessStatus() == AccessStatus.DENIED)
{
// remove denied entries
Map<Boolean, AccessControlEntryImpl> directAce = aceMap.get(entry.getAuthority());
@@ -1734,10 +1756,12 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
if (PermissionService.READ.equals(perm))
{
result.add(BasicPermissions.READ);
} else if (PermissionService.WRITE.equals(perm))
}
else if (PermissionService.WRITE.equals(perm))
{
result.add(BasicPermissions.WRITE);
} else if (PermissionService.ALL_PERMISSIONS.equals(perm))
}
else if (PermissionService.ALL_PERMISSIONS.equals(perm))
{
result.add(BasicPermissions.READ);
result.add(BasicPermissions.WRITE);
@@ -1749,10 +1773,12 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
if (PermissionService.READ.equals(permission))
{
result.add(BasicPermissions.READ);
} else if (PermissionService.WRITE.equals(permission))
}
else if (PermissionService.WRITE.equals(permission))
{
result.add(BasicPermissions.WRITE);
} else if (PermissionService.ALL_PERMISSIONS.equals(permission))
}
else if (PermissionService.ALL_PERMISSIONS.equals(permission))
{
result.add(BasicPermissions.READ);
result.add(BasicPermissions.WRITE);
@@ -1765,7 +1791,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
if (permission.startsWith("{"))
{
result.add(permission);
} else
}
else
{
result.add(permissionReference.toString());
}
@@ -1782,18 +1809,21 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
if (left.getPosition() != right.getPosition())
{
return right.getPosition() - left.getPosition();
} else
}
else
{
if (left.getAccessStatus() != right.getAccessStatus())
{
return (left.getAccessStatus() == AccessStatus.DENIED) ? -1 : 1;
} else
}
else
{
int compare = left.getAuthority().compareTo(right.getAuthority());
if (compare != 0)
{
return compare;
} else
}
else
{
return (left.getPermission().compareTo(right.getPermission()));
}
@@ -1923,22 +1953,27 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
if (BasicPermissions.READ.equals(permission))
{
result.add(PermissionService.READ);
} else if (BasicPermissions.WRITE.equals(permission))
}
else if (BasicPermissions.WRITE.equals(permission))
{
result.add(PermissionService.WRITE);
} else if (BasicPermissions.ALL.equals(permission))
}
else if (BasicPermissions.ALL.equals(permission))
{
result.add(PermissionService.ALL_PERMISSIONS);
} else if (!permission.startsWith("{"))
}
else if (!permission.startsWith("{"))
{
result.add(permission);
} else
}
else
{
int sepIndex = permission.lastIndexOf('.');
if (sepIndex == -1)
{
result.add(permission);
} else
}
else
{
result.add(permission.substring(sepIndex + 1));
}
@@ -2111,10 +2146,12 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
if (ASPECTS_TO_ADD.equals(extension.getName()) && (extension.getValue() != null))
{
aspectsToAdd.add(extension.getValue());
} else if (ASPECTS_TO_REMOVE.equals(extension.getName()) && (extension.getValue() != null))
}
else if (ASPECTS_TO_REMOVE.equals(extension.getName()) && (extension.getValue() != null))
{
aspectsToRemove.add(extension.getValue());
} else if (PROPERTIES.equals(extension.getName()) && (extension.getChildren() != null))
}
else if (PROPERTIES.equals(extension.getName()) && (extension.getChildren() != null))
{
for (CmisExtensionElement property : extension.getChildren())
{
@@ -2135,20 +2172,24 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
if (property.getName().equals("propertyBoolean"))
{
propertyType = PropertyType.BOOLEAN;
} else if (property.getName().equals("propertyInteger"))
}
else if (property.getName().equals("propertyInteger"))
{
propertyType = PropertyType.INTEGER;
} else if (property.getName().equals("propertyDateTime"))
}
else if (property.getName().equals("propertyDateTime"))
{
propertyType = PropertyType.DATETIME;
try
{
df = DatatypeFactory.newInstance();
} catch (DatatypeConfigurationException e)
}
catch (DatatypeConfigurationException e)
{
throw new CmisRuntimeException("Aspect conversation exception: " + e.getMessage(), e);
}
} else if (property.getName().equals("propertyDecimal"))
}
else if (property.getName().equals("propertyDecimal"))
{
propertyType = PropertyType.DECIMAL;
}
@@ -2182,7 +2223,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
}
}
}
} catch (Exception e)
}
catch (Exception e)
{
throw new CmisInvalidArgumentException("Invalid property aspect value: " + propertyId, e);
}
@@ -2209,10 +2251,12 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
nodeService.addAspect(nodeRef, getType(aspect).getAlfrescoName(),
Collections.<QName, Serializable> emptyMap());
}
} catch (InvalidAspectException e)
}
catch (InvalidAspectException e)
{
throw new CmisInvalidArgumentException("Invalid aspect: " + aspectType);
} catch (InvalidNodeRefException e)
}
catch (InvalidNodeRefException e)
{
throw new CmisInvalidArgumentException("Invalid node: " + nodeRef);
}
@@ -2223,7 +2267,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
if (property.getValue().isEmpty())
{
nodeService.removeProperty(nodeRef, property.getKey());
} else
}
else
{
nodeService.setProperty(nodeRef, property.getKey(), property.getValue().size() == 1 ? property
.getValue().get(0) : (Serializable) property.getValue());
@@ -2273,19 +2318,23 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
try
{
fileFolderService.rename(nodeRef, value.toString());
} catch (FileExistsException e)
}
catch (FileExistsException e)
{
throw new CmisContentAlreadyExistsException("An object with this name already exists!", e);
} catch (FileNotFoundException e)
}
catch (FileNotFoundException e)
{
throw new CmisInvalidArgumentException("Object with id " + nodeRef.toString() + " not found!");
}
} else
}
else
{
if (value == null)
{
nodeService.removeProperty(nodeRef, propertyQName);
} else
}
else
{
nodeService.setProperty(nodeRef, propertyQName, value);
}
@@ -2331,7 +2380,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
try
{
from = Long.parseLong(changeLogToken.getValue());
} catch (NumberFormatException e)
}
catch (NumberFormatException e)
{
throw new CmisInvalidArgumentException("Invalid change log token: " + changeLogToken);
}
@@ -2354,7 +2404,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
{
newChangeLogToken = result.getObjects().remove(result.getObjects().size() - 1).getId();
result.setHasMoreItems(true);
} else
}
else
{
result.setHasMoreItems(false);
}
@@ -2527,7 +2578,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
if (fallback == null)
{
throw new CmisInvalidArgumentException("Property " + PropertyIds.NAME + " must be set!");
} else
}
else
{
name = fallback;
}

View File

@@ -117,7 +117,7 @@ public class OpenCmisLocalTest extends TestCase
assertNotNull("No repository available for testing", repository);
}
public void DISABLED_testBasicFileOps()
public void testBasicFileOps()
{
Repository repository = getRepository("admin", "admin");
Session session = repository.createSession();

View File

@@ -34,14 +34,13 @@ public class CanCancelCheckOutActionEvaluator extends AbstractActionEvaluator
/**
* Construct
*
* @param serviceRegistry
* @param permission
*/
protected CanCancelCheckOutActionEvaluator(ServiceRegistry serviceRegistry)
{
super(serviceRegistry, Action.CAN_CANCEL_CHECK_OUT);
permissionEvaluator = new PermissionActionEvaluator(serviceRegistry, Action.CAN_CANCEL_CHECK_OUT,
permissionEvaluator = new PermissionActionEvaluator(
serviceRegistry,
Action.CAN_CANCEL_CHECK_OUT,
PermissionService.CANCEL_CHECK_OUT);
}

View File

@@ -34,14 +34,13 @@ public class CanCheckInActionEvaluator extends AbstractActionEvaluator
/**
* Construct
*
* @param serviceRegistry
* @param permission
*/
protected CanCheckInActionEvaluator(ServiceRegistry serviceRegistry)
{
super(serviceRegistry, Action.CAN_CHECK_IN);
permissionEvaluator = new PermissionActionEvaluator(serviceRegistry, Action.CAN_CHECK_IN,
permissionEvaluator = new PermissionActionEvaluator(
serviceRegistry,
Action.CAN_CHECK_IN,
PermissionService.CHECK_IN);
}

View File

@@ -22,6 +22,7 @@ import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.lock.LockService;
import org.alfresco.service.cmr.lock.LockType;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.PermissionService;
import org.apache.chemistry.opencmis.commons.enums.Action;
@@ -37,26 +38,28 @@ public class CanCheckOutActionEvaluator extends AbstractActionEvaluator
/**
* Construct
*
* @param serviceRegistry
* @param permission
*/
protected CanCheckOutActionEvaluator(ServiceRegistry serviceRegistry)
{
super(serviceRegistry, Action.CAN_CHECK_OUT);
permissionEvaluator = new PermissionActionEvaluator(serviceRegistry, Action.CAN_CHECK_OUT,
permissionEvaluator = new PermissionActionEvaluator(
serviceRegistry,
Action.CAN_CHECK_OUT,
PermissionService.CHECK_OUT);
lockService = serviceRegistry.getLockService();
}
/**
* Node must be versionable, must not have a Private Working Copy and must not be locked.
*/
public boolean isAllowed(CMISNodeInfo nodeInfo)
{
if (nodeInfo.hasPWC() || lockService.getLockType(nodeInfo.getNodeRef()) == LockType.READ_ONLY_LOCK)
NodeRef nodeRef = nodeInfo.getNodeRef();
if (nodeInfo.hasPWC() || lockService.getLockType(nodeRef) == LockType.READ_ONLY_LOCK)
{
return false;
}
return permissionEvaluator.isAllowed(nodeInfo);
}
}