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

The following examples show how to use org.alfresco.service.cmr.model.FileNotFoundException. 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
/**
 * Modifies (if required) the leaf folder name in the {@code homeFolderPath} by
 * appending {@code "-N"} (where N is an integer starting with 1), so that a
 * new folder will be created.
 * @param root folder.
 * @param homeFolderPath the full path. Only the final element is used.
 */
public void modifyHomeFolderNameIfItExists(NodeRef root, List<String> homeFolderPath)
{
    int n = 0;
    int last = homeFolderPath.size()-1;
    String name = homeFolderPath.get(last);
    String homeFolderName = name;
    try
    {
        do
        {
            if (n > 0)
            {
                homeFolderName = name+'-'+n;
                homeFolderPath.set(last, homeFolderName);
            }
            n++;
        } while (fileFolderService.resolveNamePath(root, homeFolderPath, false) != null);
    }
    catch (FileNotFoundException e)
    {
        // Should not be thrown as call to resolveNamePath passes in false
    }
}
 
Example 2
/**
 * @see org.alfresco.service.cmr.site.SiteService#getContainer(java.lang.String, String)
 */
public NodeRef getContainer(String shortName, String componentId)
{
    ParameterCheck.mandatoryString("componentId", componentId);

    // retrieve site
    NodeRef siteNodeRef = getSiteNodeRef(shortName);
    if (siteNodeRef == null)
    {
       throw new SiteDoesNotExistException(shortName);
    }

    // retrieve component folder within site
    // NOTE: component id is used for folder name
    NodeRef containerNodeRef = null;
    try
    {
        containerNodeRef = findContainer(siteNodeRef, componentId);
    } 
    catch (FileNotFoundException e)
    {
        //NOOP
    }

    return containerNodeRef;
}
 
Example 3
/**
 * Appends message to the folder.
 * 
 * @param message - message.
 * @param flags - message flags.
 * @param internalDate - not used. Current date used instead.
 */
@Override
protected long appendMessageInternal(
        MimeMessage message,
        Flags flags,
        Date internalDate)
        throws FileExistsException, FileNotFoundException, IOException, MessagingException 
{
    long uid;
    NodeRef sourceNodeRef = extractNodeRef(message);
    if (sourceNodeRef != null)
    {
        uid = copyOrMoveNode(this.folderInfo, message, flags, sourceNodeRef, false);
    }
    else
    {
        uid = createMimeMessageInFolder(this.folderInfo, message, flags);
    }
    // Invalidate current folder status
    this.folderStatus = null;
    return uid;
}
 
Example 4
/**
 * Copies message with the given UID to the specified {@link MailFolder}.
 * 
 * @param uid - UID of the message
 * @param toFolder - reference to the destination folder.
 * @throws MessagingException 
 * @throws IOException 
 * @throws FileNotFoundException 
 * @throws FileExistsException 
 */
@Override
protected long copyMessageInternal(
        long uid, MailFolder toFolder)
        throws MessagingException, FileExistsException, FileNotFoundException, IOException 
{
    AlfrescoImapFolder toImapMailFolder = (AlfrescoImapFolder) toFolder;

    NodeRef destFolderNodeRef = toImapMailFolder.getFolderInfo().getNodeRef();

    FileInfo sourceMessageFileInfo = searchMails().get(uid);

    if (serviceRegistry.getNodeService().hasAspect(sourceMessageFileInfo.getNodeRef(), ImapModel.ASPECT_IMAP_CONTENT))
    {
            //Generate body of message
        MimeMessage newMessage = new ImapModelMessage(sourceMessageFileInfo, serviceRegistry, true);
        return toImapMailFolder.appendMessageInternal(newMessage, imapService.getFlags(sourceMessageFileInfo), new Date());
    }
    else
    {
        String fileName = (String) serviceRegistry.getNodeService().getProperty(sourceMessageFileInfo.getNodeRef(), ContentModel.PROP_NAME);
        String newFileName = imapService.generateUniqueFilename(destFolderNodeRef, fileName);
        FileInfo messageFileInfo = serviceRegistry.getFileFolderService().copy(sourceMessageFileInfo.getNodeRef(), destFolderNodeRef, newFileName);
        return (Long)messageFileInfo.getProperties().get(ContentModel.PROP_NODE_DBID);
    }
}
 
