Example usage for com.liferay.portal.kernel.repository.model Folder getFolderId

List of usage examples for com.liferay.portal.kernel.repository.model Folder getFolderId

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.repository.model Folder getFolderId.

Prototype

public long getFolderId();

Source Link

Usage

From source file:com.liferay.wiki.service.impl.WikiPageLocalServiceImpl.java

License:Open Source License

@Override
public FileEntry addPageAttachment(long userId, long nodeId, String title, String fileName, File file,
        String mimeType) throws PortalException {

    WikiPage page = getPage(nodeId, title);

    Folder folder = page.addAttachmentsFolder();

    fileName = PortletFileRepositoryUtil.getUniqueFileName(page.getGroupId(), folder.getFolderId(), fileName);

    FileEntry fileEntry = PortletFileRepositoryUtil.addPortletFileEntry(page.getGroupId(), userId,
            WikiPage.class.getName(), page.getResourcePrimKey(), WikiConstants.SERVICE_NAME,
            folder.getFolderId(), file, fileName, mimeType, true);

    if (userId == 0) {
        userId = page.getUserId();//from  w  w w .ja  v  a  2s.c  o m
    }

    JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();

    extraDataJSONObject.put("fileEntryId", fileEntry.getFileEntryId());
    extraDataJSONObject.put("fileEntryTitle", fileEntry.getTitle());
    extraDataJSONObject.put("title", page.getTitle());
    extraDataJSONObject.put("version", page.getVersion());

    SocialActivityManagerUtil.addActivity(userId, page, SocialActivityConstants.TYPE_ADD_ATTACHMENT,
            extraDataJSONObject.toString(), 0);

    return fileEntry;
}

From source file:com.liferay.wiki.service.impl.WikiPageLocalServiceImpl.java

License:Open Source License

@Override
public FileEntry addPageAttachment(long userId, long nodeId, String title, String fileName,
        InputStream inputStream, String mimeType) throws PortalException {

    WikiPage page = getPage(nodeId, title);

    Folder folder = page.addAttachmentsFolder();

    fileName = PortletFileRepositoryUtil.getUniqueFileName(page.getGroupId(), folder.getFolderId(), fileName);

    FileEntry fileEntry = PortletFileRepositoryUtil.addPortletFileEntry(page.getGroupId(), userId,
            WikiPage.class.getName(), page.getResourcePrimKey(), WikiConstants.SERVICE_NAME,
            folder.getFolderId(), inputStream, fileName, mimeType, true);

    if (userId == 0) {
        userId = page.getUserId();/*from w  w w .  j  ava2  s  .  c  om*/
    }

    JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();

    extraDataJSONObject.put("fileEntryId", fileEntry.getFileEntryId());
    extraDataJSONObject.put("fileEntryTitle", fileEntry.getTitle());
    extraDataJSONObject.put("title", page.getTitle());
    extraDataJSONObject.put("version", page.getVersion());

    SocialActivityManagerUtil.addActivity(userId, page, SocialActivityConstants.TYPE_ADD_ATTACHMENT,
            extraDataJSONObject.toString(), 0);

    return fileEntry;
}

From source file:com.liferay.wiki.web.internal.upload.PageAttachmentWikiUploadHandler.java

License:Open Source License

@Override
protected FileEntry fetchFileEntry(long userId, long groupId, long folderId, String fileName)
        throws PortalException {

    try {/*  w  w w .j  ava  2  s.co  m*/
        WikiPage page = WikiPageLocalServiceUtil.getPage(_classPK);

        Folder folder = page.addAttachmentsFolder();

        return PortletFileRepositoryUtil.getPortletFileEntry(groupId, folder.getFolderId(), fileName);
    } catch (PortalException pe) {
        return null;
    }
}

From source file:com.rivetlogic.tree.view.model.documentlibrary.DLFolder.java

License:Open Source License

public DLFolder(Folder folder) {
    this.setFolderId(folder.getFolderId());
    this.setName(folder.getName());
    this.setParentFolderId(folder.getParentFolderId());
    this.setRepositoryId(folder.getRepositoryId());
    this.deletePermission = false;
    this.updatePermission = false;
    this.rowCheckerId = String.valueOf(folder.getFolderId());
    this.rowCheckerName = Folder.class.getSimpleName();
}

From source file:cz.topolik.fsrepo.LocalFileSystemRepository.java

License:Open Source License

