org.apache.chemistry.opencmis.commons.PropertyIds Java Examples

The following examples show how to use org.apache.chemistry.opencmis.commons.PropertyIds. 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: TestCMIS.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void assertIsPwcProperty(CmisObject pwc, boolean nullExpected)
{
    boolean isPwcFound = false;
    Boolean isPwcValueTrue = null;
    for (Property<?> property : pwc.getProperties())
    {
        if ((null != property) && PropertyIds.IS_PRIVATE_WORKING_COPY.equals(property.getId()))
        {
            isPwcFound = true;
            isPwcValueTrue = property.getValue();
            break;
        }
    }

    if (nullExpected)
    {
        assertTrue(("'" + PropertyIds.IS_PRIVATE_WORKING_COPY + "' property is not null!"), !isPwcFound || (null == isPwcValueTrue));
        return;
    }

    assertTrue(("'" + PropertyIds.IS_PRIVATE_WORKING_COPY + "' property has not been found!"), isPwcFound);
    assertNotNull(("'" + PropertyIds.IS_PRIVATE_WORKING_COPY + "' property value must not be null!"), isPwcValueTrue);
    assertTrue(("'" + PropertyIds.IS_PRIVATE_WORKING_COPY + "' property value must be equal to 'true'!"), isPwcValueTrue);
}
 
Example #2
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String getNameProperty(Properties properties, String fallback)
{
    String name = getStringProperty(properties, PropertyIds.NAME);
    if ((name == null) || (name.trim().length() == 0))
    {
        if (fallback == null)
        {
            throw new CmisInvalidArgumentException("Property " + PropertyIds.NAME + " must be set!");
        }
        else
        {
            name = fallback;
        }
    }

    return name;
}
 