Example 5
/**
 *  Creates the EML message in the specified folder.
 *  
 *  @param folderFileInfo The folder to create message in.
 *  @param message The original MimeMessage.
 *  @return ID of the new message created 
 * @throws FileNotFoundException 
 * @throws FileExistsException 
 * @throws MessagingException 
 * @throws IOException 
 */
private long createMimeMessageInFolder(
        FileInfo folderFileInfo,
        MimeMessage message,
        Flags flags)
        throws FileExistsException, FileNotFoundException, IOException, MessagingException 
{
    String name = AlfrescoImapConst.MESSAGE_PREFIX + GUID.generate();
    FileFolderService fileFolderService = serviceRegistry.getFileFolderService();
    FileInfo messageFile = fileFolderService.create(folderFileInfo.getNodeRef(), name, ContentModel.TYPE_CONTENT);
    final long newMessageUid = (Long) messageFile.getProperties().get(ContentModel.PROP_NODE_DBID);
    name = AlfrescoImapConst.MESSAGE_PREFIX  + newMessageUid + AlfrescoImapConst.EML_EXTENSION;
    fileFolderService.rename(messageFile.getNodeRef(), name);
    Flags newFlags = new Flags(flags);
    newFlags.add(Flag.RECENT);
    imapService.setFlags(messageFile, newFlags, true);
    
    if (extractAttachmentsEnabled)
    {
        imapService.extractAttachments(messageFile.getNodeRef(), message);
    }
    // Force persistence of the message to the repository
    new IncomingImapMessage(messageFile, serviceRegistry, message);
    return newMessageUid;        
}
 
Example 6
/**
 * @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 7
/**
 * Helper to set the 'name' property for the node.
 * 
 * @param name Name to set
 */
public void setName(String name)
{
    if (name != null)
    {
        QName typeQName = getQNameType();
        if ((services.getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_FOLDER) &&
             !services.getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_SYSTEM_FOLDER)) ||
             services.getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_CONTENT))
        {
            try
            {
               this.services.getFileFolderService().rename(this.nodeRef, name);
            }
            catch (FileNotFoundException e)
            {
                throw new AlfrescoRuntimeException("Failed to rename node " + nodeRef + " to " + name, e);
            }
        }
        this.getProperties().put(ContentModel.PROP_NAME.toString(), name.toString());
    }
}
 
Example 8
public void rename(NodeRef base, String src, String dst) 
{
    NodeRef srcRef = lookup(base, src).getFirst();
    if (srcRef == null)
    {
        throw new AlfrescoRuntimeException("Not Found: " + src);
    }
    Pair<NodeRef, String> parentChild = getParentChildRelative(base, dst);
    try
    {
        fFileFolderService.move(srcRef, parentChild.getFirst(), parentChild.getSecond());
    }
    catch (FileNotFoundException e)
    {
        throw new AlfrescoRuntimeException("Parent Not Found: " + dst, e);
    }
}
 
Example 9
/**
 * @param root - {@link NodeRef} instance, which determines <code>Alfresco IMAP</code> root node
 * @param actualNode - {@link NodeRef} instance, which determines mailbox in actual state
 * @throws FileNotFoundException
 */
private void assertMailboxInUserImapHomeDirectory(NodeRef root, NodeRef actualNode) throws FileNotFoundException
{
    List<String> path = fileFolderService.getNameOnlyPath(root, actualNode);

    int satisfactionFlag = 0;
    for (String element : path)
    {
        if (TEST_IMAP_FOLDER_NAME.equals(element) || USER_NAME.equals(element))
        {
            satisfactionFlag++;
        }

        if (satisfactionFlag > 1)
        {
            break;
        }
    }

    assertTrue(satisfactionFlag > 1);
}
 
Example 10
@Test
public void testFolderMissing() throws Exception
{
    try
    {
        AuthenticationUtil.pushAuthentication();
        AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
        fileFolderLoader.createFiles(
                sharedHomePath + "/Missing",
                0, 256, 1024L, 1024L, Long.MAX_VALUE, false,
                10, 256L);
        fail("Folder does not exist");
    }
    catch (AlfrescoRuntimeException e)
    {
        // Expected
        assertTrue(e.getCause() instanceof FileNotFoundException);
    }
    finally
    {
        AuthenticationUtil.popAuthentication();
    }
}
 
Example 11
/**
 * Gets the node ref for the specified path within this repo store
 * 
 * @param documentPath String
 * @return  node ref
 */
