org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringImpl Java Examples

The following examples show how to use org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringImpl. 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 5 votes vote down vote up
private void addPropertyString(PropertiesImpl props, String typeId, Set<String> filter, String id, String value) {
	if (!checkAddProperty(props, typeId, filter, id)) {
		return;
	}
	PropertyStringImpl p = new PropertyStringImpl(id, value);
	p.setQueryName(id);
	props.addProperty(p);
}
 
Example #2
Source File: RepoService.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 #3
Source File: CmisServiceBridge.java    From spring-content with Apache License 2.0 5 votes vote down vote up
static void addPropertyString(PropertiesImpl props, TypeDefinition type, Set<String> filter, String id, String value) {
	if (!checkAddProperty(props, type, filter, id)) {
		return;
	}

	props.addProperty(new PropertyStringImpl(id, value));
}
 
Example #4
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Adds the default value of property if defined.
 */
@SuppressWarnings("unchecked")
private static boolean addPropertyDefault(PropertiesImpl props, PropertyDefinition<?> propDef) {
	if ((props == null) || (props.getProperties() == null)) {
		throw new IllegalArgumentException("Props must not be null!");
	}

	if (propDef == null) {
		return false;
	}

	List<?> defaultValue = propDef.getDefaultValue();
	if ((defaultValue != null) && (!defaultValue.isEmpty())) {
		switch (propDef.getPropertyType()) {
		case BOOLEAN:
			PropertyBooleanImpl p = new PropertyBooleanImpl(propDef.getId(), (List<Boolean>) defaultValue);
			p.setQueryName(propDef.getId());
			props.addProperty(p);
			break;
		case DATETIME:
			PropertyDateTimeImpl p1 = new PropertyDateTimeImpl(propDef.getId(),
					(List<GregorianCalendar>) defaultValue);
			p1.setQueryName(propDef.getId());
			props.addProperty(p1);
			break;
		case DECIMAL:
			PropertyDecimalImpl p3 = new PropertyDecimalImpl(propDef.getId(), (List<BigDecimal>) defaultValue);
			p3.setQueryName(propDef.getId());
			props.addProperty(p3);
			break;
		case HTML:
			PropertyHtmlImpl p4 = new PropertyHtmlImpl(propDef.getId(), (List<String>) defaultValue);
			p4.setQueryName(propDef.getId());
			props.addProperty(p4);
			break;
		case ID:
			PropertyIdImpl p5 = new PropertyIdImpl(propDef.getId(), (List<String>) defaultValue);
			p5.setQueryName(propDef.getId());
			props.addProperty(p5);
			break;
		case INTEGER:
			PropertyIntegerImpl p6 = new PropertyIntegerImpl(propDef.getId(), (List<BigInteger>) defaultValue);
			p6.setQueryName(propDef.getId());
			props.addProperty(p6);
			break;
		case STRING:
			PropertyStringImpl p7 = new PropertyStringImpl(propDef.getId(), (List<String>) defaultValue);
			p7.setQueryName(propDef.getId());
			props.addProperty(p7);
			break;
		case URI:
			PropertyUriImpl p8 = new PropertyUriImpl(propDef.getId(), (List<String>) defaultValue);
			p8.setQueryName(propDef.getId());
			props.addProperty(p8);
			break;
		default:
			throw new RuntimeException("Unknown datatype! Spec change?");
		}

		return true;
	}

	return false;
}
 
Example #5
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Test to ensure that versioning properties have default values defined in Alfresco content model.
 * Testing  <b>cm:initialVersion</b>, <b>cm:autoVersion</b> and <b>cm:autoVersionOnUpdateProps</b> properties 
 * 
 * @throws Exception
 */
@Test
public void testVersioningPropertiesHaveDefaultValue() throws Exception
{
    AuthenticationUtil.pushAuthentication();
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());

    try
    {
        // Create document via CMIS
        final NodeRef documentNodeRef = withCmisService(new CmisServiceCallback<NodeRef>()
        {
            @Override
            public NodeRef execute(CmisService cmisService)
            {
                String repositoryId = cmisService.getRepositoryInfos(null).get(0).getId();

                String rootNodeId = cmisService.getObjectByPath(repositoryId, "/", null, true, IncludeRelationships.NONE, null, false, true, null).getId();

                Collection<PropertyData<?>> propsList = new ArrayList<PropertyData<?>>();
                propsList.add(new PropertyStringImpl(PropertyIds.NAME, "Folder-" + GUID.generate()));
                propsList.add(new PropertyIdImpl(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"));

                String folderId = cmisService.createFolder(repositoryId, new PropertiesImpl(propsList), rootNodeId, null, null, null, null);

                propsList = new ArrayList<PropertyData<?>>();
                propsList.add(new PropertyStringImpl(PropertyIds.NAME, "File-" + GUID.generate()));
                propsList.add(new PropertyIdImpl(PropertyIds.OBJECT_TYPE_ID, "cmis:document"));

                String nodeId = cmisService.createDocument(repositoryId, new PropertiesImpl(propsList), folderId, null, null, null, null, null, null);

                return new NodeRef(nodeId.substring(0, nodeId.indexOf(';')));
            }
        }, CmisVersion.CMIS_1_1);

        // check versioning properties
        transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<List<Void>>()
        {
            @Override
            public List<Void> execute() throws Throwable
            {
                assertTrue(nodeService.exists(documentNodeRef));
                assertTrue(nodeService.hasAspect(documentNodeRef, ContentModel.ASPECT_VERSIONABLE));

                AspectDefinition ad = dictionaryService.getAspect(ContentModel.ASPECT_VERSIONABLE);
                Map<QName, org.alfresco.service.cmr.dictionary.PropertyDefinition> properties = ad.getProperties();

                for (QName qName : new QName[] {ContentModel.PROP_INITIAL_VERSION, ContentModel.PROP_AUTO_VERSION, ContentModel.PROP_AUTO_VERSION_PROPS})
                {
                    Serializable property = nodeService.getProperty(documentNodeRef, qName);

                    assertNotNull(property);

                    org.alfresco.service.cmr.dictionary.PropertyDefinition pd = properties.get(qName);
                    assertNotNull(pd.getDefaultValue());

                    assertEquals(property, Boolean.parseBoolean(pd.getDefaultValue()));
                }

                return null;
            }
        });
    }
    finally
    {
        AuthenticationUtil.popAuthentication();
    }
}