Java Code Examples for org.alfresco.service.cmr.model.FileInfo

The following examples show how to use org.alfresco.service.cmr.model.FileInfo. These examples are extracted from open source projects. 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
/**
 * Returns node Lock token in consideration of WebDav lock depth. 
 * 
 * @param nodeInfo FileInfo
 * @return String Lock token
 */
protected LockInfo getNodeLockInfo(final FileInfo nodeInfo)
{
    if (nodeInfo.getNodeRef() == null)
    {
        // TODO review - note: can be null in case of Thor root
        return new LockInfoImpl();
    }
    
    // perf optimisation - effectively run against unprotected nodeService (to bypass repeated permission checks)
    return AuthenticationUtil.runAs(new RunAsWork<LockInfo>()
    {
        public LockInfo doWork() throws Exception
        {
            return getNodeLockInfoImpl(nodeInfo);
        }
    }, AuthenticationUtil.getSystemUserName());
}
 
Example 2
/**
 * @param nodeRef NodeRef
 * @return String
 */
private String getPath(NodeRef nodeRef)
{
    StringBuilder sb = new StringBuilder();
    try
    {
        List<FileInfo> parentFileInfoList = fileFolderService.getNamePath(null, nodeRef);
        for (FileInfo fileInfo : parentFileInfoList)
        {
            sb.append('/');
            sb.append(fileInfo.getName());
        }
    }
    catch (FileNotFoundException ex)
    {
        log.info("Unexpected problem: error while calculating path to node " + nodeRef, ex);
    }
    String path = sb.toString();
    return path;
}
 
Example 3
public FileInfo asFileInfo(VirtualStore smartStore, ActualEnvironment environment, Reference reference)
            throws VirtualizationException
{
    Map<QName, Serializable> properties = smartStore.getProperties(reference);
    QName qNameType = smartStore.getType(reference);
    FileFolderServiceType type = getTrait().getType(qNameType);

    boolean isFolder = type.equals(FileFolderServiceType.FOLDER);

    NodeRef nodeRef = reference.toNodeRef();

    return getTrait().createFileInfo(nodeRef,
                                     qNameType,
                                     isFolder,
                                     false,
                                     properties);
}
 
Example 4
private void copyContentOnly(FileInfo sourceFileInfo, FileInfo destFileInfo, FileFolderService fileFolderService) throws WebDAVServerException
{
	ContentService contentService = getContentService();
    ContentReader reader = contentService.getReader(sourceFileInfo.getNodeRef(), ContentModel.PROP_CONTENT);
    if (reader == null)
    {
        // There is no content for the node if it is a folder
        if (!sourceFileInfo.isFolder())
        {
            // Non-folders should have content available.
            logger.error("Unable to get ContentReader for source node " + sourceFileInfo.getNodeRef());
            throw new WebDAVServerException(HttpServletResponse.SC_NOT_FOUND);
        }
    }
    else
    {
        ContentWriter contentWriter = contentService.getWriter(destFileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true);
        contentWriter.putContent(reader);
    }
}
 