protected NodeRef findNodeRef(String documentPath)
{
    NodeRef node = null;
    try
    {
        String[] pathElements = documentPath.split("/");
        List<String> pathElementsList = Arrays.asList(pathElements);
        FileInfo file = fileService.resolveNamePath(getBaseNodeRef(), pathElementsList);
        node = file.getNodeRef();
    }
    catch (FileNotFoundException e)
    {
        // NOTE: return null
    }
    return node;
}
 
Example 12
private void rename(NodeRef nodeRef, String name)
{
    try
    {
        fileFolderService.rename(nodeRef, name);
    }
    catch (FileNotFoundException fnfe)
    {
        // convert checked exception
        throw new EntityNotFoundException(nodeRef.getId());
    }
    catch (FileExistsException fee)
    {
        // duplicate - name clash
        throw new ConstraintViolatedException("Name already exists in target parent: " + name);
    }
}
 
Example 13
/**
 * This test verifies that copying a shared node does not across the shared aspect and it's associated properties.
 * @throws IOException 
 * @throws UnsupportedEncodingException 
 * @throws JSONException 
 * @throws FileNotFoundException 
 * @throws FileExistsException 
 */
public void testCopy() throws UnsupportedEncodingException, IOException, JSONException, FileExistsException, FileNotFoundException 
{
    final int expectedStatusOK = 200;
    
    String testNodeRef = testNode.toString().replace("://", "/");

    // As user one ...
    
    // share
    Response rsp = sendRequest(new PostRequest(SHARE_URL.replace("{node_ref_3}", testNodeRef), "", APPLICATION_JSON), expectedStatusOK, USER_ONE);
    JSONObject jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString()));
    String sharedId = jsonRsp.getString("sharedId");
    assertNotNull(sharedId);
    assertEquals(22, sharedId.length()); // note: we may have to adjust/remove this check if we change length of id (or it becomes variable length)

    AuthenticationUtil.setFullyAuthenticatedUser(USER_ONE);
    FileInfo copyFileInfo = fileFolderService.copy(testNode, userOneHome, "Copied node");
    NodeRef copyNodeRef = copyFileInfo.getNodeRef();
    
    assertFalse(nodeService.hasAspect(copyNodeRef, QuickShareModel.ASPECT_QSHARE));
}
 
Example 14
@Test
public void cannotGetNodeForPathWithIncorrectCase() throws FileNotFoundException
{
    FileInfo folderInfo = fileFolderService.create(rootFolder, "my_folder", ContentModel.TYPE_FOLDER);
    fileFolderService.create(folderInfo.getNodeRef(), "my_file.txt", ContentModel.TYPE_CONTENT);
    
    try
    {
        webDAVHelper.getNodeForPath(rootFolder, "My_Folder/My_File.txt");
        fail("FileNotFoundException should have been thrown.");
    }
    catch (FileNotFoundException e)
    {
        // Got here, good.
    }
}
 
Example 15
@Test
public void cannotGetNodeForFolderPathWithIncorrectCase() throws FileNotFoundException
{
    FileInfo folderInfo = fileFolderService.create(rootFolder, "my_folder", ContentModel.TYPE_FOLDER);
    fileFolderService.create(folderInfo.getNodeRef(), "my_file.txt", ContentModel.TYPE_CONTENT);
    
    try
    {
        webDAVHelper.getNodeForPath(rootFolder, "My_Folder");
        fail("FileNotFoundException should have been thrown.");
    }
    catch (FileNotFoundException e)
    {
        // Got here, good.
    }
}
 
Example 16
protected final String getRepositoryPath(NodeRef nodeRef)
{
    String result = null;
    
    if (nodeRef != null)
    {
        List<FileInfo> pathElements = null;
        
        try
        {
            pathElements = fileFolderService.getNamePath(null, nodeRef);

            if (pathElements != null && pathElements.size() > 0)
            {
                StringBuilder temp = new StringBuilder();
                
                for (FileInfo pathElement : pathElements)
                {
                    temp.append("/");
                    temp.append(pathElement.getName());
                }
                
                result = temp.toString();
            }
        }
        catch (final FileNotFoundException fnfe)
        {
            // Do nothing
        }
    }
    
    return(result);
}
 
Example 17
/**
 * creates a tree of folder nodes based on the path elements provided.
 */
