Search in sources :

Example 76 with PropertyMap

use of org.alfresco.util.PropertyMap in project alfresco-repository by Alfresco.

the class XmlMetadataExtracterTest method testEmptyFile.

public void testEmptyFile() throws Exception {
    // Get an empty file
    ContentReader reader = getReader(FILE_EMPTY);
    assertTrue(reader.exists());
    // Pass it to the extracter
    PropertyMap checkProperties = new PropertyMap();
    checkProperties.put(ContentModel.PROP_TITLE, getName());
    xmlMetadataExtracter.extract(reader, checkProperties);
    // The map should be unaffected
    assertNotNull("Properties changed by empty file extraction", checkProperties.get(ContentModel.PROP_TITLE));
    assertEquals("Properties changed by empty file extraction", getName(), checkProperties.get(ContentModel.PROP_TITLE));
}
Also used : PropertyMap(org.alfresco.util.PropertyMap) FileContentReader(org.alfresco.repo.content.filestore.FileContentReader) ContentReader(org.alfresco.service.cmr.repository.ContentReader)

Example 77 with PropertyMap

use of org.alfresco.util.PropertyMap in project alfresco-repository by Alfresco.

the class XmlMetadataExtracterTest method testMalformedFile.

public void testMalformedFile() throws Exception {
    // Get an empty file
    ContentReader reader = getReader(FILE_MALFORMED);
    assertTrue(reader.exists());
    // Pass it to the extracter
    PropertyMap checkProperties = new PropertyMap();
    checkProperties.put(ContentModel.PROP_TITLE, getName());
    xmlMetadataExtracter.extract(reader, checkProperties);
    // The map should be unaffected
    assertNotNull("Properties changed by malformed file extraction", checkProperties.get(ContentModel.PROP_TITLE));
    assertEquals("Properties changed by malformed file extraction", getName(), checkProperties.get(ContentModel.PROP_TITLE));
}
Also used : PropertyMap(org.alfresco.util.PropertyMap) FileContentReader(org.alfresco.repo.content.filestore.FileContentReader) ContentReader(org.alfresco.service.cmr.repository.ContentReader)

Example 78 with PropertyMap

use of org.alfresco.util.PropertyMap in project alfresco-repository by Alfresco.

the class XmlMetadataExtracterTest method testExtractEclipseProject.

public void testExtractEclipseProject() throws Exception {
    // Load the example file
    ContentReader reader = getReader(FILE_ECLIPSE_PROJECT);
    assertTrue(reader.exists());
    // Pass it to the extracter
    PropertyMap checkProperties = new PropertyMap();
    eclipseProjectMetadataExtracter.extract(reader, checkProperties);
    // Check the values
    assertEquals("Repository", getPropertyValue(checkProperties, ContentModel.PROP_TITLE));
    assertEquals("JavaCC Nature", getPropertyValue(checkProperties, ContentModel.PROP_DESCRIPTION));
}
Also used : PropertyMap(org.alfresco.util.PropertyMap) FileContentReader(org.alfresco.repo.content.filestore.FileContentReader) ContentReader(org.alfresco.service.cmr.repository.ContentReader)

Example 79 with PropertyMap

use of org.alfresco.util.PropertyMap in project alfresco-repository by Alfresco.

the class XmlMetadataExtracterTest method testXmlMetadataExtracter.

public void testXmlMetadataExtracter() throws Exception {
    // Load the example files
    ContentReader alfrescoModelReader = getReader(FILE_ALFRESCO_MODEL);
    assertTrue(alfrescoModelReader.exists());
    ContentReader eclipseProjectReader = getReader(FILE_ECLIPSE_PROJECT);
    assertTrue(eclipseProjectReader.exists());
    // Pass the Alfresco Model xml to the extractor
    PropertyMap checkAlfrescoModelProperties = new PropertyMap();
    xmlMetadataExtracter.extract(alfrescoModelReader, checkAlfrescoModelProperties);
    // Check the values
    assertEquals("Gavin Cornwell", getPropertyValue(checkAlfrescoModelProperties, ContentModel.PROP_AUTHOR));
    assertEquals("fm:forummodel", getPropertyValue(checkAlfrescoModelProperties, ContentModel.PROP_TITLE));
    assertEquals("Forum Model", getPropertyValue(checkAlfrescoModelProperties, ContentModel.PROP_DESCRIPTION));
    // Pass the Eclipse Project xml to the extractor
    PropertyMap checkEclipseProjectProperties = new PropertyMap();
    xmlMetadataExtracter.extract(eclipseProjectReader, checkEclipseProjectProperties);
    // Check the values
    assertEquals("Repository", getPropertyValue(checkEclipseProjectProperties, ContentModel.PROP_TITLE));
    assertEquals("JavaCC Nature", getPropertyValue(checkEclipseProjectProperties, ContentModel.PROP_DESCRIPTION));
}
Also used : PropertyMap(org.alfresco.util.PropertyMap) FileContentReader(org.alfresco.repo.content.filestore.FileContentReader) ContentReader(org.alfresco.service.cmr.repository.ContentReader)

Example 80 with PropertyMap

use of org.alfresco.util.PropertyMap in project alfresco-repository by Alfresco.

the class CopyServiceImplTest method testALF11964_part2.

/**
 * Tests copying a folder that contains both a checked-out node and its working copy.
 */
public void testALF11964_part2() {
    IntegrityChecker integrityChecker = (IntegrityChecker) ctx.getBean("integrityChecker");
    PropertyMap props = new PropertyMap();
    // Need to create a potentially recursive node structure
    props.put(ContentModel.PROP_NODE_UUID, "nodeOne");
    NodeRef nodeOne = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_CONTAINER, props).getChildRef();
    props.put(ContentModel.PROP_NODE_UUID, "nodeTwo");
    NodeRef nodeTwo = nodeService.createNode(nodeOne, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_CONTENT, props).getChildRef();
    props.put(ContentModel.PROP_NODE_UUID, "nodeThree");
    NodeRef nodeThree = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_CONTAINER, props).getChildRef();
    cociService.checkout(nodeTwo);
    copyService.copy(nodeOne, nodeThree, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, true);
    integrityChecker.checkIntegrity();
}
Also used : IntegrityChecker(org.alfresco.repo.node.integrity.IntegrityChecker) NodeRef(org.alfresco.service.cmr.repository.NodeRef) PropertyMap(org.alfresco.util.PropertyMap)

Aggregations

PropertyMap (org.alfresco.util.PropertyMap)111 NodeRef (org.alfresco.service.cmr.repository.NodeRef)43 ContentWriter (org.alfresco.service.cmr.repository.ContentWriter)15 Test (org.junit.Test)14 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)13 QName (org.alfresco.service.namespace.QName)11 Serializable (java.io.Serializable)9 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)8 ContentReader (org.alfresco.service.cmr.repository.ContentReader)8 BaseSpringTest (org.alfresco.util.BaseSpringTest)8 FileContentReader (org.alfresco.repo.content.filestore.FileContentReader)7 DictionaryException (org.alfresco.service.cmr.dictionary.DictionaryException)7 ExpectedException (org.junit.rules.ExpectedException)7 ApplicationContext (org.springframework.context.ApplicationContext)7 StoreRef (org.alfresco.service.cmr.repository.StoreRef)6 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)5 NodeService (org.alfresco.service.cmr.repository.NodeService)5 Date (java.util.Date)4 HashMap (java.util.HashMap)4 ServiceRegistry (org.alfresco.service.ServiceRegistry)4