org.apache.chemistry.opencmis.commons.data.CmisExtensionElement Java Examples
The following examples show how to use
org.apache.chemistry.opencmis.commons.data.CmisExtensionElement.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LDRepository.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
/** * Adds LogicalDOC specific extensions. Here we put the current SID. * * @param repoInfo The repository info to process */ private void setupExtensions(RepositoryInfoImpl repoInfo) { // Important: use this namespace for the extensions that must be // different from the CMIS // namespaces String ns = "http://www.logicaldoc.com"; // create a list for the first level of our extension List<CmisExtensionElement> extElements = new ArrayList<CmisExtensionElement>(); // add two leafs to the extension extElements.add(new CmisExtensionElementImpl(ns, "sid", null, this.sid)); // set the extension list List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>(); extensions.add(new CmisExtensionElementImpl(ns, "LogicaldocExtension", null, extElements)); repoInfo.setExtensions(extensions); }
Example #2
Source File: Converter.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * Converts a CMIS extension element to a DOM node * * @param source the source extension * @param parent the parent element * @param doc the current document * * @return the DOM node */ private static Node convertCmisExtensionElementToNode(CmisExtensionElement source, Element parent, Document doc) { if (source == null) { return null; } Element element = doc.createElementNS( (source.getNamespace() == null ? DEFAULT_EXTENSION_NS : source.getNamespace()), source.getName()); if (source.getValue() != null) { element.appendChild(doc.createTextNode(source.getValue())); } else { for (CmisExtensionElement child : source.getChildren()) { element.appendChild(convertCmisExtensionElementToNode(child, element, doc)); } } // set attributes if (source.getAttributes() != null) { for (Map.Entry<String, String> e : source.getAttributes().entrySet()) { element.setAttributeNS((source.getNamespace() == null ? DEFAULT_EXTENSION_NS : source.getNamespace()), e.getKey(), e.getValue()); } } return element; }
Example #3
Source File: CMISTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * ALF-20389 Test Alfresco cmis stream interceptor that checks content stream for mimetype. Only ContentStreamImpl extensions should take palace. */ @Test public void testGetRepositoryInfos() { boolean cmisEx = false; List<RepositoryInfo> infoDataList = null; try { infoDataList = withCmisService(new CmisServiceCallback<List<RepositoryInfo>>() { @Override public List<RepositoryInfo> execute(CmisService cmisService) { ExtensionDataImpl result = new ExtensionDataImpl(); List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>(); result.setExtensions(extensions); return cmisService.getRepositoryInfos(result); } }); } catch (CmisRuntimeException e) { cmisEx = true; } assertNotNull(cmisEx ? "CmisRuntimeException was thrown. Please, take a look on ALF-20389" : "No CMIS repository information was retrieved", infoDataList); }
Example #4
Source File: CMISDictionaryRegistryImpl.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
private void addTypeExtensions(TypeDefinitionWrapper td) { QName classQName = td.getAlfrescoClass(); ClassDefinition classDef = dictionaryService.getClass(classQName); if(classDef != null) { // add mandatory/default aspects List<AspectDefinition> defaultAspects = classDef.getDefaultAspects(true); if(defaultAspects != null && defaultAspects.size() > 0) { List<CmisExtensionElement> mandatoryAspectsExtensions = new ArrayList<CmisExtensionElement>(); for(AspectDefinition aspectDef : defaultAspects) { QName aspectQName = aspectDef.getName(); TypeDefinitionWrapper aspectType = getTypeDefByQName(cmisMapping.getCmisType(aspectQName)); if (aspectType == null) { continue; } mandatoryAspectsExtensions.add(new CmisExtensionElementImpl(ALFRESCO_EXTENSION_NAMESPACE, MANDATORY_ASPECT, null, aspectType.getTypeId())); } if(!mandatoryAspectsExtensions.isEmpty()) { td.getTypeDefinition(true).setExtensions( Collections.singletonList((CmisExtensionElement) new CmisExtensionElementImpl( ALFRESCO_EXTENSION_NAMESPACE, MANDATORY_ASPECTS, null, mandatoryAspectsExtensions))); } } } }
Example #5
Source File: RepoService.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
private Properties getProperties(NodeRef nodeRef) { CMISNodeInfoImpl nodeInfo = cmisConnector.createNodeInfo(nodeRef); final Properties properties = cmisConnector.getNodeProperties(nodeInfo, null); // fake the title property, which CMIS doesn't give us String title = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_TITLE); final PropertyStringImpl titleProp = new PropertyStringImpl(ContentModel.PROP_TITLE.toString(), title); Properties wrapProperties = new Properties() { @Override public List<CmisExtensionElement> getExtensions() { return properties.getExtensions(); } @Override public void setExtensions(List<CmisExtensionElement> extensions) { properties.setExtensions(extensions); } @Override public Map<String, PropertyData<?>> getProperties() { Map<String, PropertyData<?>> updatedProperties = new HashMap<String, PropertyData<?>>(properties.getProperties()); updatedProperties.put(titleProp.getId(), titleProp); return updatedProperties; } @Override public List<PropertyData<?>> getPropertyList() { List<PropertyData<?>> propertyList = new ArrayList<PropertyData<?>>(properties.getPropertyList()); propertyList.add(titleProp); return propertyList; } }; return wrapProperties; }
Example #6
Source File: CMISConnector.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@SuppressWarnings("unchecked") private ObjectData createCMISObjectImpl(final CMISNodeInfo info, Properties nodeProps, String filter, boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, boolean includePolicyIds, boolean includeAcl) { final ObjectDataImpl result = new ObjectDataImpl(); // set allowable actions if (includeAllowableActions) { result.setAllowableActions(getAllowableActions(info)); } // set policy ids if (includePolicyIds) { result.setPolicyIds(new PolicyIdListImpl()); } if (info.isRelationship()) { // set properties result.setProperties(getAssocProperties(info, filter)); // set ACL if (includeAcl) { // association have no ACL - return an empty list of ACEs result.setAcl(new AccessControlListImpl((List<Ace>) Collections.EMPTY_LIST)); result.setIsExactAcl(Boolean.FALSE); } } else { // set properties result.setProperties(nodeProps); // set relationships if (includeRelationships != IncludeRelationships.NONE) { result.setRelationships(getRelationships(info.getNodeRef(), includeRelationships)); } // set renditions if (!RENDITION_NONE.equals(renditionFilter)) { List<RenditionData> renditions = getRenditions(info.getNodeRef(), renditionFilter, null, null); if ((renditions != null) && (!renditions.isEmpty())) { result.setRenditions(renditions); } else { result.setRenditions(Collections.EMPTY_LIST); } } // set ACL if (includeAcl) { AuthenticationUtil.runAsSystem(new RunAsWork<Void>() { @Override public Void doWork() throws Exception { Acl acl = getACL(info.getCurrentNodeNodeRef(), false); if (acl != null) { result.setAcl(acl); result.setIsExactAcl(acl.isExact()); } return null; } }); } // add aspects List<CmisExtensionElement> extensions = getAspectExtensions(info, filter, result.getProperties() .getProperties().keySet()); if (!extensions.isEmpty()) { result.getProperties().setExtensions( Collections.singletonList((CmisExtensionElement) new CmisExtensionElementImpl( ALFRESCO_EXTENSION_NAMESPACE, ASPECTS, null, extensions))); } } return result; }
Example #7
Source File: CMISConnector.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Builds aspect extension. */ public List<CmisExtensionElement> getAspectExtensions(CMISNodeInfo info, String filter, Set<String> alreadySetProperties) { List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>(); Set<String> propertyIds = new HashSet<String>(alreadySetProperties); List<CmisExtensionElement> propertyExtensionList = new ArrayList<CmisExtensionElement>(); Set<String> filterSet = splitFilter(filter); Set<QName> aspects = info.getNodeAspects(); for (QName aspect : aspects) { TypeDefinitionWrapper aspectType = getOpenCMISDictionaryService().findNodeType(aspect); if (aspectType == null) { continue; } AspectDefinition aspectDefinition = dictionaryService.getAspect(aspect); Map<QName, org.alfresco.service.cmr.dictionary.PropertyDefinition> aspectProperties = aspectDefinition.getProperties(); extensions.add(new CmisExtensionElementImpl(ALFRESCO_EXTENSION_NAMESPACE, APPLIED_ASPECTS, null, aspectType .getTypeId())); for (PropertyDefinitionWrapper propDef : aspectType.getProperties()) { boolean addPropertyToExtensionList = getRequestCmisVersion().equals(CmisVersion.CMIS_1_1) && aspectProperties.keySet().contains(propDef.getAlfrescoName()); // MNT-11876 : add property to extension even if it has been returned (CMIS 1.1) if (propertyIds.contains(propDef.getPropertyId()) && !addPropertyToExtensionList) { // skip properties that have already been added continue; } if ((filterSet != null) && (!filterSet.contains(propDef.getPropertyDefinition().getQueryName()))) { // skip properties that are not in the filter continue; } Serializable value = propDef.getPropertyAccessor().getValue(info); propertyExtensionList.add(createAspectPropertyExtension(propDef.getPropertyDefinition(), value)); // mark property as 'added' propertyIds.add(propDef.getPropertyId()); } } if (!propertyExtensionList.isEmpty()) { CmisExtensionElementImpl propertiesExtension = new CmisExtensionElementImpl( ALFRESCO_EXTENSION_NAMESPACE, "properties", null, propertyExtensionList); extensions.addAll(Collections.singletonList(propertiesExtension)); } return extensions; }
Example #8
Source File: CMISConnector.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Creates a property extension element. */ @SuppressWarnings("rawtypes") private CmisExtensionElement createAspectPropertyExtension(PropertyDefinition<?> propertyDefinition, Object value) { String name; switch (propertyDefinition.getPropertyType()) { case BOOLEAN: name = "propertyBoolean"; break; case DATETIME: name = "propertyDateTime"; break; case DECIMAL: name = "propertyDecimal"; break; case INTEGER: name = "propertyInteger"; break; case ID: name = "propertyId"; break; default: name = "propertyString"; } Map<String, String> attributes = new HashMap<String, String>(); attributes.put("propertyDefinitionId", propertyDefinition.getId()); attributes.put("queryName", propertyDefinition.getQueryName()); // optional value if (propertyDefinition.getDisplayName() !=null && propertyDefinition.getDisplayName().trim().length() > 0) { attributes.put("displayName", propertyDefinition.getDisplayName()); } // optional value if (propertyDefinition.getLocalName() !=null && propertyDefinition.getLocalName().trim().length() > 0) { attributes.put("localName", propertyDefinition.getLocalName()); } List<CmisExtensionElement> propertyValues = new ArrayList<CmisExtensionElement>(); if (value != null) { if (value instanceof List) { for (Object o : ((List) value)) { if(o != null) { propertyValues.add(new CmisExtensionElementImpl(CMIS_NAMESPACE, "value", null, convertAspectPropertyValue(o))); } else { logger.warn("Unexpected null entry in list value for property " + propertyDefinition.getDisplayName() + ", value = " + value); } } } else { propertyValues.add(new CmisExtensionElementImpl(CMIS_NAMESPACE, "value", null, convertAspectPropertyValue(value))); } } return new CmisExtensionElementImpl(CMIS_NAMESPACE, name, attributes, propertyValues); }
Example #9
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 4 votes |
@Transactional public ContentStream getContentStream(CmisRepositoryConfiguration config, String objectId, String streamId, BigInteger offset, BigInteger length, ExtensionsData extension) { Object object = getObjectInternal(config, objectId, Collections.EMPTY_SET, false, IncludeRelationships.NONE, "", false, false, extension); if (object != null) { return new ContentStream() { @Override public long getLength() { return CmisServiceBridge.contentLength(object); } @Override public BigInteger getBigLength() { return BigInteger.valueOf(CmisServiceBridge.contentLength(object)); } @Override public String getMimeType() { Object mimeType = BeanUtils.getFieldWithAnnotation(object, MimeType.class); return (mimeType != null) ? mimeType.toString() : null; } @Override public String getFileName() { return null; } @Override public InputStream getStream() { return config.cmisDocumentStorage().getContent(object); } @Override public List<CmisExtensionElement> getExtensions() { return null; } @Override public void setExtensions(List<CmisExtensionElement> extensions) { } }; } return null; }
Example #10
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public List<CmisExtensionElement> getExtensions(ExtensionLevel level) { // TODO Auto-generated method stub return null; }
Example #11
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public ContentStream getContentStream(String streamId) { return new ContentStream() { @Override public void setExtensions(List<CmisExtensionElement> extensions) { // TODO Auto-generated method stub } @Override public List<CmisExtensionElement> getExtensions() { // TODO Auto-generated method stub return null; } @Override public InputStream getStream() { // TODO Auto-generated method stub return new ByteArrayInputStream("dummy_stream".getBytes()); } @Override public String getMimeType() { // TODO Auto-generated method stub return "text/xml"; } @Override public long getLength() { // TODO Auto-generated method stub return 0; } @Override public String getFileName() { // TODO Auto-generated method stub return null; } @Override public BigInteger getBigLength() { // TODO Auto-generated method stub return null; } }; }