Example #3
Source File: FavouriteDocument.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static FavouriteDocument getDocument(String id, String guid, Properties props)
{
    FavouriteDocument document = new FavouriteDocument(id, guid);

    Map<String, PropertyData<?>> properties = props.getProperties();
    document.setName((String)properties.get(PropertyIds.NAME).getFirstValue());
    document.setTitle((String)properties.get(ContentModel.PROP_TITLE.toString()).getFirstValue());
    document.setCreatedBy((String)properties.get(PropertyIds.CREATED_BY).getFirstValue());
    document.setModifiedBy((String)properties.get(PropertyIds.LAST_MODIFIED_BY).getFirstValue());
    GregorianCalendar modifiedAt = (GregorianCalendar)properties.get(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue();
    document.setModifiedAt(modifiedAt.getTime());
    GregorianCalendar createdAt = (GregorianCalendar)properties.get(PropertyIds.CREATION_DATE).getFirstValue();
    document.setCreatedAt(createdAt.getTime());
    //document.setDescription((String)props.get(PropertyIds.DE).getFirstValue());
    document.setMimeType((String)properties.get(PropertyIds.CONTENT_STREAM_MIME_TYPE).getFirstValue());
    document.setSizeInBytes((BigInteger)properties.get(PropertyIds.CONTENT_STREAM_LENGTH).getFirstValue());
    document.setVersionLabel((String)properties.get(PropertyIds.VERSION_LABEL).getFirstValue());
    return document;
}
 
Example #4
Source File: CmisIntegrationTest.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
private void deleteAllContent() {
    Session session = createSession();
    Folder rootFolder = session.getRootFolder();
    ItemIterable<CmisObject> children = rootFolder.getChildren();
    for (CmisObject cmisObject : children) {
        if ("cmis:folder".equals(cmisObject.getPropertyValue(PropertyIds.OBJECT_TYPE_ID))) {
            List<String> notDeltedIdList = ((Folder)cmisObject)
                    .deleteTree(true, UnfileObject.DELETE, true);
            if (notDeltedIdList != null && notDeltedIdList.size() > 0) {
                throw new RuntimeException("Cannot empty repo");
            }
        } else {
            cmisObject.delete(true);
        }
    }
    session.getBinding().close();
}
 
Example #5
Source File: OpenCmisLocalTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static Document createDocument(Folder target, String newDocName, Session session)
{
    Map<String, String> props = new HashMap<String, String>();
    props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
    props.put(PropertyIds.NAME, newDocName);
    String content = "aegif Mind Share Leader Generating New Paradigms by aegif corporation.";
    byte[] buf = null;
    try
    {
        buf = content.getBytes("ISO-8859-1"); // set the encoding here for the content stream
    }
    catch (UnsupportedEncodingException e)
    {
        e.printStackTrace();
    }

    ByteArrayInputStream input = new ByteArrayInputStream(buf);

    ContentStream contentStream = session.getObjectFactory().createContentStream(newDocName, buf.length,
            "text/plain; charset=UTF-8", input); // additionally set the charset here
    // NOTE that we intentionally specified the wrong charset here (as UTF-8)
    // because Alfresco does automatic charset detection, so we will ignore this explicit request
    return target.createDocument(props, contentStream, VersioningState.MAJOR);
}
 
Example #6
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public String createRelationship(String repositoryId, Properties properties, List<String> policies, Acl addAces,
        Acl removeAces, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkProperties(properties);
    checkProperty(properties, PropertyIds.OBJECT_TYPE_ID, String.class);
    // checkProperty(properties, PropertyIds.SOURCE_ID, String.class);
    // checkProperty(properties, PropertyIds.TARGET_ID, String.class);

    try {
        return getWrappedService().createRelationship(repositoryId, properties, policies, addAces, removeAces,
                extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #7
Source File: SampleClient.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Create test document with content
 * 
 * @param target
 * @param newDocName
 */
private static void createDocument(Folder target, String newDocName) {
	Map<String, String> props = new HashMap<String, String>();
	props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
	props.put(PropertyIds.NAME, newDocName);
	props.put(TypeManager.PROP_TAGS, "tag1,tag2,tag3");
	System.out.println("This is a test document: " + newDocName);
	String content = "aegif Mind Share Leader Generating New Paradigms by aegif corporation.";
	byte[] buf = null;
	try {
		buf = content.getBytes("UTF-8");
	} catch (UnsupportedEncodingException e) {
		e.printStackTrace();
	}
	ByteArrayInputStream input = new ByteArrayInputStream(buf);
	ContentStream contentStream = session.getObjectFactory().createContentStream(newDocName, buf.length,
			"text/plain; fileNameCharset=UTF-8", input);
	target.createDocument(props, contentStream, VersioningState.NONE);
}
 
Example #8
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Checks if a child of a given type can be added to a given folder.
 */
@SuppressWarnings("unchecked")
public void checkChildObjectType(CMISNodeInfo folderInfo, String childType)
{
    TypeDefinitionWrapper targetType = folderInfo.getType();
    PropertyDefinitionWrapper allowableChildObjectTypeProperty = targetType
            .getPropertyById(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS);
    List<String> childTypes = (List<String>) allowableChildObjectTypeProperty.getPropertyAccessor().getValue(
            folderInfo);

    if ((childTypes == null) || childTypes.isEmpty())
    {
        return;
    }

    if (!childTypes.contains(childType))
    {
        throw new CmisConstraintException("Objects of type '" + childType + "' cannot be added to this folder!");
    }
}
 
Example #9
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String getObjectTypeIdProperty(Properties properties)
{
    String objectTypeId = getIdProperty(properties, PropertyIds.OBJECT_TYPE_ID);
    if ((objectTypeId == null) || (objectTypeId.trim().length() == 0))
    {
        throw new CmisInvalidArgumentException("Property " + PropertyIds.OBJECT_TYPE_ID + " must be set!");
    }

    return objectTypeId;
}
 
Example #10
Source File: CmisIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Test
public void testCmisProducer() throws Exception {
    deleteAllContent();

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
            .to("cmis://http://127.0.0.1:8080/chemistry-opencmis-server-inmemory/atom11");
        }
    });

    camelctx.start();
    try {
        ProducerTemplate template = camelctx.createProducerTemplate();

        String content = "Some content to be store";
        String rootFolderId = createSession().getRootFolder().getId();

        Map<String,Object> headers = new HashMap<>();
        headers.put(PropertyIds.CONTENT_STREAM_MIME_TYPE, "text/plain; charset=UTF-8");
        headers.put(CamelCMISConstants.CMIS_OBJECT_ID, rootFolderId);
        headers.put(CamelCMISConstants.CMIS_ACTION, CamelCMISActions.CREATE);
        headers.put(PropertyIds.NAME, "test.file");

        CmisObject object = template.requestBodyAndHeaders("direct:start", "Some content to be store", headers, CmisObject.class);
        Assert.assertNotNull(object);

        String nodeContent = getDocumentContentAsString(object.getId());
        Assert.assertEquals(content, nodeContent);
    } finally {
        camelctx.close();
    }
}
 
Example #11
Source File: CmisRepository.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the type id from a set of properties.
 */
private static String getTypeId(Properties properties) {
	PropertyData<?> typeProperty = properties.getProperties().get(PropertyIds.OBJECT_TYPE_ID);
	if (!(typeProperty instanceof PropertyId)) {
		throw new CmisInvalidArgumentException("Type id must be set!");
	}

	String typeId = ((PropertyId) typeProperty).getFirstValue();
	if (typeId == null) {
		throw new CmisInvalidArgumentException("Type id must be set!");
	}

	return typeId;
}
 
Example #12
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Gets the type id from a set of properties.
 */
private static String getTypeId(Properties properties) {
	PropertyData<?> typeProperty = properties.getProperties().get(PropertyIds.OBJECT_TYPE_ID);
	if (!(typeProperty instanceof PropertyId)) {
		throw new CmisInvalidArgumentException("Type id must be set!");
	}

	String typeId = ((PropertyId) typeProperty).getFirstValue();
	if (typeId == null) {
		throw new CmisInvalidArgumentException("Type id must be set!");
	}

	return typeId;
}
 
Example #13
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String getSourceIdProperty(Properties properties)
{
    String id = getIdProperty(properties, PropertyIds.SOURCE_ID);
    if ((id == null) || (id.trim().length() == 0))
    {
        throw new CmisInvalidArgumentException("Property " + PropertyIds.SOURCE_ID + " must be set!");
    }

    return id;
}
 
Example #14
Source File: ObjectTypeIdLuceneBuilder.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public <Q, S, E extends Throwable> Q buildLuceneGreaterThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode,
        LuceneFunction luceneFunction) throws E
{
    throw new CmisInvalidArgumentException("Property " + PropertyIds.OBJECT_TYPE_ID
            + " can not be used in a 'greater than or equals' comparison");
}
 
