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


Java UploadPortletRequest.getFile方法代码示例

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


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

示例1: EmployeeFileTerm

import com.liferay.portal.kernel.upload.UploadPortletRequest; //导入方法依赖的package包/类
public EmployeeFileTerm(ActionRequest actionRequest) {

		UploadPortletRequest request = PortalUtil.getUploadPortletRequest(actionRequest);
		
		ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
		
		fileName= request.getFileName("uploadedFile");
		
		file =  request.getFile("uploadedFile");

		mimeType = request.getContentType("uploadedFile");
		
		employeeFileId = ParamUtil.getLong(request, EMPLOYEE_FILE_ID);
		
		groupId = themeDisplay.getScopeGroupId();
		
		companyId = themeDisplay.getCompanyId();
		
		userId = themeDisplay.getUserId();
		
		userName = themeDisplay.getUser().getFullName();
		
		createDate = ParamUtil.getDate(request, CREATE_DATE,
				DateTimeUtils.getDateTimeFormat(DateTimeUtils._VN_DATE_TIME_FORMAT));
		
		modifiedDate = ParamUtil.getDate(request, MODIFIED_DATE,
				DateTimeUtils.getDateTimeFormat(DateTimeUtils._VN_DATE_TIME_FORMAT));
		
		employeeId = ParamUtil.getLong(request, EMPLOYEE_ID);
		
		fileEntryId = ParamUtil.getLong(request, FILE_ENTRY_ID);
		
		documentName = ParamUtil.getString(request, DOCUMENT_NAME);
		
		if(Validator.isNull(documentName)){
			documentName = fileName;
		}
		
	}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:40,代码来源:EmployeeFileTerm.java

示例2: getUploadRequestFile

import com.liferay.portal.kernel.upload.UploadPortletRequest; //导入方法依赖的package包/类
private File getUploadRequestFile(UploadPortletRequest uploadRequest,
		String paramName) throws LARFileException {
	File file = null;
	if (Validator.isNotNull(uploadRequest.getFileName(paramName))) {
		file = uploadRequest.getFile(paramName);
		if (!file.exists()) {
			throw new LARFileException("Import file '" + paramName
					+ "' does not exist");
		}
	}
	return file;
}
 
开发者ID:rivetlogic,项目名称:hr-portal,代码行数:13,代码来源:EditUserAction.java

示例3: importCourse

import com.liferay.portal.kernel.upload.UploadPortletRequest; //导入方法依赖的package包/类
public void importCourse(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

		UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
		long groupId = ParamUtil.getLong(uploadRequest, "groupId");
		
		try {

			ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

			File file = uploadRequest.getFile("importFileName");
			if (!file.exists()) {
				//	log.debug("Import file does not exist");
				throw new LARFileException("Import file does not exist");
			}
			String portletId = (String) actionRequest.getAttribute(WebKeys.PORTLET_ID);
			LayoutServiceUtil.importPortletInfo(themeDisplay.getLayout().getPlid(), groupId,portletId, uploadRequest.getParameterMap(), file);
			addSuccessMessage(actionRequest, actionResponse);
			
			/* Si esta seleccionado el modo de borrar tenemos que progpagar borrado de icono de la clase*/
			
			if(uploadRequest.getParameter(PortletDataHandlerKeys.DELETE_PORTLET_DATA).equals("true")){
				Course c = CourseLocalServiceUtil.getCourseByGroupCreatedId(groupId);
				c.setIcon(0);
				CourseLocalServiceUtil.updateCourse(c);
			}
			
			SessionMessages.add(actionRequest, "import-course-ok");

		} catch (Exception e) {
			e.printStackTrace();
			if ((e instanceof LARFileException) || (e instanceof LARTypeException)) {

				SessionErrors.add(actionRequest, e.getClass().getName());

			} if(e.getMessage() != null && e.getMessage().indexOf(NoLearningActivityTypeActiveException.class.getName()) >= 0){
				e.printStackTrace();
				actionResponse.setRenderParameter("view", "import");
				actionResponse.setRenderParameter("groupId", String.valueOf(groupId));
				SessionErrors.add(actionRequest, "error-learning-activity-type");	
			}
			else {
				log.error(e, e);
				SessionErrors.add(actionRequest, LayoutImportException.class.getName());
			}
		}
	}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:47,代码来源:CourseAdmin.java

示例4: PartnerFileTerm