public Folder getFolder(long parentFolderId, String title) throws PortalException, SystemException {
    LocalFileSystemPermissionsUtil.checkFolder(getGroupId(), parentFolderId, ActionKeys.VIEW);
    Folder f = fileToFolder(new File(folderIdToFile(parentFolderId), title));
    LocalFileSystemPermissionsUtil.checkFolder(getGroupId(), f.getFolderId(), ActionKeys.VIEW);
    return f;//from w w  w  . j a v a  2s  .co m
}

From source file:cz.topolik.fsrepo.LocalFileSystemRepository.java

License:Open Source License

public List<Long> getSubfolderIds(long folderId, boolean recurse) throws SystemException {
    try {// w  ww .  j av  a 2 s . c  o  m
        LocalFileSystemPermissionsUtil.checkFolder(getGroupId(), folderId, ActionKeys.VIEW);
        List<Long> result = new ArrayList();
        List<Folder> folders = getFolders(folderId, false, 0, Integer.MAX_VALUE, null);
        for (Folder folder : folders) {
            if (LocalFileSystemPermissionsUtil.containsFolder(getGroupId(), folder.getFolderId(),
                    ActionKeys.VIEW)) {
                result.add(folder.getFolderId());
                if (recurse) {
                    result.addAll(getSubfolderIds(folder.getFolderId(), recurse));
                }
            }
        }
        return result;
    } catch (PortalException ex) {
        throw new SystemException(ex);
    }
}

From source file:cz.topolik.fsrepo.LocalFileSystemRepository.java

License:Open Source License

public Folder fileToFolder(File folder) throws SystemException, PortalException {
    try {/*from  w  w  w  .  j a  v a2 s  . c  om*/
        if (folder.getAbsolutePath().length() <= getRootFolder().getAbsolutePath().length()) {
            Folder mountFolder = DLAppLocalServiceUtil.getMountFolder(getRepositoryId());
            if (!LocalFileSystemPermissionsUtil.containsFolder(getGroupId(), mountFolder.getFolderId(),
                    ActionKeys.VIEW)) {
                return null;
            }
            return mountFolder;
        }
    } catch (FileNotFoundException ex) {
        throw new SystemException(ex.getMessage(), ex);
    }

    RepositoryEntry entry = retrieveRepositoryEntry(folder, DLFolder.class);
    if (!LocalFileSystemPermissionsUtil.containsFolder(getGroupId(), entry.getRepositoryEntryId(),
            ActionKeys.VIEW)) {
        return null;
    }

    return new FileSystemFolder(this, entry.getUuid(), entry.getRepositoryEntryId(), folder);
}

From source file:cz.topolik.fsrepo.model.FileSystemFolder.java

License:Open Source License

public long getParentFolderId() {
    try {/*from  w  w w .j a v  a  2s  . c  o  m*/
        Folder f = getParentFolder();
        return f == null ? DLFolderConstants.DEFAULT_PARENT_FOLDER_ID : f.getFolderId();
    } catch (Exception ex) {
        ex.printStackTrace(System.err);
    }
    return DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;
}

From source file:edu.jhu.cvrg.filestore.main.Liferay61FileStorer.java

License:Apache License

@Override
public FSFolder getFolder(long folderId) throws FSException {

    try {/* w w  w  . j  a  va 2 s  . c o m*/

        Folder folder = DLAppLocalServiceUtil.getFolder(folderId);

        return new FSFolder(folder.getFolderId(), folder.getName(), folder.getParentFolderId());
    } catch (Exception e) {
        log.warn("Folder ID [" + folderId + "] does not exists.");
    }
    return null;
}

From source file:edu.jhu.cvrg.filestore.main.Liferay61FileStorer.java

License:Apache License

@Override
public List<FSFolder> getFolders(long folderId) throws FSException {
    try {//from  w w  w  .  j  av  a 2  s  .c  o  m

        List<Folder> subFolders = DLAppLocalServiceUtil.getFolders(groupId, folderId);

        if (subFolders != null) {
            List<FSFolder> fsSubFolders = new ArrayList<FSFolder>();
            for (Folder sub : subFolders) {
                fsSubFolders.add(new FSFolder(sub.getFolderId(), sub.getName(), sub.getParentFolderId()));
            }
            return fsSubFolders;
        }

    } catch (Exception e) {
        log.warn("Folder ID [" + folderId + "] does not exists.");
    }
    return null;
}