Example #15
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String getTargetIdProperty(Properties properties)
{
    String id = getIdProperty(properties, PropertyIds.TARGET_ID);
    if ((id == null) || (id.trim().length() == 0))
    {
        throw new CmisInvalidArgumentException("Property " + PropertyIds.TARGET_ID + " must be set!");
    }

    return id;
}
 
Example #16
Source File: TypeManager.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void addBasePropertyDefinitions(AbstractTypeDefinition type) {
	type.addPropertyDefinition(createPropDef(PropertyIds.BASE_TYPE_ID, "Base Type Id", "Base Type Id",
			PropertyType.ID, Cardinality.SINGLE, Updatability.READONLY, false, false));

	type.addPropertyDefinition(createPropDef(PropertyIds.OBJECT_ID, "Object Id", "Object Id", PropertyType.ID,
			Cardinality.SINGLE, Updatability.READONLY, false, false));

	type.addPropertyDefinition(createPropDef(PropertyIds.OBJECT_TYPE_ID, "Type Id", "Type Id", PropertyType.ID,
			Cardinality.SINGLE, Updatability.ONCREATE, false, true));

	type.addPropertyDefinition(createPropDef(PropertyIds.NAME, "Name", "Name", PropertyType.STRING,
			Cardinality.SINGLE, Updatability.READWRITE, false, true));

	type.addPropertyDefinition(createPropDef(PropertyIds.CREATED_BY, "Created By", "Created By",
			PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, false, false));

	type.addPropertyDefinition(createPropDef(PropertyIds.CREATION_DATE, "Creation Date", "Creation Date",
			PropertyType.DATETIME, Cardinality.SINGLE, Updatability.READONLY, false, false));

	type.addPropertyDefinition(createPropDef(PropertyIds.LAST_MODIFIED_BY, "Last Modified By", "Last Modified By",
			PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, false, false));

	type.addPropertyDefinition(
			createPropDef(PropertyIds.LAST_MODIFICATION_DATE, "Last Modification Date", "Last Modification Date",
					PropertyType.DATETIME, Cardinality.SINGLE, Updatability.READONLY, false, false));

	type.addPropertyDefinition(createPropDef(PropertyIds.CHANGE_TOKEN, "Change Token", "Change Token",
			PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, false, false));
}
 