private FileInfo createTree(HomeFolderProvider2 provider, NodeRef root,
        List<String> homeFolderPath, NodeRef templateNodeRef,
        FileFolderService fileFolderService)
{
    NodeRef newParent = createNewParentIfRequired(root, homeFolderPath, fileFolderService);
    String homeFolderName = homeFolderPath.get(homeFolderPath.size()-1);
    FileInfo fileInfo;
    if (templateNodeRef == null)
    {
        fileInfo = fileFolderService.create(
                newParent,
                homeFolderName,
                ContentModel.TYPE_FOLDER);
    }
    else
    {
        try
        {
            fileInfo = fileFolderService.copy(
                    templateNodeRef,
                    newParent,
                    homeFolderName);
        }
        catch (FileNotFoundException e)
        {
            throw new PersonException("Invalid template to create home space");
        }
    }
    return fileInfo;
}
 
Example 18
/**
 * 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 19
/**
 * Persists the given field data as the name property
 * 
 * @param nodeRef The NodeRef to update the name for
 * @param fieldData The data representing the new name value
 * @param propsToPersist Map of properties to be persisted
 */
protected void processNamePropertyPersist(NodeRef nodeRef, FieldData fieldData, 
            Map<QName, Serializable> propsToPersist)
{
    // determine whether the file folder service can handle the current node
    FileInfo fileInfo = this.fileFolderService.getFileInfo(nodeRef);
    if (fileInfo != null)
    {
        try
        {
            // if the name property changes the rename method of the file folder
            // service should be called rather than updating the property directly
            this.fileFolderService.rename(nodeRef, (String) fieldData.getValue());
        }
        catch (FileExistsException fee)
        {
            // ALF-6739: Notification should be more user friendly on editing with duplicated name.
            // throwing FormException is not informative, therefore, for now we 
            // throw the captured runtime exception back, as it gives us better information.
            
            //throw new FormException("Failed to persist field '" + fieldData.getName() + "'", fee);
            throw fee;
        }
        catch (FileNotFoundException fnne)
        {
            throw new FormException("Failed to persist field '" + fieldData.getName() + "'", fnne);
        }
    }
    else
    {
        // as the file folder service can not be used just set the name property,
        // the node service will deal with the details of renaming.
        propsToPersist.put(ContentModel.PROP_NAME, (Serializable)fieldData.getValue());
    }
}
 
Example 20
/**
 * Moves the node <code>sourceNodeRef</code> extracted from the message id.
 * A part of a complex move operation.
 * 
 * @param folderInfo FileInfo
 * @param message MimeMessage
 * @param flags Flags
 * @param sourceNodeRef NodeRef
 * @return UUID of the moved node
 * @throws FileExistsException
 * @throws FileNotFoundException
 */
@SuppressWarnings("deprecation")
private long copyOrMoveNode(FileInfo folderInfo, MimeMessage message, Flags flags, NodeRef sourceNodeRef, boolean move)
        throws FileExistsException, FileNotFoundException
{
    FileFolderService fileFolderService = serviceRegistry.getFileFolderService();
    FileFilterMode.setClient(FileFilterMode.Client.imap);
    FileInfo messageFile = null;
    if (move)
    {
        fileFolderService.setHidden(sourceNodeRef, false);
        messageFile = fileFolderService.move(sourceNodeRef, folderInfo.getNodeRef(), null);
    }
    else
    {
        NodeRef newNodeRef = serviceRegistry.getCopyService().copyAndRename(sourceNodeRef, folderInfo.getNodeRef(), ContentModel.ASSOC_CONTAINS, null, false);
        fileFolderService.setHidden(newNodeRef, false);
        messageFile = fileFolderService.getFileInfo(newNodeRef);
    }
    final long newMessageUid = (Long) messageFile.getProperties().get(ContentModel.PROP_NODE_DBID);
    
    imapService.persistMessageHeaders(messageFile.getNodeRef(), message);
    
    Flags newFlags = new Flags(flags);
    newFlags.add(Flag.RECENT);
    
    imapService.setFlags(messageFile, newFlags, true);
    imapService.setFlag(messageFile, Flag.DELETED, false);
    
    return newMessageUid;
}
 
Example 21
/**
 * @see #move(NodeRef, NodeRef, String)
 */
@Override
@Extend(traitAPI=FileFolderServiceTrait.class,extensionAPI=FileFolderServiceExtension.class)
public FileInfo rename(NodeRef sourceNodeRef, String newName) throws FileExistsException, FileNotFoundException
{
    return moveOrCopy(sourceNodeRef, null, null, newName, true);
}
 