import com.liferay.portal.kernel.upload.UploadPortletRequest; //导入方法依赖的package包/类
public PartnerFileTerm(ActionRequest actionRequest) {

		UploadPortletRequest request = PortalUtil.getUploadPortletRequest(actionRequest);
		
		ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
		
		fileName= request.getFileName("uploadedFile");
		
		file =  request.getFile("uploadedFile");

		mimeType = request.getContentType("uploadedFile");
		
		partnerFileId = ParamUtil.getLong(request, PARTNER_FILE_ID);
		
		groupId = themeDisplay.getScopeGroupId();
		
		companyId = themeDisplay.getCompanyId();
		
		userId = themeDisplay.getUserId();
		
		userName = themeDisplay.getUser().getFullName();
		
		createDate = ParamUtil.getDate(request, CREATE_DATE,
				DateTimeUtils.getDateTimeFormat(DateTimeUtils._VN_DATE_TIME_FORMAT));
		
		modifiedDate = ParamUtil.getDate(request, MODIFIED_DATE,
				DateTimeUtils.getDateTimeFormat(DateTimeUtils._VN_DATE_TIME_FORMAT));
		
		partnerId = ParamUtil.getLong(request, PARTNER_ID);
		
		fileEntryId = ParamUtil.getLong(request, FILE_ENTRY_ID);
		
		if(Validator.isNull(documentName)){
			documentName = fileName;
		}
		
	}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:38,代码来源:PartnerFileTerm.java

示例5: setActivity

import com.liferay.portal.kernel.upload.UploadPortletRequest; //导入方法依赖的package包/类
public void setActivity(ActionRequest actionRequest,
		ActionResponse actionResponse) throws IOException, NestableException {
	long actId = ParamUtil.getLong(actionRequest, "actId");
	UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
	String text = ParamUtil.getString(uploadRequest, "text");
	ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
	User user = UserLocalServiceUtil.getUser(themeDisplay.getUserId());
	boolean isSetTextoEnr =  StringPool.TRUE.equals(LearningActivityLocalServiceUtil.getExtraContentValue(actId,"textoenr"));
	boolean isSetFichero =  StringPool.TRUE.equals(LearningActivityLocalServiceUtil.getExtraContentValue(actId,"fichero"));

	LearningActivity learningActivity = LearningActivityLocalServiceUtil.getLearningActivity(actId);
	LearningActivityTryLocalServiceUtil.getTriesCountByActivityAndUser(actId, user.getUserId());

	if((learningActivity.getTries()!=0)&&(learningActivity.getTries()<=LearningActivityTryLocalServiceUtil.getTriesCountByActivityAndUser(actId, user.getUserId()))) {
		//TODO
		SessionErrors.add(actionRequest, "onlineActivity.max-tries");	
	}
	else {

		//ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

		Element resultadosXML=SAXReaderUtil.createElement("results");
		Document resultadosXMLDoc=SAXReaderUtil.createDocument(resultadosXML);

		if(isSetFichero) {
			String fileName = uploadRequest.getFileName("fileName");
			File file = uploadRequest.getFile("fileName");
			String mimeType = uploadRequest.getContentType("fileName");
			if (Validator.isNull(fileName)) {
				SessionErrors.add(actionRequest, "onlineActivity.mandatory.file");
				actionRequest.setAttribute("actId", actId);
				actionResponse.setRenderParameter("text", text);
				return;
			}
			if(	file.getName().endsWith(".bat") 
					|| file.getName().endsWith(".com")
					|| file.getName().endsWith(".exe")
					|| file.getName().endsWith(".msi") ){

				SessionErrors.add(actionRequest, "onlineActivity.not.allowed.file.type");
				actionResponse.setRenderParameter("text", text);
				actionRequest.setAttribute("actId", actId);
				return;
			}

			long repositoryId = DLFolderConstants.getDataRepositoryId(themeDisplay.getScopeGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
			long folderId = createDLFolders(user.getUserId(), repositoryId, actionRequest);

			//Subimos el Archivo en la Document Library
			ServiceContext serviceContext= ServiceContextFactory.getInstance( DLFileEntry.class.getName(), actionRequest);
			//Damos permisos al archivo para usuarios de comunidad.
			serviceContext.setAddGroupPermissions(true);
			FileEntry document = DLAppLocalServiceUtil.addFileEntry(
					themeDisplay.getUserId(), repositoryId , folderId , fileName, mimeType, fileName, StringPool.BLANK, StringPool.BLANK, file , serviceContext ) ;

			Element fileXML=SAXReaderUtil.createElement(FILE_XML);
			fileXML.addAttribute("id", Long.toString(document.getFileEntryId()));
			resultadosXML.add(fileXML);
		}

		if(isSetTextoEnr){
			Element richTextXML=SAXReaderUtil.createElement(RICH_TEXT_XML);
			richTextXML.setText(text);
			resultadosXML.add(richTextXML);				
		}
		else {
			Element textXML=SAXReaderUtil.createElement(TEXT_XML);
			textXML.setText(text);
			resultadosXML.add(textXML);				
		}

		LearningActivityTry learningActivityTry =  LearningActivityTryLocalServiceUtil.createLearningActivityTry(actId,ServiceContextFactory.getInstance(actionRequest));
		learningActivityTry.setTryResultData(resultadosXMLDoc.formattedString());	
		//learningActivityTry.setEndDate(new Date());
		//learningActivityTry.setResult(0);
		LearningActivityTryLocalServiceUtil.updateLearningActivityTry(learningActivityTry);
		SessionMessages.add(actionRequest, "onlinetaskactivity.updating");
	}

}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:81,代码来源:OnlineActivity.java


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