Example #17
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String createFolder(String repositoryId, final Properties properties, String folderId,
        final List<String> policies, final Acl addAces, final Acl removeAces, ExtensionsData extension)
{
    checkRepositoryId(repositoryId);

    // get the parent folder node ref
    final CMISNodeInfo parentInfo = getOrCreateFolderInfo(folderId, "Folder");

    // get name and type
    final String name = connector.getNameProperty(properties, null);
    final String objectTypeId = connector.getObjectTypeIdProperty(properties);
    final TypeDefinitionWrapper type = connector.getTypeForCreate(objectTypeId, BaseTypeId.CMIS_FOLDER);

    connector.checkChildObjectType(parentInfo, type.getTypeId());

    // run transaction
    FileInfo fileInfo = connector.getFileFolderService().create(
            parentInfo.getNodeRef(), name, type.getAlfrescoClass());
    NodeRef nodeRef = fileInfo.getNodeRef();

    connector.setProperties(nodeRef, type, properties, new String[] { PropertyIds.NAME, PropertyIds.OBJECT_TYPE_ID });
    connector.applyPolicies(nodeRef, type, policies);
    connector.applyACL(nodeRef, type, addAces, removeAces);
    
    connector.getActivityPoster().postFileFolderAdded(nodeRef);

    String objectId = connector.createObjectId(nodeRef);
    return objectId;
}
 
Example #18
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void assertVersions(final NodeRef nodeRef, final String expectedVersionLabel, final VersionType expectedVersionType)
{
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<List<Void>>()
    {
        @Override
        public List<Void> execute() throws Throwable
        {
            assertTrue("Node should be versionable", nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE));
            
            Version version = versionService.getCurrentVersion(nodeRef);
            
            assertNotNull(version);
            assertEquals(expectedVersionLabel, version.getVersionLabel());
            assertEquals(expectedVersionType, version.getVersionType());
            
            return null;
        }
    });
    
    withCmisService(new CmisServiceCallback<Void>()
    {
        @Override
        public Void execute(CmisService cmisService)
        {
            String repositoryId = cmisService.getRepositoryInfos(null).get(0).getId();
            
            ObjectData data = 
                cmisService.getObjectOfLatestVersion(repositoryId, nodeRef.toString(), null, Boolean.FALSE, null, null, null, null, null, null, null);
            
            assertNotNull(data);
            
            PropertyData<?> prop = data.getProperties().getProperties().get(PropertyIds.VERSION_LABEL);
            Object versionLabelCmisValue = prop.getValues().get(0);
            
            assertEquals(expectedVersionLabel, versionLabelCmisValue);
            
            return null;
        }
    }, CmisVersion.CMIS_1_1);
}
 