Example 5
private void postFileFolderActivity(
            String activityType,
            String siteId,
            String tenantDomain,
            String path,
            NodeRef parentNodeRef,
            FileInfo contentNodeInfo) throws WebDAVServerException
{
    String fileName = contentNodeInfo.getName();
    NodeRef nodeRef = contentNodeInfo.getNodeRef();
    
    try
    {
        poster.postFileFolderActivity(activityType, path, tenantDomain, siteId,
                               parentNodeRef, nodeRef, fileName,
                               appTool, Client.asType(ClientType.webdav),contentNodeInfo);
    }
    catch (AlfrescoRuntimeException are)
    {
        logger.error("Failed to post activity.", are);
        throw new WebDAVServerException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
}
 
Example 6
/**
 * Round-trip of export then import will result in the imported content having the same categories
 * assigned to it as for the exported content -- provided the source and destination stores are the same.
 */
@SuppressWarnings("unchecked")
@Category(RedundantTests.class)
@Test
public void testRoundTripKeepsCategoriesWhenWithinSameStore() throws Exception
{   
    // Use a store ref that has the bootstrapped categories
    StoreRef storeRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
    NodeRef rootNode = nodeService.getRootNode(storeRef);
    
    ChildAssociationRef contentChildAssocRef = createContentWithCategories(storeRef, rootNode);
    
    // Export/import
    File acpFile = exportContent(contentChildAssocRef.getParentRef());
    FileInfo importFolderFileInfo = importContent(acpFile, rootNode);
    
    // Check categories
    NodeRef importedFileNode = fileFolderService.searchSimple(importFolderFileInfo.getNodeRef(), "test.txt");
    assertNotNull("Couldn't find imported file: test.txt", importedFileNode);
    assertTrue(nodeService.hasAspect(importedFileNode, ContentModel.ASPECT_GEN_CLASSIFIABLE));
    List<NodeRef> importedFileCategories = (List<NodeRef>)
        nodeService.getProperty(importedFileNode, ContentModel.PROP_CATEGORIES);
    assertCategoriesEqual(importedFileCategories,
                "Regions",
                "Software Document Classification");
}
 
Example 7
/**
 * Marks all messages in the folder as deleted using {@link javax.mail.Flags.Flag#DELETED} flag.
 */
@Override
public void deleteAllMessagesInternal() throws FolderException
{
    if (isReadOnly())
    {
        throw new FolderException("Can't delete all - Permission denied");
    }
    
    for (Map.Entry<Long, FileInfo> entry : searchMails().entrySet())
    {
        imapService.setFlag(entry.getValue(), Flags.Flag.DELETED, true);
        // comment out to physically remove content.
        // fileFolderService.delete(fileInfo.getNodeRef());
    }
}
 
Example 8
private void createNothingToDoScript(String scriptName)
{
    NodeRef storeRootNodeRef = nodeService.getRootNode(new StoreRef("workspace://SpacesStore"));
    NodeRef scriptFolderRef = searchService.selectNodes(storeRootNodeRef, "/app:company_home/app:dictionary/app:scripts", null, namespaceService, false).get(0);
    
    try
    {
        FileInfo fileInfo = fileFolderService.create(scriptFolderRef, scriptName, ContentModel.TYPE_CONTENT);

        ContentWriter writer = fileFolderService.getWriter(fileInfo.getNodeRef());
        assertNotNull("Writer is null", writer);
        // write some content
        String content = "function main(){}\nmain();";
        writer.putContent(content);
    }
    catch (FileExistsException exc)
    {
        // file was created before
    }
}
 
Example 9
public void testGetFlags() throws Exception
{
    NavigableMap<Long, FileInfo> fis = imapService.getFolderStatus(authenticationService.getCurrentUserName(), testImapFolderNodeRef, ImapViewMode.ARCHIVE).search;
    if (fis != null && fis.size() > 0)
    {
        FileInfo messageFileInfo = fis.firstEntry().getValue();
        
        reauthenticate(USER_NAME, USER_PASSWORD);
        
        permissionService.setPermission(testImapFolderNodeRef, anotherUserName, PermissionService.WRITE, true);
        
        imapService.setFlags(messageFileInfo, flags, true);
        
        reauthenticate(anotherUserName, anotherUserName);

        Flags fl = imapService.getFlags(messageFileInfo);
        assertTrue(fl.contains(flags));
    }
}
 
Example 10
@Test
public void testSimplestClasspathTemplate() throws Exception
{
    try
    {
        FileInfo xmlFile = createXmlFile(companyHome);
        XSLTemplateModel model = new XSLTemplateModel();
        model.put(XSLTProcessor.ROOT_NAMESPACE, XMLUtil.parse(xmlFile.getNodeRef(), contentService));

        StringWriter writer = new StringWriter();
        xsltProcessor.process("org/alfresco/repo/template/test_template1.xsl", model, writer);

        String output = writer.toString();
        
        log.debug("XSLT Processor output: " + output);
        assertEquals("Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
    }
    catch (Exception ex)
    {
        log.error("Error!", ex);
        fail();
    }
}
 
Example 11
@Test
public void testPathParseXMLDocument()
{
    String path = "path/to/xml/files";
    List<String> pathElements = Arrays.asList(path.split("/"));
    FileInfo folder = FileFolderServiceImpl.makeFolders(fileFolderService, companyHome, pathElements, ContentModel.TYPE_FOLDER);
    FileInfo file = createXmlFile(folder.getNodeRef());
    
    try
    {
        Document doc = xsltFunctions.parseXMLDocument(companyHome, path + "/" + file.getName());
        NodeList foodNodes = doc.getElementsByTagName("food");
        assertEquals(10, foodNodes.getLength());
    }
    catch (Exception ex)
    {
        log.error("Error!", ex);
        fail(ex.getMessage());
    }
}
 
Example 12
@Test
public void testSimplestStringTemplate() throws Exception
{
    try
    {
        FileInfo file = createXmlFile(companyHome);
        XSLTemplateModel model = new XSLTemplateModel();
        model.put(XSLTProcessor.ROOT_NAMESPACE, XMLUtil.parse(file.getNodeRef(), contentService));

        StringWriter writer = new StringWriter();
        xsltProcessor.processString(verySimpleXSLT, model, writer);
        String output = writer.toString();
        
        log.debug("XSLT Processor output: " + output);
        assertEquals("Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
    }
    catch (Exception ex)
    {
        log.error("Error!", ex);
        fail();
    }
}
 
Example 13
@Auditable(parameters = {"contextNodeRef", "files", "folders", "ignoreQNames", "sortProps", "pagingRequest"})
@Override
@Extend(traitAPI = FileFolderServiceTrait.class, extensionAPI = FileFolderServiceExtension.class)
public PagingResults<FileInfo> list(NodeRef contextNodeRef,
                                  boolean files,
                                  boolean folders,
                                  Set<QName> ignoreQNames,
                                  List<Pair<QName, Boolean>> sortProps,
                                  PagingRequest pagingRequest)
{
    ParameterCheck.mandatory("contextNodeRef", contextNodeRef);
    ParameterCheck.mandatory("pagingRequest", pagingRequest);
    
    Pair<Set<QName>,Set<QName>> pair = buildSearchTypesAndIgnoreAspects(files, folders, ignoreQNames);
    Set<QName> searchTypeQNames = pair.getFirst();
    Set<QName> ignoreAspectQNames = pair.getSecond();
    
    // execute query
    final CannedQueryResults<NodeRef> results = listImpl(contextNodeRef, null, searchTypeQNames, ignoreAspectQNames, sortProps, pagingRequest);
    return getPagingResults(pagingRequest, results);
}
 
Example 14
/**
 * Check the nodes to be indexed
 * 
 * @param nodes
 * @throws Exception
 */
private void checkNodes(List<FileInfo> nodes) throws Exception
{
    SearchService searchService = registry.getSearchService();
    
    boolean notFound = false;
    for (int i = 1; i <= 40; i++)
    {
        notFound = false;
        for (FileInfo fileInfo : nodes)
        {
            ResultSet resultSet = searchService.query(storeRef, SearchService.LANGUAGE_LUCENE, "PATH:\"/app:company_home//cm:" + TEST_FOLDER_NAME + "//cm:" + fileInfo.getName() + "\"");
            if (resultSet.length() == 0)
            {
                notFound = true;
                break;
            }
        }
        if (notFound)
        {
            Thread.sleep(500);
        }
        else
        {
            break;
        }
    }
    assertFalse("The content was not created or indexed correctly.", notFound);
}
 
Example 15
/**
 * Updates an existing document.
 * <p>
 * Update methods are user authenticated, so the modification of site config must be
 * allowed for the current user.
 * 
 * @param path          document path to update
 * @param content       content to update the document with
 */
@Override
protected void updateDocument(final WebScriptResponse res, String store, final String path, final InputStream content)
{
    final String runAsUser = getPathRunAsUser(path);
    AuthenticationUtil.runAs(new RunAsWork<Void>()
    {
        @SuppressWarnings("synthetic-access")
        public Void doWork() throws Exception
        {
            final String encpath = encodePath(path);
            final FileInfo fileInfo = resolveFilePath(encpath);
            if (fileInfo == null || fileInfo.isFolder())
            {
                res.setStatus(Status.STATUS_NOT_FOUND);
                return null;
            }
            
            try
            {
                ContentWriter writer = contentService.getWriter(fileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true);
                writer.putContent(content);
                if (logger.isDebugEnabled())
                    logger.debug("updateDocument: " + fileInfo.toString());
            }
            catch (AccessDeniedException ae)
            {
                res.setStatus(Status.STATUS_UNAUTHORIZED);
                throw ae;
            }
            return null;
        }
    }, runAsUser);
}
 
Example 16
private NodeRef getFolderPathImpl(
        NamespaceService namespaceService,
        NodeService nodeService,
        SearchService searchService,
        FileFolderService fileFolderService,
        boolean throwException)
{
    NodeRef pathStartNodeRef = super.resolveNodePath(namespaceService, nodeService, searchService);
    if (pathStartNodeRef == null)
    {
        return getNullOrThrowAlfrescoRuntimeExcpetion(
                "Folder path resolution requires an existing base path. \n" +
                "   Base path: " + getRootPath(), throwException);
    }
    // Just choose the root path if the folder path is empty
    if (folderPath.length() == 0)
    {
        return pathStartNodeRef;
    }
    else
    {
        List<NodeRef> nodeRefs = searchService.selectNodes(pathStartNodeRef, folderPath, null, namespaceService, true);
        if (nodeRefs.size() == 0)
        {
            return getNullOrThrowAlfrescoRuntimeExcpetion("Folder not found: " + this, throwException);
        }
        else
        {
            NodeRef nodeRef = nodeRefs.get(0);
            FileInfo folderInfo = fileFolderService.getFileInfo(nodeRef);
            if (!folderInfo.isFolder())
            {
                return getNullOrThrowAlfrescoRuntimeExcpetion("Not a folder: " + this, throwException);
            }
            return nodeRef;
        }
    }
    // Done
}
 
Example 17
private NodeRef addFile(NodeRef parentNodeRef, String filename, int depth)
{
    System.out.println(makeTabs(depth) + "Creating file " + filename + " in parent " + parentNodeRef);
    FileInfo info = fileFolderService.create(parentNodeRef, filename, ContentModel.TYPE_CONTENT);
    String name = info.getName();
    if (!name.equals(filename))
    {
        String msg = "A filename '" + filename + "' was not persisted: " + info;
        logger.error(msg);
        rollbackMessages.add(msg);
    }
    return info.getNodeRef();
}
 
Example 18
/**
 * Putting a content to a locked file
 * <p>
 * Create and lock a file by admin
 * <p>
 * Try to put the content by user
 */
@SuppressWarnings("deprecation")
@Test
public void testPutContentToLockedFIle() throws Exception
{
    FileInfo testFileInfo = fileFolderService.create(companyHomeNodeRef, "file-" + GUID.generate(), ContentModel.TYPE_CONTENT);
    lockService.lock(testFileInfo.getNodeRef(), LockType.WRITE_LOCK);
    try
    {
        AuthenticationUtil.setFullyAuthenticatedUser(USER1_NAME);
        executeMethod(WebDAV.METHOD_PUT, testFileInfo.getName(), testDataFile, null);

        fail("The PUT execution should fail with a 423 error");
    }
    catch (WebDAVServerException wse)
    {
        // The execution failed and it is expected
        assertTrue(wse.getHttpStatusCode() == WebDAV.WEBDAV_SC_LOCKED);
    }
    catch (Exception e)
    {
        fail("Failed to upload a file: " + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()));
    }
    finally
    {
        AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
        nodeService.deleteNode(testFileInfo.getNodeRef());
    }
}
 
Example 19
@Override
public PagingResults<FileInfo> list(final NodeRef contextNodeRef, final boolean files, final boolean folders,
            final String pattern, final Set<QName> ignoreQNames, final List<Pair<QName, Boolean>> sortProps,
            final PagingRequest pagingRequest)
{
    return thisService.list(contextNodeRef,
                            files,
                            folders,
                            pattern,
                            ignoreQNames,
                            sortProps,
                            pagingRequest);
}
 
Example 20
/**
 * Locate site "container" folder for component
 * 
 * @param siteNodeRef
 *            site
 * @param componentId
 *            component id
 * @return "container" node ref, if it exists
 * @throws FileNotFoundException
 */
private NodeRef findContainer(NodeRef siteNodeRef, String componentId)
        throws FileNotFoundException
{
    List<String> paths = new ArrayList<String>(1);
    paths.add(componentId);
    FileInfo fileInfo = fileFolderService.resolveNamePath(siteNodeRef,
            paths);
    if (!fileInfo.isFolder())
    {
        throw new SiteServiceException(MSG_SITE_CONTAINER_NOT_FOLDER, new Object[]{fileInfo.getName()});
    }
    return fileInfo.getNodeRef();
}
 
Example 21
@Test
public void testListWithIgnores() throws Exception
{
    NodeRef vf = createVirtualizedFolder(testRootFolder.getNodeRef(),
                                         "TestVirtualFileFolderService_testVirtualFolderVirtualChild",
                                         TEST_TEMPLATE_3_JSON_SYS_PATH);
    NodeRef node2 = nodeService.getChildByName(vf,
                                               ContentModel.ASSOC_CHILDREN,
                                               "Node2");

    final String contentName = "ContentVirtualChild";
    NodeRef contentNodeRef = createContent(node2,
                                           contentName).getChildRef();

    CheckOutCheckInService checkOutCheckInService = ctx.getBean("checkOutCheckInService",
                                                                CheckOutCheckInService.class);

    checkOutCheckInService.checkout(contentNodeRef);

    Set<QName> searchTypeQNames = Collections.emptySet();
    Set<QName> ignoreAspectQNames = Collections.singleton(ContentModel.ASPECT_CHECKED_OUT);
    List<Pair<QName, Boolean>> sortProps = Collections.<Pair<QName, Boolean>> emptyList();
    PagingRequest pagingRequest = new PagingRequest(100);
    PagingResults<FileInfo> node2List = fileAndFolderService.list(node2,
                                                                  searchTypeQNames,
                                                                  ignoreAspectQNames,
                                                                  sortProps,
                                                                  pagingRequest);

    assertEquals(1,
                 node2List.getPage().size());

}
 
Example 22
@Override
public List<FileInfo> search(NodeRef contextNodeRef, String namePattern, boolean includeSubFolders)
{
    return search(contextNodeRef,
                  namePattern,
                  true,
                  true,
                  false);
}
 
Example 23
@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 24
public SimpleStoredMessage createImapMessage(FileInfo fileInfo, boolean generateBody) throws MessagingException
{
    // TODO MER 26/11/2010- this test should really be that the content of the node is of type message/RFC822
    Long key = (Long) fileInfo.getProperties().get(ContentModel.PROP_NODE_DBID);
    if (nodeService.hasAspect(fileInfo.getNodeRef(), ImapModel.ASPECT_IMAP_CONTENT))
    {
        return new SimpleStoredMessage(new ImapModelMessage(fileInfo, serviceRegistry, generateBody), new Date(), key);
    }
    else
    {
        return new SimpleStoredMessage(new ContentModelMessage(fileInfo, serviceRegistry, generateBody), new Date(), key);
    }
}
 
Example 25
/**
 * Create a deletion activity post.
 * 
 * @param parent The FileInfo for the deleted file's parent.
 * @param deletedFile The FileInfo for the deleted file.
 * @throws WebDAVServerException 
 */
protected void postActivity(FileInfo parent, FileInfo deletedFile, String siteId) throws WebDAVServerException
{
    WebDavService davService = getDAVHelper().getServiceRegistry().getWebDavService();
    if (!davService.activitiesEnabled())
    {
        // Don't post activities if this behaviour is disabled.
        return;
    }
    
    String tenantDomain = getTenantDomain();
    
    // Check there is enough information to publish site activity.
    if (!siteId.equals(WebDAVHelper.EMPTY_SITE_ID))
    {
        SiteService siteService = getServiceRegistry().getSiteService();
        NodeRef documentLibrary = siteService.getContainer(siteId, SiteService.DOCUMENT_LIBRARY);
        String parentPath = "/";
        try
        {
            parentPath = getDAVHelper().getPathFromNode(documentLibrary, parent.getNodeRef());
        }
        catch (FileNotFoundException error)
        {
            if (logger.isDebugEnabled())
            {
                logger.debug("No " + SiteService.DOCUMENT_LIBRARY + " container found.");
            }
        }
        
        activityPoster.postFileFolderDeleted(siteId, tenantDomain, parentPath, parent, deletedFile);
    }  
}
 
Example 26
protected void checkFolder(NodeRef folderNode, String childFolderName, String pattern, int numExpectedFolders, int numExpectedFiles, ExpectedFolder[] expectedFolders, ExpectedFile[] expectedFiles)
{
    List<FileInfo> folders = getFolders(folderNode, childFolderName);
    assertEquals("", 1, folders.size());
    NodeRef folder1 = folders.get(0).getNodeRef();
    checkFiles(folder1, pattern, numExpectedFolders, numExpectedFiles, expectedFiles, expectedFolders);
}
 
Example 27
public OutputStream createFile(NodeRef base, String path) 
{
    Pair<NodeRef, String> parentChild = getParentChildRelative(base, path);
    FileInfo info = fFileFolderService.create(parentChild.getFirst(), 
                                              parentChild.getSecond(), 
                                              ContentModel.TYPE_CONTENT);
    // TODO is update supposed to be true.
    ContentWriter writer = fContentService.getWriter(info.getNodeRef(), ContentModel.PROP_CONTENT, true);
    return writer.getContentOutputStream();
}
 
Example 28
@Test
public void testImportXMLDocument() throws Exception
{
    try
    {
        FileInfo file = createXmlFile(companyHome);
        createXmlFile(companyHome, "TestTableXML.xml", testTableXml);
        FileInfo testImportTable = createXmlFile(companyHome, "TestImportTableXML.xml", testImportTableXml);

        RenditionDefinition def = renditionService.createRenditionDefinition(QName.createQName("Test"), XSLTRenderingEngine.NAME);
        def.setParameterValue(XSLTRenderingEngine.PARAM_TEMPLATE_NODE, testImportTable.getNodeRef());

        ChildAssociationRef rendition = renditionService.render(file.getNodeRef(), def);
        
        assertNotNull(rendition);
        
        ContentReader reader = contentService.getReader(rendition.getChildRef(), ContentModel.PROP_CONTENT);
        assertNotNull(reader);
        String output = reader.getContentString();
        
        log.debug("XSLT Processor output: " + output);
        Diff myDiff = new Diff("<html>\n<body>\n<h2>My CD Collection</h2>\n<table border=\"1\">\n<tr bgcolor=\"#9acd32\">\n<th>Title</th><th>Artist</th>\n</tr>\n<tr>\n<td></td><td></td>\n</tr>\n</table>\n</body>\n</html>\n", output);
        assertTrue("Pieces of XML are similar " + myDiff, myDiff.similar());
    }
    catch (Exception ex)
    {
        log.error("Error!", ex);
        fail();
    }
}
 
Example 29
public Map<String, Document> parseXMLDocuments(final String typeName, NodeRef rootNode, String repoPath)
        throws IOException, SAXException
{
    final Map<String, Document> result = new TreeMap<String, Document>();

    String[] pathElements = breakDownPath(repoPath);

    try
    {
        FileInfo file = fileService.resolveNamePath(rootNode, Arrays.asList(pathElements));

        if (file.isFolder())
        {
            QName typeQName = QName.createQName(typeName, namespaceService);
            Set<QName> types = new HashSet<QName>(dictionaryService.getSubTypes(typeQName, true));
            types.add(typeQName);
            List<ChildAssociationRef> children = nodeService.getChildAssocs(file.getNodeRef(), types);
            for (ChildAssociationRef child : children)
            {
                String name = (String) nodeService.getProperty(child.getChildRef(), ContentModel.PROP_NAME);
                Document doc = XMLUtil.parse(child.getChildRef(), contentService);
                result.put(name, doc);
            }
        }
    }
    catch (Exception ex)
    {
        log.warn("Unexpected exception caught in call to parseXMLDocuments", ex);
    }
    return result;
}
 
Example 30
/**
 * Constructs {@link AlfrescoImapFolder} object.
 * 
 * @param folderInfo - reference to the {@link FileInfo} object representing the folder.
 * @param userName - name of user (e.g. "admin" for admin user).
 * @param folderName - name of the folder.
 * @param folderPath - path of the folder.
 * @param viewMode - defines view mode. Can be one of the following: {@link ImapViewMode#ARCHIVE} or {@link ImapViewMode#VIRTUAL}.
 * @param extractAttachmentsEnabled boolean
 * @param imapService ImapService
 * @param serviceRegistry ServiceRegistry
 * @param mountPointId - id of the mount point.
 */
public AlfrescoImapFolder(
        FileInfo folderInfo,
        String userName,
        String folderName,
        String folderPath,
        ImapViewMode viewMode,
        boolean extractAttachmentsEnabled,
        ImapService imapService,
        ServiceRegistry serviceRegistry,
        int mountPointId)
{
    this(folderInfo, userName, folderName, folderPath, viewMode, imapService, serviceRegistry, null, extractAttachmentsEnabled, mountPointId);
}