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


Java StringPool.SLASH属性代码示例

本文整理汇总了Java中com.liferay.portal.kernel.util.StringPool.SLASH属性的典型用法代码示例。如果您正苦于以下问题:Java StringPool.SLASH属性的具体用法?Java StringPool.SLASH怎么用?Java StringPool.SLASH使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.liferay.portal.kernel.util.StringPool的用法示例。


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

示例1: cloneFile

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,代码行数:37,代码来源:FileUploadUtils.java

示例2: uploadFile

/**
 * 
 * @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,代码行数:69,代码来源:FileUploadUtils.java

示例3: uploadFile

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,代码行数:34,代码来源:FileUploadUtils.java


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