Example 22
public Document parseXMLDocument(final NodeRef root, String repoPath) throws IOException, SAXException,
        FileNotFoundException
{
    String[] pathElements = breakDownPath(repoPath);
    FileInfo file = fileService.resolveNamePath(root, Arrays.asList(pathElements));
    return XMLUtil.parse(file.getNodeRef(), contentService);
}
 
Example 23
/**
 * Get the WebDavUrl for the specified nodeRef
 * 
 * @param nodeRef the node that the webdav URL (or null)
 * @return the URL of the node in webdav or "" if a URL cannot be built.
 */
public String getWebdavUrl(NodeRef nodeRef)
{
    String url = "";
    
    if (!enabled)
    {
        return url;
    }
    
    try
    {
        QName typeName = nodeService.getType(nodeRef);
        
        if (getIsContainer(typeName) || getIsDocument(typeName))
        {
            List<String> paths = fileFolderService.getNameOnlyPath(getRootNode().getNodeForCurrentTenant(), nodeRef);
            
            // build up the webdav url
            StringBuilder path = new StringBuilder(128);
            path.append("/" + WEBDAV_PREFIX);
            
            for (int i=0; i<paths.size(); i++)
            {
                path.append("/")
                    .append(URLEncoder.encode(paths.get(i)));
            }
            url = path.toString();
        }
    }
    catch (InvalidTypeException typeErr)
    {
        // cannot build path if file is a type such as a rendition
    }
    catch (FileNotFoundException nodeErr)
    {
        // cannot build path if file no longer exists, return default
    }
    return url;
}
 
Example 24
/**
 * @return The WebDav cm:name based path to the content for the default content property
 *         (@see ContentModel.PROP_CONTENT)
 */
public String getWebdavUrl()
{
    String url = "";
    try
    {
        if (getIsContainer() || getIsDocument())
        {
            List<String> paths = this.services.getFileFolderService().getNameOnlyPath(null, getNodeRef());
            
            // build up the webdav url
            StringBuilder path = new StringBuilder(128);
            path.append("/webdav");
            
            // build up the path skipping the first path as it is the root folder
            for (int i=1; i<paths.size(); i++)
            {
                path.append("/")
                    .append(URLEncoder.encode(paths.get(i)));
            }
            url = path.toString();
        }
    }
    catch (InvalidTypeException typeErr)
    {
        // cannot build path if file is a type such as a rendition
    }
    catch (FileNotFoundException nodeErr)
    {
        // cannot build path if file no longer exists
    }
    return url;
}
 
Example 25
public Pair<NodeRef, Boolean> lookup(NodeRef base, String path) 
{
    List<String> pathList = splitPath(path);
    try 
    {
        FileInfo info = fFileFolderService.resolveNamePath(base, pathList);
        return new Pair<NodeRef, Boolean>(info.getNodeRef(), info.isFolder());
    } 
    catch (FileNotFoundException e) 
    {
        return null;
    }
}
 
Example 26
/**
 * Utility for getting the parent NodeRef of a relative path.
 * @param base The base node ref.
 * @param path The relative path.
 * @return A Pair with the parent node ref and the name of the child.
 */
private Pair<NodeRef, String> getParentChildRelative(NodeRef base, String path)
{
    List<String> pathList = splitPath(path);
    NodeRef parent;
    String name = null;
    if (pathList.size() == 1)
    {
        parent = base;
        name = pathList.get(0);
    }
    else
    {
        try
        {
            name = pathList.get(pathList.size() - 1);
            pathList.remove(pathList.size() - 1);
            FileInfo info = fFileFolderService.resolveNamePath(base, pathList);
            parent = info.getNodeRef();
        }
        catch (FileNotFoundException e)
        {
            throw new AlfrescoRuntimeException("Not Found: " + pathList, e);
        }
    }
    return new Pair<NodeRef, String>(parent, name);
}
 
Example 27
/**
 * @see org.alfresco.repo.action.executer.ActionExecuter#execute(Action, NodeRef)
 */
public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef)
{
    // ALF-17635: A move action should not fire on a working copy - wait until check in
    if (this.nodeService.exists(actionedUponNodeRef)
            && !this.nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY))
    {
        NodeRef destinationParent = (NodeRef) ruleAction.getParameterValue(PARAM_DESTINATION_FOLDER);

        // Check the destination not to be in a pending delete list
        // MNT-11695
        Set<QName> destinationAspects = nodeService.getAspects(destinationParent);
        if (destinationAspects.contains(ContentModel.ASPECT_PENDING_DELETE))
        {
            return;
        }

        try
        {
            fileFolderService.move(actionedUponNodeRef, destinationParent, null);
        }
        catch (FileNotFoundException e)
        {
            // Do nothing
        }
    }
}
 