Example #19
Source File: ObjectIdLuceneBuilder.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public <Q, S, E extends Throwable> Q buildLuceneGreaterThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode,
        LuceneFunction luceneFunction) throws E
{
    throw new CmisInvalidArgumentException("Property " + PropertyIds.OBJECT_ID
            + " can not be used in a 'greater than or equals' comparison");
}
 
Example #20
Source File: SampleClient.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Create test folder directly under target folder
 * 
 * @param target
 * @param createFolderName
 * @return newly created folder
 */
private static Folder createFolder(Folder target, String newFolderName) {
	Map<String, String> props = new HashMap<String, String>();
	props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
	props.put(PropertyIds.NAME, newFolderName);
	Folder newFolder = target.createFolder(props);
	return newFolder;
}
 
Example #21
Source File: CmisTypeManager.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Folder related properties.
 */
private static void addFolderPropertyDefinitions(FolderTypeDefinitionImpl type) {
	type.addPropertyDefinition(createPropDef(PropertyIds.PARENT_ID, "Parent Id", "Parent Id", PropertyType.ID, Cardinality.SINGLE,
			Updatability.READONLY, false, false));

	type.addPropertyDefinition(createPropDef(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS, "Allowed Child Object Type Ids",
			"Allowed Child Object Type Ids", PropertyType.ID, Cardinality.MULTI, Updatability.READONLY, false, false));

	type.addPropertyDefinition(createPropDef(PropertyIds.PATH, "Path", "Path", PropertyType.STRING, Cardinality.SINGLE,
			Updatability.READONLY, false, false));
}
 
Example #22
Source File: TestRemovePermissions.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 
 * @param session Session
 * @param name String
 * @return Folder
 */
private Folder createFolder(Session session, String name)
{
    Folder testFolder;
    Folder folder = session.getRootFolder();
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
    properties.put(PropertyIds.NAME, name);

    testFolder = folder.createFolder(properties);

    return testFolder;
}
 
