Search in sources :

Example 1 with ContentDataWithId

use of org.alfresco.repo.domain.node.ContentDataWithId in project alfresco-repository by Alfresco.

the class CMISTest method checkEncoding.

protected void checkEncoding(FileFolderService ffs, AuthenticationComponent authenticationComponent, final ObjectData objectData, String expectedEncoding) {
    // Authenticate as system to check the properties in alfresco
    authenticationComponent.setSystemUserAsCurrentUser();
    try {
        NodeRef doc1NodeRef = cmisIdToNodeRef(objectData.getId());
        doc1NodeRef.getId();
        FileInfo fileInfo = ffs.getFileInfo(doc1NodeRef);
        Map<QName, Serializable> properties2 = fileInfo.getProperties();
        ContentDataWithId contentData = (ContentDataWithId) properties2.get(QName.createQName("{http://www.alfresco.org/model/content/1.0}content"));
        String encoding = contentData.getEncoding();
        assertEquals(expectedEncoding, encoding);
    } finally {
        authenticationComponent.clearCurrentSecurityContext();
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Serializable(java.io.Serializable) FileInfo(org.alfresco.service.cmr.model.FileInfo) QName(org.alfresco.service.namespace.QName) ContentDataWithId(org.alfresco.repo.domain.node.ContentDataWithId)

Example 2 with ContentDataWithId

use of org.alfresco.repo.domain.node.ContentDataWithId in project alfresco-repository by Alfresco.

the class OpenCmisLocalTest method testEncodingForCreateContentStream.

public void testEncodingForCreateContentStream() {
    ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    FileFolderService ffs = serviceRegistry.getFileFolderService();
    // Authenticate as system
    AuthenticationComponent authenticationComponent = (AuthenticationComponent) ctx.getBean(BEAN_NAME_AUTHENTICATION_COMPONENT);
    authenticationComponent.setSystemUserAsCurrentUser();
    try {
        /* Create the document using openCmis services */
        Repository repository = getRepository("admin", "admin");
        Session session = repository.createSession();
        Folder rootFolder = session.getRootFolder();
        Document document = createDocument(rootFolder, "test_file_" + GUID.generate() + ".txt", session);
        ContentStream content = document.getContentStream();
        assertNotNull(content);
        content = document.getContentStream(BigInteger.valueOf(2), BigInteger.valueOf(4));
        assertNotNull(content);
        NodeRef doc1NodeRef = cmisIdToNodeRef(document.getId());
        FileInfo fileInfo = ffs.getFileInfo(doc1NodeRef);
        Map<QName, Serializable> properties = fileInfo.getProperties();
        ContentDataWithId contentData = (ContentDataWithId) properties.get(QName.createQName("{http://www.alfresco.org/model/content/1.0}content"));
        String encoding = contentData.getEncoding();
        assertEquals("ISO-8859-1", encoding);
    } finally {
        authenticationComponent.clearCurrentSecurityContext();
    }
}
Also used : Serializable(java.io.Serializable) QName(org.alfresco.service.namespace.QName) FileFolderService(org.alfresco.service.cmr.model.FileFolderService) Folder(org.apache.chemistry.opencmis.client.api.Folder) Document(org.apache.chemistry.opencmis.client.api.Document) ContentDataWithId(org.alfresco.repo.domain.node.ContentDataWithId) NodeRef(org.alfresco.service.cmr.repository.NodeRef) Repository(org.apache.chemistry.opencmis.client.api.Repository) ContentStream(org.apache.chemistry.opencmis.commons.data.ContentStream) AuthenticationComponent(org.alfresco.repo.security.authentication.AuthenticationComponent) FileInfo(org.alfresco.service.cmr.model.FileInfo) ServiceRegistry(org.alfresco.service.ServiceRegistry) Session(org.apache.chemistry.opencmis.client.api.Session)

Aggregations

Serializable (java.io.Serializable)2 ContentDataWithId (org.alfresco.repo.domain.node.ContentDataWithId)2 FileInfo (org.alfresco.service.cmr.model.FileInfo)2 NodeRef (org.alfresco.service.cmr.repository.NodeRef)2 QName (org.alfresco.service.namespace.QName)2 AuthenticationComponent (org.alfresco.repo.security.authentication.AuthenticationComponent)1 ServiceRegistry (org.alfresco.service.ServiceRegistry)1 FileFolderService (org.alfresco.service.cmr.model.FileFolderService)1 Document (org.apache.chemistry.opencmis.client.api.Document)1 Folder (org.apache.chemistry.opencmis.client.api.Folder)1 Repository (org.apache.chemistry.opencmis.client.api.Repository)1 Session (org.apache.chemistry.opencmis.client.api.Session)1 ContentStream (org.apache.chemistry.opencmis.commons.data.ContentStream)1