Example 28
private final String getPathFromNode(NodeRef rootNodeRef, NodeRef nodeRef) throws FileNotFoundException
{
    // Check if the nodes are valid, or equal
    if (rootNodeRef == null || nodeRef == null)
        throw new IllegalArgumentException("Invalid node(s) in getPathFromNode call");
    
    // short cut if the path node is the root node
    if (rootNodeRef.equals(nodeRef))
        return "";
    
    // get the path elements
    List<FileInfo> pathInfos = fileFolderService.getNamePath(rootNodeRef, nodeRef);
    
    // build the path string
    StringBuilder sb = new StringBuilder(pathInfos.size() * 20);
    for (FileInfo fileInfo : pathInfos)
    {
        sb.append(PathSeperatorChar);
        sb.append(fileInfo.getName());
    }
    // done
    if (logger.isDebugEnabled())
    {
        logger.debug("Build name path for node: \n" +
                "   root: " + rootNodeRef + "\n" +
                "   target: " + nodeRef + "\n" +
                "   path: " + sb);
    }
    return sb.toString();
}
 
Example 29
public ActivityInfo getActivityInfo(NodeRef nodeRef)
{
    SiteInfo siteInfo = siteService.getSite(nodeRef);
    String siteId = (siteInfo != null ? siteInfo.getShortName() : null);
    if(siteId != null && !siteId.equals(""))
    {
        NodeRef parentNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef();
        FileInfo fileInfo = fileFolderService.getFileInfo(nodeRef);
        String name = fileInfo.getName();
        boolean isFolder = fileInfo.isFolder();
            
        NodeRef documentLibrary = siteService.getContainer(siteId, SiteService.DOCUMENT_LIBRARY);
        String parentPath = "/";
        try
        {
            parentPath = getPathFromNode(documentLibrary, parentNodeRef);
        }
        catch (FileNotFoundException error)
        {
            if (logger.isDebugEnabled())
            {
                logger.debug("No " + SiteService.DOCUMENT_LIBRARY + " container found.");
            }
        }
        
        return new ActivityInfo(nodeRef, parentPath, parentNodeRef, siteId, name, isFolder);
    }
    else
    {
        return null;
    }
}
 
Example 30
/**
 * @param user - {@link AlfrescoImapUser} instance, which determines a user who has enough permissions to rename a node
 * @param root - {@link NodeRef} instance, which determines <code>Alfresco IMAP</code> root node
 * @param targetNodePath - {@link String} value, which determines a path in IMAP notation to a node which should be renamed
 * @param targetNode - {@link FileInfo} instance, which determines a node, located at the <code>targetNodePath</code> path
 * @throws FileNotFoundException
 */
private void assertMailboxRenaming(AlfrescoImapUser user, NodeRef root, String targetNodePath, List<String> renamedNodeName, String renamedNodePath, FileInfo targetNode)
        throws FileNotFoundException
{
    AlfrescoImapFolder mailbox = imapService.getOrCreateMailbox(user, targetNodePath, true, false);
    assertNotNull(("Just created mailbox can't be received by full path via the ImapService. Path: '" + targetNodePath + "'"), mailbox);
    assertNotNull(mailbox.getFolderInfo());
    assertNotNull(mailbox.getFolderInfo().getNodeRef());

    imapService.renameMailbox(user, targetNodePath, renamedNodePath);

    NodeRef actualNode = null;

    if (null != targetNode)
    {
        FileInfo actualFileInfo = fileFolderService.resolveNamePath(root, renamedNodeName);
        assertNotNull(actualFileInfo);
        assertNotNull(actualFileInfo.getNodeRef());
        actualNode = actualFileInfo.getNodeRef();
    }
    else
    {
        mailbox = imapService.getOrCreateMailbox(user, renamedNodePath, true, false);
        assertNotNull(mailbox);
        actualNode = mailbox.getFolderInfo().getNodeRef();
    }

    assertNotNull(("Can't receive renamed node by full path: '" + renamedNodePath + "'"), actualNode);

    if (null != targetNode)
    {
        assertEquals(targetNode.getNodeRef(), actualNode);
    }
    else
    {
        assertMailboxInUserImapHomeDirectory(root, actualNode);
    }
}