Example #23
Source File: RuntimePropertyLuceneBuilderMapping.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void afterPropertiesSet()
{
    registerPropertyLuceneBuilder(PropertyIds.OBJECT_ID, new ObjectIdLuceneBuilder(dictionaryService));
    registerPropertyLuceneBuilder(PropertyIds.OBJECT_TYPE_ID, new ObjectTypeIdLuceneBuilder(cmisDictionaryService));
    registerPropertyLuceneBuilder(PropertyIds.BASE_TYPE_ID, new BaseTypeIdLuceneBuilder(cmisDictionaryService));
    registerPropertyLuceneBuilder(PropertyIds.CREATED_BY, new DirectLuceneBuilder(dictionaryService, ContentModel.PROP_CREATOR));
    registerPropertyLuceneBuilder(PropertyIds.CREATION_DATE, new DirectLuceneBuilder(dictionaryService, ContentModel.PROP_CREATED));
    registerPropertyLuceneBuilder(PropertyIds.LAST_MODIFIED_BY, new DirectLuceneBuilder(dictionaryService, ContentModel.PROP_MODIFIER));
    registerPropertyLuceneBuilder(PropertyIds.LAST_MODIFICATION_DATE, new DirectLuceneBuilder(dictionaryService, ContentModel.PROP_MODIFIED));
    registerPropertyLuceneBuilder(PropertyIds.CHANGE_TOKEN, new FixedValueLuceneBuilder(null));
    registerPropertyLuceneBuilder(PropertyIds.NAME, new DirectLuceneBuilder(dictionaryService, ContentModel.PROP_NAME));
    registerPropertyLuceneBuilder(PropertyIds.DESCRIPTION, new DirectLuceneBuilder(dictionaryService, ContentModel.PROP_DESCRIPTION));
    registerPropertyLuceneBuilder(PropertyIds.IS_IMMUTABLE, new NotSupportedLuceneBuilder());
    registerPropertyLuceneBuilder(PropertyIds.IS_LATEST_VERSION, new NotSupportedLuceneBuilder());
    registerPropertyLuceneBuilder(PropertyIds.IS_MAJOR_VERSION, new NotSupportedLuceneBuilder());
    registerPropertyLuceneBuilder(PropertyIds.IS_LATEST_MAJOR_VERSION, new NotSupportedLuceneBuilder());
    registerPropertyLuceneBuilder(PropertyIds.VERSION_LABEL, new NotSupportedLuceneBuilder());
    registerPropertyLuceneBuilder(PropertyIds.VERSION_SERIES_ID, new NotSupportedLuceneBuilder());
    registerPropertyLuceneBuilder(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, new NotSupportedLuceneBuilder());
    registerPropertyLuceneBuilder(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, new NotSupportedLuceneBuilder());
    registerPropertyLuceneBuilder(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, new NotSupportedLuceneBuilder());
    registerPropertyLuceneBuilder(PropertyIds.CHECKIN_COMMENT, new NotSupportedLuceneBuilder());
    registerPropertyLuceneBuilder(PropertyIds.CONTENT_STREAM_LENGTH, new ContentStreamLengthLuceneBuilder(dictionaryService));
    registerPropertyLuceneBuilder(PropertyIds.CONTENT_STREAM_MIME_TYPE, new ContentStreamMimetypeLuceneBuilder(dictionaryService));
    registerPropertyLuceneBuilder(PropertyIds.CONTENT_STREAM_ID, new NotSupportedLuceneBuilder());
    registerPropertyLuceneBuilder(PropertyIds.CONTENT_STREAM_FILE_NAME, new DirectLuceneBuilder(dictionaryService, ContentModel.PROP_NAME));
    registerPropertyLuceneBuilder(PropertyIds.PARENT_ID, new ParentLuceneBuilder(dictionaryService));
    registerPropertyLuceneBuilder(PropertyIds.PATH, new NotSupportedLuceneBuilder());
    registerPropertyLuceneBuilder(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS, new NotSupportedLuceneBuilder());
    registerPropertyLuceneBuilder(PropertyIds.SOURCE_ID, new NotSupportedLuceneBuilder());
    registerPropertyLuceneBuilder(PropertyIds.TARGET_ID, new NotSupportedLuceneBuilder());
    
    registerPropertyLuceneBuilder("alfcmis:nodeRef", new NotSupportedLuceneBuilder());
}
 
Example #24
Source File: SearchNonIndexedFields.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
    serverHealth.assertServerIsOnline();

    deployCustomModel("model/indexing-disabled-content-model.xml");
    
    dataUser.addUserToSite(testUser, testSite, UserRole.SiteContributor);

    FolderModel testFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();

    FileModel sampleFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "Sample");
    sampleFile.setName("in1-" + sampleFile.getName());

    // One field indexed and one field not indexed
    Map<String, Object> properties = new HashMap<>();
    properties.put(PropertyIds.OBJECT_TYPE_ID, "D:index:sample");
    properties.put(PropertyIds.NAME, sampleFile.getName());
    properties.put("index:indexed", "Indexed");
    properties.put("index:nonIndexed", "Not indexed");

    cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).createFile(sampleFile, properties, VersioningState.MAJOR)
            .assertThat().existsInRepo();

    sampleFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "Sample");
    sampleFile.setName("in2-" + sampleFile.getName());

    // Only one field not indexed
    properties = new HashMap<>();
    properties.put(PropertyIds.OBJECT_TYPE_ID, "D:index:sample");
    properties.put(PropertyIds.NAME, sampleFile.getName());
    properties.put("index:nonIndexed", "Not indexed");

    cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).createFile(sampleFile, properties, VersioningState.MAJOR)
            .assertThat().existsInRepo();
    
    waitForIndexing(sampleFile.getName(), true);
    
}
 
