當前位置: 首頁>>代碼示例>>Java>>正文


Java PermissionCheckerFactoryUtil類代碼示例

本文整理匯總了Java中com.liferay.portal.kernel.security.permission.PermissionCheckerFactoryUtil的典型用法代碼示例。如果您正苦於以下問題:Java PermissionCheckerFactoryUtil類的具體用法?Java PermissionCheckerFactoryUtil怎麽用?Java PermissionCheckerFactoryUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PermissionCheckerFactoryUtil類屬於com.liferay.portal.kernel.security.permission包,在下文中一共展示了PermissionCheckerFactoryUtil類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processLifecycleEvent

import com.liferay.portal.kernel.security.permission.PermissionCheckerFactoryUtil; //導入依賴的package包/類
@Override
public void processLifecycleEvent(LifecycleEvent lifecycleEvent) throws ActionException {
	User user;
	try {
		user = PortalUtil.getUser(lifecycleEvent.getRequest());
		
		PrincipalThreadLocal.setName(user.getUserId());

		PermissionChecker permissionChecker;

		permissionChecker = PermissionCheckerFactoryUtil.create(user);

		PermissionThreadLocal.setPermissionChecker(permissionChecker);

		String friendlyUrl = user.getSiteGroups().get(0).getFriendlyURL();

		lifecycleEvent.getResponse().sendRedirect("/group" + friendlyUrl);
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}
 
開發者ID:VietOpenCPS,項目名稱:opencps-v2,代碼行數:24,代碼來源:LoginPostAction.java

示例2: updateFile

import com.liferay.portal.kernel.security.permission.PermissionCheckerFactoryUtil; //導入依賴的package包/類
public static FileEntry updateFile(long userId, long companyId, long groupId, long fileEntryId,
		InputStream inputStream, String fileName, String fileType, long fileSize, String destination, String desc,
		ServiceContext serviceContext) throws Exception {
	FileEntry fileEntry = null;

	if (inputStream != null && fileSize > 0 && Validator.isNotNull(fileName)) {

		serviceContext.setAddGroupPermissions(true);
		serviceContext.setAddGuestPermissions(true);

		User user = UserLocalServiceUtil.getUser(serviceContext.getUserId());

		PermissionChecker checker = PermissionCheckerFactoryUtil.create(user);
		PermissionThreadLocal.setPermissionChecker(checker);

		DLAppLocalServiceUtil.updateFileEntry(userId, fileEntryId, fileName, fileType,
				System.currentTimeMillis() + StringPool.DASH + fileName, desc, StringPool.BLANK, true, inputStream,
				fileSize, serviceContext);
	}

	return fileEntry;
}
 
開發者ID:VietOpenCPS,項目名稱:opencps-v2,代碼行數:23,代碼來源:FileUploadUtils.java

示例3: addFolder

import com.liferay.portal.kernel.security.permission.PermissionCheckerFactoryUtil; //導入依賴的package包/類
public static DLFolder addFolder(
	long userId, long groupId, long repositoryId, boolean mountPoint,
	long parentFolderId, String name, String description, boolean hidden,
	ServiceContext serviceContext) {

	DLFolder dlFolder = null;
	try {
		if (hasFolder(groupId, parentFolderId, name)) {
			dlFolder = DLFolderLocalServiceUtil.getFolder(
				groupId, parentFolderId, name);
			setFolderPermissions(dlFolder);
		}
		else {
			User user =
				UserLocalServiceUtil.getUser(serviceContext.getUserId());
			PermissionChecker checker =
				PermissionCheckerFactoryUtil.create(user);
			PermissionThreadLocal.setPermissionChecker(checker);
			//serviceContext.setAddGroupPermissions(true);
			//serviceContext.setAddGuestPermissions(true);

			dlFolder = DLFolderLocalServiceUtil.addFolder(
				userId, groupId, repositoryId, mountPoint, parentFolderId,
				name, description, hidden, serviceContext);

			setFolderPermissions(dlFolder);
		}

	}
	catch (Exception e) {
		_log.info(e);
	}

	return dlFolder;
}
 
開發者ID:VietOpenCPS,項目名稱:opencps-v2,代碼行數:36,代碼來源:DLFolderUtil.java

示例4: cloneFile

import com.liferay.portal.kernel.security.permission.PermissionCheckerFactoryUtil; //導入依賴的package包/類
public static FileEntry cloneFile(long userId, long groupId, long fileEntryId, 
		String destination, ServiceContext serviceContext) 
	throws Exception {
	
	FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(fileEntryId);

	serviceContext.setAddGroupPermissions(true);
	serviceContext.setAddGuestPermissions(true);

	Calendar calendar = Calendar.getInstance();

	calendar.setTime(new Date());
	
	if(Validator.isNull(destination)) {
		destination = StringPool.BLANK;
	} else if(destination.indexOf(StringPool.SLASH) < 0) {
	    destination += StringPool.SLASH;
	}

	destination += calendar.get(Calendar.YEAR) + StringPool.SLASH;
	destination += calendar.get(Calendar.MONTH) + StringPool.SLASH;
	destination += calendar.get(Calendar.DAY_OF_MONTH);

	DLFolder dlFolder = DLFolderUtil.getTargetFolder(userId, groupId, groupId, false, 0, destination,
			StringPool.BLANK, false, serviceContext);

	User user = UserLocalServiceUtil.getUser(serviceContext.getUserId());

	PermissionChecker checker = PermissionCheckerFactoryUtil.create(user);
	PermissionThreadLocal.setPermissionChecker(checker);
	
	String title = getFileName(fileEntry.getTitle());
	
	return DLAppLocalServiceUtil.addFileEntry(userId, groupId, dlFolder.getFolderId(), title,
			fileEntry.getMimeType(), System.currentTimeMillis() + StringPool.DASH + title, title,
			StringPool.BLANK, fileEntry.getContentStream(), fileEntry.getSize(), serviceContext);
}
 
開發者ID:VietOpenCPS,項目名稱:opencps-v2,代碼行數:38,代碼來源:FileUploadUtils.java

示例5: setAdminPermissionCheckerForThread

import com.liferay.portal.kernel.security.permission.PermissionCheckerFactoryUtil; //導入依賴的package包/類
/**
 * Initializes permission checker for Liferay Admin. Used to grant access to
 * custom fields.
 *
 * @param companyId company ID
 * @throws Exception if cannot set permission checker
 */
private static void setAdminPermissionCheckerForThread(final long companyId) throws Exception {

    User adminUser = getAdminUser(companyId);
    PrincipalThreadLocal.setName(adminUser.getUserId());
    PermissionChecker permissionChecker;
    try {
        permissionChecker = PermissionCheckerFactoryUtil.create(adminUser);
    } catch (Exception e) {
        throw new Exception("Cannot obtain permission checker for Liferay Administrator user",
                e);
    }
    PermissionThreadLocal.setPermissionChecker(permissionChecker);
}
 
開發者ID:mimacom,項目名稱:liferay-db-setup-core,代碼行數:21,代碼來源:LiferaySetup.java

示例6: uploadFile

import com.liferay.portal.kernel.security.permission.PermissionCheckerFactoryUtil; //導入依賴的package包/類
/**
 * 
 * @param userId
 * @param groupId
 * @param inputStream
 * @param sourceFileName
 * @param fileType
 * @param fileSize
 * @param destination
 * @param serviceContext
 * @return null if inputStream is null or sourceFileName is null
 * @throws Exception
 */
public static FileEntry uploadFile(long userId, long groupId, long fileEntryId, InputStream inputStream, String sourceFileName,
		String fileType, long fileSize, String destination, ServiceContext serviceContext) 
	throws Exception {
	
	FileEntry fileEntry = null;

	if (inputStream != null && Validator.isNotNull(sourceFileName)) {
		
		if(Validator.isNull(fileType)) {
			fileType = MimeTypesUtil.getContentType(sourceFileName);
		}
		
		if(fileSize == 0) {
			fileSize = inputStream.available();
			//byte[] bytes = FileUtil.getBytes(inputStream, -1, false);
			//fileSize = bytes.length;
		}
		
		String title = getFileName(sourceFileName);

		serviceContext.setAddGroupPermissions(true);
		serviceContext.setAddGuestPermissions(true);

		Calendar calendar = Calendar.getInstance();

		calendar.setTime(new Date());
		
		if(destination == null) {
			destination = StringPool.BLANK;
		}

		destination += calendar.get(Calendar.YEAR) + StringPool.SLASH;
		destination += calendar.get(Calendar.MONTH) + StringPool.SLASH;
		destination += calendar.get(Calendar.DAY_OF_MONTH);

		DLFolder dlFolder = DLFolderUtil.getTargetFolder(userId, groupId, groupId, false, 0, destination,
				StringPool.BLANK, false, serviceContext);

		User user = UserLocalServiceUtil.getUser(serviceContext.getUserId());

		PermissionChecker checker = PermissionCheckerFactoryUtil.create(user);
		PermissionThreadLocal.setPermissionChecker(checker);
		
		if(fileEntryId > 0) {
			fileEntry = DLAppLocalServiceUtil.updateFileEntry(userId, fileEntryId, sourceFileName, 
					fileType, title, title, title, true, inputStream, fileSize, serviceContext);
		} else {
			fileEntry = DLAppLocalServiceUtil.addFileEntry(userId, groupId, dlFolder.getFolderId(), title,
				fileType, title, title,
				StringPool.BLANK, inputStream, fileSize, serviceContext);
		}

	}

	return fileEntry;
}
 
開發者ID:VietOpenCPS,項目名稱:opencps-v2,代碼行數:70,代碼來源:FileUploadUtils.java

示例7: execute

import com.liferay.portal.kernel.security.permission.PermissionCheckerFactoryUtil; //導入依賴的package包/類
@Override
public BackgroundTaskResult execute(BackgroundTask backgroundTask) throws Exception {

    ExportImportConfiguration exportImportConfiguration = getExportImportConfiguration(backgroundTask);

    long userId = exportImportConfiguration.getUserId();

    List<FileEntry> attachmentsFileEntries = backgroundTask.getAttachmentsFileEntries();

    File file = null;

    for (FileEntry attachmentsFileEntry : attachmentsFileEntries) {

        try {

            String extension = attachmentsFileEntry.getExtension();

            file = FileUtil.createTempFile(extension);

            // Setup a permissionChecker for the user configured to own
            // scheduled import.

            PrincipalThreadLocal.setName(userId);
            PermissionChecker permissionChecker = PermissionCheckerFactoryUtil
                    .create(UserLocalServiceUtil.getUser(userId));
            PermissionThreadLocal.setPermissionChecker(permissionChecker);

            FileUtil.write(file, attachmentsFileEntry.getContentStream());

            TransactionInvokerUtil.invoke(transactionConfig,
                    new MeasurementImportCallable(exportImportConfiguration, file));

        } catch (Throwable t) {
            if (_log.isDebugEnabled()) {
                _log.debug(t, t);
            } else if (_log.isWarnEnabled()) {
                _log.warn("Unable to import measurements: " + t.getMessage());
            }

            throw new SystemException(t);
        } finally {
            FileUtil.delete(file);
        }
    }

    return BackgroundTaskResult.SUCCESS;
}
 
開發者ID:inofix,項目名稱:ch-inofix-data-manager,代碼行數:48,代碼來源:MeasurementImportBackgroundTaskExecutor.java

示例8: uploadFile

import com.liferay.portal.kernel.security.permission.PermissionCheckerFactoryUtil; //導入依賴的package包/類
public static FileEntry uploadFile(long userId, long companyId, long groupId, InputStream inputStream,
		String fileName, String fileType, long fileSize, String destination, String desc,
		ServiceContext serviceContext) throws Exception {
	FileEntry fileEntry = null;

	if (inputStream != null && fileSize > 0 && Validator.isNotNull(fileName)) {

		serviceContext.setAddGroupPermissions(true);
		serviceContext.setAddGuestPermissions(true);

		Calendar calendar = Calendar.getInstance();

		calendar.setTime(new Date());

		destination += calendar.get(Calendar.YEAR) + StringPool.SLASH;
		destination += calendar.get(Calendar.MONTH) + StringPool.SLASH;
		destination += calendar.get(Calendar.DAY_OF_MONTH);

		DLFolder dlFolder = DLFolderUtil.getTargetFolder(userId, groupId, groupId, false, 0, destination, desc,
				false, serviceContext);

		User user = UserLocalServiceUtil.getUser(serviceContext.getUserId());

		PermissionChecker checker = PermissionCheckerFactoryUtil.create(user);
		PermissionThreadLocal.setPermissionChecker(checker);

		fileEntry = DLAppLocalServiceUtil.addFileEntry(userId, groupId, dlFolder.getFolderId(), fileName, fileType,
				System.currentTimeMillis() + StringPool.DASH + fileName, desc, StringPool.BLANK, inputStream,
				fileSize, serviceContext);

	}

	return fileEntry;
}
 
開發者ID:VietOpenCPS,項目名稱:opencps-v2,代碼行數:35,代碼來源:FileUploadUtils.java


注:本文中的com.liferay.portal.kernel.security.permission.PermissionCheckerFactoryUtil類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。