/** * Prepara las propiedades para un documento o un directorio nuevo en Alfresco Propiedades para un * documento:<br> * - name<br> * - description<br> * - author<br> * - title<br> * Propiedades para un directorio:<br> * - name<br> * - description<br> * - title<br> * * @param properties HashMap con las propiedades del documento. La propiedad "name" es obligatoria * @param isDocument Indica si las propiedades pertenecen a un documento. Si es falso pertenecen a * un directorio * @return NamedValue con las propiedades del documento o directorio */ public static NamedValue[] prepareProperties( HashMap<String, String> properties, boolean isDocument) { // name is mandatory if (properties.containsKey("name") && properties.get("name") != "") { int i = 1; if (properties.containsKey("description")) i++; if (properties.containsKey("title")) i++; if (isDocument) { if (properties.containsKey("author")) i++; } NamedValue[] preparedProperties = new NamedValue[i]; i = 0; preparedProperties[i] = Utils.createNamedValue(ContentModel.PROP_NAME.toString(), properties.get("name")); i++; if (properties.containsKey("description")) { preparedProperties[i] = Utils.createNamedValue( ContentModel.PROP_DESCRIPTION.toString(), properties.get("description")); i++; } if (properties.containsKey("title")) { preparedProperties[i] = Utils.createNamedValue(ContentModel.PROP_TITLE.toString(), properties.get("title")); i++; } if (isDocument) { if (properties.containsKey("author")) { preparedProperties[i] = Utils.createNamedValue( ContentModel.PROP_AUTHOR.toPrefixString(), properties.get("author")); i++; } } return preparedProperties; } else { LOGGER.severe("The name propertie is mandatory"); } return null; }
// TODO filter CMIS properties private Properties getCMISProperties(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; }