/** * Checks if at least one ACE list is not empty. */ protected boolean isAclMergeRequired(Acl addAces, Acl removeAces) { return (addAces != null && isNotEmpty(addAces.getAces())) || (removeAces != null && isNotEmpty(removeAces.getAces())); }
/** * Helper method for * {@link #getTypeDescendants(String, String, BigInteger, Boolean, ExtensionsData)} * . */ private void addTypeChildren(String repositoryId, Boolean includePropertyDefinitions, int depth, TypeDefinitionContainerImpl container) { if (depth == 0) { return; } TypeDefinitionList children = getTypeChildren(repositoryId, container.getTypeDefinition().getId(), includePropertyDefinitions, BigInteger.valueOf(Integer.MAX_VALUE), BigInteger.ZERO, null); if (children != null && isNotEmpty(children.getList())) { List<TypeDefinitionContainer> list = new ArrayList<TypeDefinitionContainer>(); container.setChildren(list); for (TypeDefinition td : children.getList()) { TypeDefinitionContainerImpl tdc = new TypeDefinitionContainerImpl(td); addTypeChildren(repositoryId, includePropertyDefinitions, (depth > 0 ? depth - 1 : -1), tdc); list.add(tdc); } } }
@Override public List<TypeDefinitionContainer> getTypeDescendants(String repositoryId, String typeId, BigInteger depth, Boolean includePropertyDefinitions, ExtensionsData extension) { List<TypeDefinitionContainer> result = null; boolean hasExtension = (extension != null) && isNotEmpty(extension.getExtensions()); boolean propDefs = includePropertyDefinitions == null ? false : includePropertyDefinitions.booleanValue(); // get the SPI and fetch the type definitions CmisSpi spi = CmisBindingsHelper.getSPI(session); result = spi.getRepositoryService().getTypeDescendants(repositoryId, typeId, depth, includePropertyDefinitions, extension); // put it into the cache if (!hasExtension && propDefs && (result != null)) { TypeDefinitionCache cache = CmisBindingsHelper.getTypeDefinitionCache(session); addToTypeCache(cache, repositoryId, result); } return result; }
@Override public List<TypeDefinitionContainer> getTypeDescendants(String repositoryId, String typeId, BigInteger depth, Boolean includePropertyDefinitions, ExtensionsData extension) { List<TypeDefinitionContainer> result = null; boolean hasExtension = (extension != null) && isNotEmpty(extension.getExtensions()); boolean propDefs = includePropertyDefinitions == null ? false : includePropertyDefinitions.booleanValue(); // get the SPI and fetch the type definitions CmisSpi spi = CmisBindingsHelper.getSPI(session); result = spi.getRepositoryService().getTypeDescendants(repositoryId, typeId, depth, includePropertyDefinitions, extension); // put it into the cache if (!hasExtension && propDefs && (result != null)) { TypeDefinitionCache cache = CmisBindingsHelper.getTypeDefinitionCache(session); addToTypeCache(cache, repositoryId, result); } return result; }
/** * Makes a deep copy of an extension element. */ private CmisExtensionElement copy(CmisExtensionElement element) { if (element == null) { return null; } Map<String, String> attrs = (element.getAttributes() != null ? new HashMap<String, String>( element.getAttributes()) : null); List<CmisExtensionElement> children = element.getChildren(); if (isNotEmpty(children)) { List<CmisExtensionElement> copyChildren = new ArrayList<CmisExtensionElement>(children.size()); for (CmisExtensionElement child : children) { copyChildren.add(copy(child)); } return new CmisExtensionElementImpl(element.getNamespace(), element.getName(), attrs, copyChildren); } else { return new CmisExtensionElementImpl(element.getNamespace(), element.getName(), attrs, element.getValue()); } }
public void validate(PropertyDefinition<T> propDef, PropertyData<T> prop) { // check general constraints for all property types if (propDef.getCardinality() == Cardinality.SINGLE) { if (prop.getValues() != null && prop.getValues().size() > 1) { throw new CmisConstraintException("The property with id " + propDef.getId() + " is single valued, but multiple values are passed " + prop.getValues()); } } if (isNotEmpty(propDef.getChoices())) { validateChoices(propDef, prop); } }
/** * Return the CMIS version of the given repository. */ protected CmisVersion getCmisVersion(String repositoryId) { if (CmisBindingsHelper.getForcedCmisVersion(session) != null) { return CmisBindingsHelper.getForcedCmisVersion(session); } RepositoryInfoCache cache = CmisBindingsHelper.getRepositoryInfoCache(session); RepositoryInfo info = cache.get(repositoryId); if (info == null) { List<RepositoryInfo> infoList = getRepositoriesInternal(repositoryId); if (isNotEmpty(infoList)) { info = infoList.get(0); cache.put(info); } } return info == null ? CmisVersion.CMIS_1_0 : info.getCmisVersion(); }
@Override public TypeDefinitionList getTypeChildren(String repositoryId, String typeId, Boolean includePropertyDefinitions, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) { TypeDefinitionList result = null; boolean hasExtension = (extension != null) && isNotEmpty(extension.getExtensions()); boolean propDefs = (includePropertyDefinitions == null ? false : includePropertyDefinitions.booleanValue()); // get the SPI and fetch the type definitions CmisSpi spi = CmisBindingsHelper.getSPI(session); result = spi.getRepositoryService().getTypeChildren(repositoryId, typeId, includePropertyDefinitions, maxItems, skipCount, extension); // put it into the cache if (!hasExtension && propDefs && (result != null)) { TypeDefinitionCache cache = CmisBindingsHelper.getTypeDefinitionCache(session); for (TypeDefinition tdd : result.getList()) { cache.put(repositoryId, tdd); } } return result; }
/** * Return the CMIS version of the given repository. */ protected CmisVersion getCmisVersion(String repositoryId) { if (CmisBindingsHelper.getForcedCmisVersion(session) != null) { return CmisBindingsHelper.getForcedCmisVersion(session); } RepositoryInfoCache cache = CmisBindingsHelper.getRepositoryInfoCache(session); RepositoryInfo info = cache.get(repositoryId); if (info == null) { List<RepositoryInfo> infoList = getRepositoriesInternal(repositoryId); if (isNotEmpty(infoList)) { info = infoList.get(0); cache.put(info); } } return info == null ? CmisVersion.CMIS_1_0 : info.getCmisVersion(); }
@Override public TypeDefinitionList getTypeChildren(String repositoryId, String typeId, Boolean includePropertyDefinitions, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) { TypeDefinitionList result = null; boolean hasExtension = (extension != null) && isNotEmpty(extension.getExtensions()); boolean propDefs = (includePropertyDefinitions == null ? false : includePropertyDefinitions.booleanValue()); // get the SPI and fetch the type definitions CmisSpi spi = CmisBindingsHelper.getSPI(session); result = spi.getRepositoryService().getTypeChildren(repositoryId, typeId, includePropertyDefinitions, maxItems, skipCount, extension); // put it into the cache if (!hasExtension && propDefs && (result != null)) { TypeDefinitionCache cache = CmisBindingsHelper.getTypeDefinitionCache(session); for (TypeDefinition tdd : result.getList()) { cache.put(repositoryId, tdd); } } return result; }
@Override public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension) { List<RepositoryInfo> result = null; boolean hasExtension = (extension != null) && isNotEmpty(extension.getExtensions()); // get the SPI and fetch the repository infos CmisSpi spi = CmisBindingsHelper.getSPI(session); result = spi.getRepositoryService().getRepositoryInfos(extension); // put it into the cache if (!hasExtension && (result != null)) { RepositoryInfoCache cache = CmisBindingsHelper.getRepositoryInfoCache(session); for (RepositoryInfo rid : result) { cache.put(rid); } } return result; }
@Override public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension) { List<RepositoryInfo> result = null; boolean hasExtension = (extension != null) && isNotEmpty(extension.getExtensions()); // get the SPI and fetch the repository infos CmisSpi spi = CmisBindingsHelper.getSPI(session); result = spi.getRepositoryService().getRepositoryInfos(extension); // put it into the cache if (!hasExtension && (result != null)) { RepositoryInfoCache cache = CmisBindingsHelper.getRepositoryInfoCache(session); for (RepositoryInfo rid : result) { cache.put(rid); } } return result; }
@Override public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension, boolean useCache) { TypeDefinition result = null; boolean hasExtension = (extension != null) && isNotEmpty(extension.getExtensions()); TypeDefinitionCache cache = CmisBindingsHelper.getTypeDefinitionCache(session); // if the cache should be used and the extension is not set, // check the cache first if (useCache && !hasExtension) { result = cache.get(repositoryId, typeId); if (result != null) { return result; } } // it was not in the cache -> get the SPI and fetch the type definition CmisSpi spi = CmisBindingsHelper.getSPI(session); result = spi.getRepositoryService().getTypeDefinition(repositoryId, typeId, extension); // put it into the cache if (!hasExtension && (result != null)) { cache.put(repositoryId, result); } return result; }
private void addAcesParameters(Acl acl, String principalControl, String permissionControl) { if (acl == null || acl.getAces() == null) { return; } int idx = 0; for (Ace ace : acl.getAces()) { if (ace.getPrincipalId() != null && isNotEmpty(ace.getPermissions())) { String idxStr = "[" + idx + "]"; addParameter(principalControl + idxStr, ace.getPrincipalId()); int permIdx = 0; for (String perm : ace.getPermissions()) { if (perm != null) { String permIdxStr = "[" + permIdx + "]"; addParameter(permissionControl + idxStr + permIdxStr, perm); permIdx++; } } idx++; } } }
/** * Converts a type definition container. */ public static JSONObject convert(final TypeDefinitionContainer container, final DateTimeFormat dateTimeFormat) { if (container == null) { return null; } JSONObject result = new JSONObject(); result.put(JSON_TYPESCONTAINER_TYPE, convert(container.getTypeDefinition(), dateTimeFormat)); if (isNotEmpty(container.getChildren())) { JSONArray children = new JSONArray(); for (TypeDefinitionContainer child : container.getChildren()) { children.add(convert(child, dateTimeFormat)); } result.put(JSON_TYPESCONTAINER_CHILDREN, children); } convertExtension(container, result); return result; }
/** * Converts a folder container. */ public static JSONObject convert(final ObjectInFolderContainer container, final TypeCache typeCache, final boolean succinct, final DateTimeFormat dateTimeFormat) { if (container == null) { return null; } JSONObject result = new JSONObject(); result.put(JSON_OBJECTINFOLDERCONTAINER_OBJECT, convert(container.getObject(), typeCache, succinct, dateTimeFormat)); if (isNotEmpty(container.getChildren())) { JSONArray children = new JSONArray(); for (ObjectInFolderContainer descendant : container.getChildren()) { children.add(JSONConverter.convert(descendant, typeCache, succinct, dateTimeFormat)); } result.put(JSON_OBJECTINFOLDERCONTAINER_CHILDREN, children); } convertExtension(container, result); return result; }
/** * Converts a folder container. */ public static JSONObject convert(final ObjectInFolderContainer container, final TypeCache typeCache, final boolean succinct, final DateTimeFormat dateTimeFormat) { if (container == null) { return null; } JSONObject result = new JSONObject(); result.put(JSON_OBJECTINFOLDERCONTAINER_OBJECT, convert(container.getObject(), typeCache, succinct, dateTimeFormat)); if (isNotEmpty(container.getChildren())) { JSONArray children = new JSONArray(); for (ObjectInFolderContainer descendant : container.getChildren()) { children.add(JSONConverter.convert(descendant, typeCache, succinct, dateTimeFormat)); } result.put(JSON_OBJECTINFOLDERCONTAINER_CHILDREN, children); } convertExtension(container, result); return result; }
/** * Converts a type definition container. */ public static JSONObject convert(final TypeDefinitionContainer container, final DateTimeFormat dateTimeFormat) { if (container == null) { return null; } JSONObject result = new JSONObject(); result.put(JSON_TYPESCONTAINER_TYPE, convert(container.getTypeDefinition(), dateTimeFormat)); if (isNotEmpty(container.getChildren())) { JSONArray children = new JSONArray(); for (TypeDefinitionContainer child : container.getChildren()) { children.add(convert(child, dateTimeFormat)); } result.put(JSON_TYPESCONTAINER_CHILDREN, children); } convertExtension(container, result); return result; }
private static JSONObject convert(final ExtensionFeature feature) { if (feature == null) { return null; } JSONObject jsonFeature = new JSONObject(); setIfNotNull(JSON_FEATURE_ID, feature.getId(), jsonFeature); setIfNotNull(JSON_FEATURE_URL, feature.getUrl(), jsonFeature); setIfNotNull(JSON_FEATURE_COMMON_NAME, feature.getCommonName(), jsonFeature); setIfNotNull(JSON_FEATURE_VERSION_LABEL, feature.getVersionLabel(), jsonFeature); setIfNotNull(JSON_FEATURE_DESCRIPTION, feature.getDescription(), jsonFeature); if (isNotEmpty(feature.getFeatureData())) { JSONObject data = new JSONObject(); data.putAll(feature.getFeatureData()); jsonFeature.put(JSON_FEATURE_DATA, data); } convertExtension(feature, jsonFeature); return jsonFeature; }
private static JSONObject convert(final ExtensionFeature feature) { if (feature == null) { return null; } JSONObject jsonFeature = new JSONObject(); setIfNotNull(JSON_FEATURE_ID, feature.getId(), jsonFeature); setIfNotNull(JSON_FEATURE_URL, feature.getUrl(), jsonFeature); setIfNotNull(JSON_FEATURE_COMMON_NAME, feature.getCommonName(), jsonFeature); setIfNotNull(JSON_FEATURE_VERSION_LABEL, feature.getVersionLabel(), jsonFeature); setIfNotNull(JSON_FEATURE_DESCRIPTION, feature.getDescription(), jsonFeature); if (isNotEmpty(feature.getFeatureData())) { JSONObject data = new JSONObject(); data.putAll(feature.getFeatureData()); jsonFeature.put(JSON_FEATURE_DATA, data); } convertExtension(feature, jsonFeature); return jsonFeature; }