Example #25
Source File: OpenCmisLocalTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testDownloadEvent() throws InterruptedException
{
    Repository repository = getRepository("admin", "admin");
    Session session = repository.createSession();
    Folder rootFolder = session.getRootFolder();
    String docname = "mydoc-" + GUID.generate() + ".txt";
    Map<String, String> props = new HashMap<String, String>();
    {
        props.put(PropertyIds.OBJECT_TYPE_ID, "D:cmiscustom:document");
        props.put(PropertyIds.NAME, docname);
    }
    
    // content
    byte[] byteContent = "Hello from Download testing class".getBytes();
    InputStream stream = new ByteArrayInputStream(byteContent);
    ContentStream contentStream = new ContentStreamImpl(docname, BigInteger.valueOf(byteContent.length), "text/plain", stream);

    Document doc1 = rootFolder.createDocument(props, contentStream, VersioningState.MAJOR);
    NodeRef doc1NodeRef = cmisIdToNodeRef(doc1.getId());
    
    ContentStream content = doc1.getContentStream();
    assertNotNull(content);
    
    //range request
    content = doc1.getContentStream(BigInteger.valueOf(2),BigInteger.valueOf(4));
    assertNotNull(content);
}
 
Example #26
Source File: OpenCmisLocalTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void DISABLED_testBasicFileOps()
{
    Repository repository = getRepository("admin", "admin");
    Session session = repository.createSession();
    Folder rootFolder = session.getRootFolder();
    // create folder
    Map<String,String> folderProps = new HashMap<String, String>();
    {
        folderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
        folderProps.put(PropertyIds.NAME, getName() + "-" + GUID.generate());
    }
    Folder folder = rootFolder.createFolder(folderProps, null, null, null, session.getDefaultContext());
    
    Map<String, String> fileProps = new HashMap<String, String>();
    {
        fileProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
        fileProps.put(PropertyIds.NAME, "mydoc-" + GUID.generate() + ".txt");
    }
    ContentStreamImpl fileContent = new ContentStreamImpl();
    {
        ContentWriter writer = new FileContentWriter(TempFileProvider.createTempFile(getName(), ".txt"));
        writer.putContent("Ipsum and so on");
        ContentReader reader = writer.getReader();
        fileContent.setMimeType(MimetypeMap.MIMETYPE_TEXT_PLAIN);
        fileContent.setStream(reader.getContentInputStream());
    }
    folder.createDocument(fileProps, fileContent, VersioningState.MAJOR);
}
 
Example #27
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String createItem(String repositoryId, Properties properties, String folderId, List<String> policies,
        Acl addAces, Acl removeAces, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkProperties(properties);
    checkProperty(properties, PropertyIds.OBJECT_TYPE_ID, String.class);

    try {
        return getWrappedService().createItem(repositoryId, properties, folderId, policies, addAces, removeAces,
                extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #28
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String createPolicy(String repositoryId, Properties properties, String folderId, List<String> policies,
        Acl addAces, Acl removeAces, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkProperties(properties);
    checkProperty(properties, PropertyIds.OBJECT_TYPE_ID, String.class);

    try {
        return getWrappedService().createPolicy(repositoryId, properties, folderId, policies, addAces, removeAces,
                extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #29
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String createFolder(String repositoryId, Properties properties, String folderId, List<String> policies,
        Acl addAces, Acl removeAces, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkProperties(properties);
    checkProperty(properties, PropertyIds.OBJECT_TYPE_ID, String.class);
    checkId("Folder Id", folderId);

    try {
        return getWrappedService().createFolder(repositoryId, properties, folderId, policies, addAces, removeAces,
                extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #30
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String create(String repositoryId, Properties properties, String folderId, ContentStream contentStream,
        VersioningState versioningState, List<String> policies, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkProperties(properties);
    checkProperty(properties, PropertyIds.OBJECT_TYPE_ID, String.class);

    try {
        return getWrappedService().create(repositoryId, properties, folderId, contentStream, versioningState,
                policies, extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}