当前位置: 首页>>代码示例>>Java>>正文


Java Folder类代码示例

本文整理汇总了Java中com.liferay.portal.kernel.repository.model.Folder的典型用法代码示例。如果您正苦于以下问题:Java Folder类的具体用法?Java Folder怎么用?Java Folder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Folder类属于com.liferay.portal.kernel.repository.model包,在下文中一共展示了Folder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setFolderPermissions

import com.liferay.portal.kernel.repository.model.Folder; //导入依赖的package包/类
public static void setFolderPermissions(Folder folder) throws Exception{
	ResourcePermission resourcePermission = null;
	final Role guestMemberRole = RoleLocalServiceUtil.getRole(folder.getCompanyId(), RoleConstants.GUEST);
	final Role siteMemberRole = RoleLocalServiceUtil.getRole(folder.getCompanyId(), RoleConstants.SITE_MEMBER);
	ResourceAction resourceAction = ResourceActionLocalServiceUtil.getResourceAction(DLFolder.class.getName(), ActionKeys.VIEW);
	String[] actionIdsGuest = new String[] { ActionKeys.VIEW, ActionKeys.ACCESS };
	String[] actionIds = new String[] { ActionKeys.VIEW, ActionKeys.ACCESS, ActionKeys.SUBSCRIBE, ActionKeys.ADD_DOCUMENT, ActionKeys.UPDATE, ActionKeys.ADD_SHORTCUT, ActionKeys.ADD_SUBFOLDER, ActionKeys.PERMISSIONS, ActionKeys.DELETE };
	try{
		 ResourcePermissionLocalServiceUtil.setResourcePermissions(folder.getCompanyId(), 
				 DLFolder.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, 
				 String.valueOf(folder.getPrimaryKey()), guestMemberRole.getRoleId(), actionIdsGuest);
		 ResourcePermissionLocalServiceUtil.setResourcePermissions(folder.getCompanyId(), 
				 DLFolder.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, 
				 String.valueOf(folder.getPrimaryKey()), siteMemberRole.getRoleId(), actionIds);
	} catch (NoSuchResourcePermissionException e){
		resourcePermission = ResourcePermissionLocalServiceUtil
		.createResourcePermission(CounterLocalServiceUtil.increment());
		resourcePermission.setCompanyId(folder.getCompanyId());
		resourcePermission.setName(DLFolder.class.getName());
		resourcePermission.setScope(ResourceConstants.SCOPE_INDIVIDUAL);
		resourcePermission.setPrimKey(String.valueOf(folder.getPrimaryKey()));
		resourcePermission.setRoleId(guestMemberRole.getRoleId());
		resourcePermission.setActionIds(resourceAction.getBitwiseValue());// (ActionKeys.VIEW);
		ResourcePermissionLocalServiceUtil.addResourcePermission(resourcePermission);
	}
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:27,代码来源:DocumentUtils.java

示例2: createDocumentFolder

import com.liferay.portal.kernel.repository.model.Folder; //导入依赖的package包/类
public static Folder createDocumentFolder(final long companyId, final long groupId,
                                          final long repoId, final long userId, final Long pFolderId, final String folderName) {

    Long currentFolderId = null;
    Folder folder = null;

    // we currently dont have a folder for this naviagtion point, create one
    if (currentFolderId == null) {

        try {
            folder = findFolder(groupId, pFolderId, folderName);
            if (folder == null) {
                folder = DLAppLocalServiceUtil.addFolder(userId, repoId, pFolderId, folderName,
                        folderName, new ServiceContext());

            }
        } catch (SystemException | PortalException e) {
            e.printStackTrace();
        }

    }
    return folder;
}
 
开发者ID:mimacom,项目名称:liferay-db-setup-core,代码行数:24,代码来源:FolderUtil.java

示例3: deleteResources

import com.liferay.portal.kernel.repository.model.Folder; //导入依赖的package包/类
@Override
public void deleteResources(ActionRequest actionRequest,
		ActionResponse actionResponse, LearningActivity larn)
		throws PortalException, SystemException, DocumentException,
		IOException {
	UploadRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
	ThemeDisplay themeDisplay = (ThemeDisplay) uploadRequest.getAttribute(WebKeys.THEME_DISPLAY);
	try {
		Folder folder = DLAppLocalServiceUtil.getFolder(themeDisplay.getScopeGroupId(), 0, String.valueOf(larn.getActId()));
		java.util.List<FileEntry> files = DLAppLocalServiceUtil.getFileEntries(themeDisplay.getScopeGroupId(), folder.getFolderId());
		for(FileEntry file:files){
			DLAppLocalServiceUtil.deleteFileEntry(file.getFileEntryId());
		}
		DLAppLocalServiceUtil.deleteFolder(folder.getFolderId());
	} catch (Exception e) {
		//No existe carpeta, por lo que no hay recursos asociados que eliminar.
	}
	super.deleteResources(actionRequest, actionResponse, larn);
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:20,代码来源:ResourceInternalLearningActivityType.java

示例4: deleteSong

import com.liferay.portal.kernel.repository.model.Folder; //导入依赖的package包/类
@Indexable(type = IndexableType.DELETE)
public Song deleteSong(long songId) throws PortalException {
	Song song = songPersistence.findByPrimaryKey(songId);

	Repository repository =
		PortletFileRepositoryUtil.fetchPortletRepository(
			song.getGroupId(), Constants.JUKEBOX_PORTLET_REPOSITORY);

	if (repository != null) {
		try {
			Folder folder = PortletFileRepositoryUtil.getPortletFolder(
				0, repository.getRepositoryId(),
				DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
				String.valueOf(songId), null);

			PortletFileRepositoryUtil.deleteFolder(folder.getFolderId());
		}
		catch (Exception e) {
		}
	}

	return songPersistence.remove(songId);
}
 
开发者ID:juliocamarero,项目名称:jukebox-portlet,代码行数:24,代码来源:SongLocalServiceImpl.java

示例5: deleteSong

import com.liferay.portal.kernel.repository.model.Folder; //导入依赖的package包/类
@Indexable(type = IndexableType.DELETE)
public Song deleteSong(long songId)
	throws PortalException, SystemException {

	Song song = songPersistence.findByPrimaryKey(songId);

	Repository repository =
		PortletFileRepositoryUtil.fetchPortletRepository(
			song.getGroupId(), Constants.JUKEBOX_PORTLET_REPOSITORY);

	if (repository != null) {
		try {
			Folder folder = PortletFileRepositoryUtil.getPortletFolder(
				0, repository.getRepositoryId(),
				DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
				String.valueOf(songId), null);

			PortletFileRepositoryUtil.deleteFolder(folder.getFolderId());
		}
		catch (Exception e) {
		}
	}

	return songPersistence.remove(songId);
}
 
开发者ID:juliocamarero,项目名称:jukebox,代码行数:26,代码来源:SongLocalServiceImpl.java

示例6: findFolder

import com.liferay.portal.kernel.repository.model.Folder; //导入依赖的package包/类
public static Folder findFolder(final long company, final long groupId, final long repoId,
                                final long userId, final String name, final boolean createIfNotExists) {
    String[] folderPath = name.split("/");
    Folder foundFolder = null;
    int count = 0;
    Long parentId = 0L;
    while (count < folderPath.length) {
        String folder = folderPath[count];
        if (!folder.equals("")) {
            foundFolder = findFolder(groupId, parentId, folder);

            if (foundFolder == null && createIfNotExists) {
                foundFolder = createDocumentFolder(company, groupId, repoId, userId, parentId,
                        folder);
                SetupPermissions.updatePermission(
                        "Folder " + name + ", creating folder " + "segment " + folder, groupId,
                        company, foundFolder.getFolderId(), JournalFolder.class, null,
                        SetupWebFolders.DEFAULT_PERMISSIONS);
            }

            if (foundFolder == null) {
                break;
            }
            parentId = foundFolder.getFolderId();
        }
        count++;
    }
    return foundFolder;
}
 
开发者ID:mimacom,项目名称:liferay-db-setup-core,代码行数:30,代码来源:FolderUtil.java

示例7: setupDocumentFolders

import com.liferay.portal.kernel.repository.model.Folder; //导入依赖的package包/类
public static void setupDocumentFolders(final Site group, final long groupId, final long companyId) {
    for (DocumentFolder df : group.getDocumentFolder()) {
        boolean create = df.isCreateIfNotExists();
        String folderName = df.getFolderName();

        Folder folder = FolderUtil.findFolder(companyId, groupId, groupId, LiferaySetup.getRunAsUserId(), folderName, create);
        SetupPermissions.updatePermission("Document folder " + folderName, groupId, companyId,
                folder.getFolderId(), DLFolder.class, df.getRolePermissions(),
                DEFAULT_PERMISSIONS);
    }
}
 
开发者ID:mimacom,项目名称:liferay-db-setup-core,代码行数:12,代码来源:SetupDocumentFolders.java

示例8: createDLFolders

import com.liferay.portal.kernel.repository.model.Folder; //导入依赖的package包/类
private long createDLFolders(Long userId,Long repositoryId,PortletRequest portletRequest,long actId) throws PortalException, SystemException{
	//Variables for folder ids
	Long dlMainFolderId = 0L;
	//Search for folder in Document Library
       boolean dlMainFolderFound = false;
       //Get main folder
       try {
       	//Get main folder
       	Folder dlFolderMain = DLAppLocalServiceUtil.getFolder(repositoryId,DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,DOCUMENTLIBRARY_MAINFOLDER+actId);
       	dlMainFolderId = dlFolderMain.getFolderId();
       	dlMainFolderFound = true;
       	//Get portlet folder
       } catch (Exception ex){
       }
       
	ServiceContext serviceContext= ServiceContextFactory.getInstance( DLFolder.class.getName(), portletRequest);
	//Damos permisos al archivo para usuarios de comunidad.
	serviceContext.setAddGroupPermissions(true);
       
       //Create main folder if not exist
       if(!dlMainFolderFound){
       	Folder newDocumentMainFolder = DLAppLocalServiceUtil.addFolder(userId, repositoryId,DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, DOCUMENTLIBRARY_MAINFOLDER+actId, DOCUMENTLIBRARY_MAINFOLDER+actId, serviceContext);
       	dlMainFolderFound = true;
       	dlMainFolderId = newDocumentMainFolder.getFolderId();
       }
       //Create portlet folder if not exist
       return dlMainFolderId;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:29,代码来源:ResourceExternalLearningActivityType.java

示例9: createFoldersForLearningActivity

import com.liferay.portal.kernel.repository.model.Folder; //导入依赖的package包/类
/**
 * Primero se busca si ya existe, si existe se devuelve y sino se crea uno nuevo.
 */
private Folder createFoldersForLearningActivity(Long userId, Long groupId, Long actId, String title, ServiceContext serviceContext) throws PortalException, SystemException{
	Folder newFolder = null;
	try {
		newFolder = DLAppLocalServiceUtil.getFolder(groupId, 0, String.valueOf(actId));
	} catch (Exception e) {
		newFolder = DLAppLocalServiceUtil.addFolder(userId, groupId,0, String.valueOf(actId), title, serviceContext);
	}
   	return newFolder;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:13,代码来源:ResourceInternalLearningActivityType.java

示例10: createDLFolders

import com.liferay.portal.kernel.repository.model.Folder; //导入依赖的package包/类
private long createDLFolders(Long userId,Long repositoryId,PortletRequest portletRequest) throws PortalException, SystemException{
	//Variables for folder ids
	Long dlMainFolderId = 0L;
	//Search for folder in Document Library
       boolean dlMainFolderFound = false;
       //Get main folder
       try {
       	//Get main folder
       	Folder dlFolderMain = DLAppLocalServiceUtil.getFolder(repositoryId,DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,DOCUMENTLIBRARY_MAINFOLDER);
       	dlMainFolderId = dlFolderMain.getFolderId();
       	dlMainFolderFound = true;
       	//Get portlet folder
       } catch (Exception ex){
       }
       
	ServiceContext serviceContext= ServiceContextFactory.getInstance( DLFolder.class.getName(), portletRequest);
	//Damos permisos al archivo para usuarios de comunidad.
	serviceContext.setAddGroupPermissions(true);
       
       //Create main folder if not exist
       if(!dlMainFolderFound){
       	Folder newDocumentMainFolder = DLAppLocalServiceUtil.addFolder(userId, repositoryId,DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, DOCUMENTLIBRARY_MAINFOLDER, DOCUMENTLIBRARY_MAINFOLDER, serviceContext);
       	dlMainFolderFound = true;
       	dlMainFolderId = newDocumentMainFolder.getFolderId();
       }
       //Create portlet folder if not exist
    
 
       return dlMainFolderId;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:31,代码来源:ResourceInternalActivity.java

示例11: getFileEntry

import com.liferay.portal.kernel.repository.model.Folder; //导入依赖的package包/类
protected FileEntry getFileEntry(
	ThemeDisplay themeDisplay, String folderName) {

	Repository repository =
		PortletFileRepositoryUtil.fetchPortletRepository(
			getGroupId(), Constants.JUKEBOX_PORTLET_REPOSITORY);

	if (repository == null) {
		return null;
	}

	try {
		Folder folder = PortletFileRepositoryUtil.getPortletFolder(
			0, repository.getRepositoryId(),
			DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
			String.valueOf(getSongId()), null);

		Folder songFolder = PortletFileRepositoryUtil.getPortletFolder(
			0, repository.getRepositoryId(), folder.getFolderId(),
			folderName, null);

		List<FileEntry> fileEntries =
			PortletFileRepositoryUtil.getPortletFileEntries(
				themeDisplay.getScopeGroupId(), songFolder.getFolderId());

		if (fileEntries.isEmpty()) {
			return null;
		}

		return fileEntries.get(0);
	}
	catch (Exception e) {
		return null;
	}
}
 
开发者ID:juliocamarero,项目名称:jukebox-portlet,代码行数:36,代码来源:SongImpl.java

示例12: DLFolder

import com.liferay.portal.kernel.repository.model.Folder; //导入依赖的package包/类
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();
}
 
开发者ID:rivetlogic,项目名称:liferay-document-and-media-treeview,代码行数:11,代码来源:DLFolder.java

示例13: getFileEntry

import com.liferay.portal.kernel.repository.model.Folder; //导入依赖的package包/类
protected FileEntry getFileEntry(
		ThemeDisplay themeDisplay, String folderName)
	throws SystemException {

	Repository repository =
		PortletFileRepositoryUtil.fetchPortletRepository(
			getGroupId(), Constants.JUKEBOX_PORTLET_REPOSITORY);

	if (repository == null) {
		return null;
	}

	try {
		Folder folder = PortletFileRepositoryUtil.getPortletFolder(
			0, repository.getRepositoryId(),
			DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
			String.valueOf(getSongId()), null);

		Folder songFolder = PortletFileRepositoryUtil.getPortletFolder(
			0, repository.getRepositoryId(), folder.getFolderId(),
			folderName, null);

		List<FileEntry> fileEntries =
			PortletFileRepositoryUtil.getPortletFileEntries(
				themeDisplay.getScopeGroupId(), songFolder.getFolderId());

		if (fileEntries.isEmpty()) {
			return null;
		}

		return fileEntries.get(0);
	}
	catch (Exception e) {
		return null;
	}
}
 
开发者ID:juliocamarero,项目名称:jukebox,代码行数:37,代码来源:SongImpl.java

示例14: setFolderPermissions

import com.liferay.portal.kernel.repository.model.Folder; //导入依赖的package包/类
public static void setFolderPermissions(Folder folder)
	throws Exception {

	ResourcePermission resourcePermission = null;
	final Role guestMemberRole = RoleLocalServiceUtil.getRole(
		folder.getCompanyId(), RoleConstants.GUEST);
	final Role siteMemberRole = RoleLocalServiceUtil.getRole(
		folder.getCompanyId(), RoleConstants.SITE_MEMBER);
	ResourceAction resourceAction =
		ResourceActionLocalServiceUtil.getResourceAction(
			DLFolder.class.getName(), ActionKeys.VIEW);
	String[] actionIdsGuest = new String[] {
		ActionKeys.VIEW, ActionKeys.ACCESS
	};
	String[] actionIds = new String[] {
		ActionKeys.VIEW, ActionKeys.ACCESS, ActionKeys.SUBSCRIBE,
		ActionKeys.ADD_DOCUMENT, ActionKeys.UPDATE, ActionKeys.ADD_SHORTCUT,
		ActionKeys.ADD_SUBFOLDER, ActionKeys.PERMISSIONS, ActionKeys.DELETE
	};
	try {
		ResourcePermissionLocalServiceUtil.setResourcePermissions(
			folder.getCompanyId(), DLFolder.class.getName(),
			ResourceConstants.SCOPE_INDIVIDUAL,
			String.valueOf(folder.getPrimaryKey()),
			guestMemberRole.getRoleId(), actionIdsGuest);
		ResourcePermissionLocalServiceUtil.setResourcePermissions(
			folder.getCompanyId(), DLFolder.class.getName(),
			ResourceConstants.SCOPE_INDIVIDUAL,
			String.valueOf(folder.getPrimaryKey()),
			siteMemberRole.getRoleId(), actionIds);
	}
	catch (NoSuchResourcePermissionException e) {
		resourcePermission =
			ResourcePermissionLocalServiceUtil.createResourcePermission(
				CounterLocalServiceUtil.increment());
		resourcePermission.setCompanyId(folder.getCompanyId());
		resourcePermission.setName(DLFolder.class.getName());
		resourcePermission.setScope(ResourceConstants.SCOPE_INDIVIDUAL);
		resourcePermission.setPrimKey(
			String.valueOf(folder.getPrimaryKey()));
		resourcePermission.setRoleId(guestMemberRole.getRoleId());
		resourcePermission.setActionIds(resourceAction.getBitwiseValue());// (ActionKeys.VIEW);
		ResourcePermissionLocalServiceUtil.addResourcePermission(
			resourcePermission);
	}
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:47,代码来源:DLFolderUtil.java

示例15: setupSiteDocuments

import com.liferay.portal.kernel.repository.model.Folder; //导入依赖的package包/类
public static void setupSiteDocuments(final Site site,
                                      final long groupId, final long company) {
    for (Document doc : site.getDocument()) {
        String folderPath = doc.getDocumentFolderName();
        String documentName = doc.getDocumentFilename();
        String documentTitle = doc.getDocumentTitle();
        String extension = doc.getExtension();
        String filenameInFilesystem = doc.getFileSystemName();
        long repoId = groupId;
        long userId = LiferaySetup.getRunAsUserId();
        Long folderId = 0L;
        Folder f = null;
        if (folderPath != null && !folderPath.equals("")) {
            f = FolderUtil.findFolder(company, groupId, repoId, userId, folderPath, true);
            folderId = f.getFolderId();
        }
        FileEntry fe = DocumentUtil.findDocument(documentName, folderPath, groupId, company,
                groupId, userId);
        byte[] fileBytes = null;
        try {
            fileBytes = ResourcesUtil.getFileBytes(filenameInFilesystem);
        } catch (IOException e) {
            LOG.error("Can not read file: " + filenameInFilesystem + ". Skipping file");
            continue;
        }
        if (fileBytes != null) {
            if (fe == null) {
                fe = DocumentUtil.createDocument(company, groupId, folderId, documentName,
                        documentTitle, userId, repoId, fileBytes);
                LOG.info(documentName + " is not found! It will be created! ");
            } else {
                LOG.info(documentName + " is found! Content will be updated! ");
                DocumentUtil.updateFile(fe, fileBytes, userId,
                        documentName);
            }
            SetupPermissions.updatePermission("Document " + folderPath + "/" + documentName,
                    groupId, company, fe.getFileEntryId(), DLFileEntry.class,
                    doc.getRolePermissions(), DEFAULT_PERMISSIONS);
        }
    }
}
 
开发者ID:mimacom,项目名称:liferay-db-setup-core,代码行数:42,代码来源:SetupDocuments.java


注:本文中的com.liferay.portal.kernel.repository.model.Folder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。