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


Java SAXReaderUtil.createDocument方法代码示例

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


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

示例1: convertHashMapToString

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public String convertHashMapToString(HashMap<String, String> map, int typeId) throws IOException, SystemException{
	Element resultadosXML=SAXReaderUtil.createElement(getNameLearningActivity(typeId));
	Document resultadosXMLDoc=SAXReaderUtil.createDocument(resultadosXML);

	Iterator<Entry<String, String>> it = map.entrySet().iterator();

	while (it.hasNext()) {
		Map.Entry<String, String> e = (Map.Entry<String, String>)it.next();
		Element eleXML=SAXReaderUtil.createElement(String.valueOf(e.getKey()));
		if(e.getKey().toString().contains("document")){
			eleXML.addAttribute("id", String.valueOf(e.getValue()));
		}else{
			eleXML.addText(String.valueOf(e.getValue()));
		}
		resultadosXML.add(eleXML);
	}
	return resultadosXMLDoc.formattedString();
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:20,代码来源:LearningActivityLocalServiceImpl.java

示例2: setExtraContent

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的package包/类
@Override
public String setExtraContent(UploadRequest uploadRequest,
		PortletResponse portletResponse, LearningActivity learningActivity)
		throws NumberFormatException, Exception {
	
	ThemeDisplay themeDisplay = (ThemeDisplay) uploadRequest.getAttribute(WebKeys.THEME_DISPLAY);
	
		String team = ParamUtil.getString(uploadRequest, "team","0");
		long teamId = 0;
		if(!team.equalsIgnoreCase("0")){
			teamId = Long.parseLong(team);
		}
		
		Document document = null;
		Element rootElement = null;
		if((learningActivity.getExtracontent()==null)||(learningActivity.getExtracontent().trim().length()==0)){
			document = SAXReaderUtil.createDocument();
			rootElement = document.addElement("survey");
		}
		else
		{
			document=SAXReaderUtil.read(learningActivity.getExtracontent());
			rootElement =document.getRootElement();
		}
					
		Element teamElement=rootElement.element("team");
		if(teamElement!=null)
		{
			teamElement.detach();
			rootElement.remove(teamElement);
		}
		if(teamId!=0){
			teamElement = SAXReaderUtil.createElement("team");
			teamElement.setText(Long.toString(teamId));
			rootElement.add(teamElement);
		}
		learningActivity.setExtracontent(document.formattedString());
		
		return null;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:41,代码来源:SurveyLearningActivityType.java

示例3: setExtraContent

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的package包/类
@Override
public String setExtraContent(UploadRequest uploadRequest,
		PortletResponse portletResponse, LearningActivity learningActivity)
		throws NumberFormatException, Exception {
	
	ThemeDisplay themeDisplay = (ThemeDisplay) uploadRequest.getAttribute(WebKeys.THEME_DISPLAY);
	
		String team = ParamUtil.getString(uploadRequest, "team","0");
		long teamId = 0;
		if(!team.equalsIgnoreCase("0")){
			teamId = Long.parseLong(team);
		}
		
		Document document = null;
		Element rootElement = null;
		if((learningActivity.getExtracontent()==null)||(learningActivity.getExtracontent().trim().length()==0)){
			document = SAXReaderUtil.createDocument();
			rootElement = document.addElement("offline");
		}
		else
		{
			document=SAXReaderUtil.read(learningActivity.getExtracontent());
			rootElement =document.getRootElement();
		}
					
		Element teamElement=rootElement.element("team");
		if(teamElement!=null)
		{
			teamElement.detach();
			rootElement.remove(teamElement);
		}
		if(teamId!=0){
			teamElement = SAXReaderUtil.createElement("team");
			teamElement.setText(Long.toString(teamId));
			rootElement.add(teamElement);
		}
		learningActivity.setExtracontent(document.formattedString());
	
		return null;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:41,代码来源:TaskOfflineLearningActivityType.java

示例4: setEvaluationModel

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的package包/类
@Override
public void setEvaluationModel(Course course, JSONObject model)
		throws PortalException, SystemException, DocumentException,
		IOException {	
	Document document = SAXReaderUtil.createDocument();
	Element rootElement = document.addElement("eval");
	rootElement.addElement("courseEval").setText(CompleteModulesCourseEval.class.getName());		
	course.setCourseExtraData(document.formattedString());
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:10,代码来源:MandatoryAvgCourseEval.java

示例5: setEvaluationModel

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的package包/类
@Override
public void setEvaluationModel(Course course, JSONObject model)
		throws PortalException, SystemException, DocumentException,
		IOException {	
	Document document = SAXReaderUtil.createDocument();
	Element rootElement = document.addElement("eval");
	rootElement.addElement("courseEval").setText(PonderatedCourseEval.class.getName());		
	course.setCourseExtraData(document.formattedString());
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:10,代码来源:PonderatedCourseEval.java

示例6: update

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的package包/类
public LearningActivityTry update(long latId, int score, double position, int plays) throws SystemException, PortalException {

		System.out.println("update: " + latId);
		
		LearningActivityTry lat=learningActivityTryPersistence.fetchByPrimaryKey(latId);
		
		lat.setResult(score);
		
		try {			
			Element resultadoXML=SAXReaderUtil.createElement("result");
			Document resultadoXMLDoc=SAXReaderUtil.createDocument(resultadoXML);
			Element positionXML=SAXReaderUtil.createElement("position");
			positionXML.setText(String.valueOf(position));		
			resultadoXML.add(positionXML);
			Element scoreXML=SAXReaderUtil.createElement("score");
			scoreXML.setText(String.valueOf(score));		
			resultadoXML.add(scoreXML);
			Element playsXML=SAXReaderUtil.createElement("plays");
			playsXML.setText(String.valueOf(plays));		
			resultadoXML.add(playsXML);		
			lat.setTryResultData(resultadoXMLDoc.formattedString());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		lat.setEndDate(new Date());
		
		lat = learningActivityTryLocalService.updateLearningActivityTry(lat);
		
		return lat;
	}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:33,代码来源:LearningActivityTryLocalServiceImpl.java

示例7: QuestionTypeRegistry

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

		long actId=ParamUtil.getLong(actionRequest, "actId");
		long latId=ParamUtil.getLong(actionRequest,"latId" );
		boolean isTablet = ParamUtil.getBoolean(actionRequest,"isTablet" );
		String navigate = ParamUtil.getString(actionRequest, "navigate");
		boolean isPartial = false;
		if (Validator.isNotNull(navigate)) {
			if (Validator.equals(navigate, "backward") || Validator.equals(navigate, "forward")) {
				isPartial = true;
			}
		}

		LearningActivityTry larntry=LearningActivityTryLocalServiceUtil.getLearningActivityTry(latId);

		//Comprobar que el usuario tenga intentos posibles.
		if (larntry.getEndDate() == null){

			long correctanswers=0,penalizedAnswers=0;
			Element resultadosXML=SAXReaderUtil.createElement("results");
			Document resultadosXMLDoc=SAXReaderUtil.createDocument(resultadosXML);

			long[] questionIds = ParamUtil.getLongValues(actionRequest, "question");


			for (long questionId : questionIds) {
				TestQuestion question = TestQuestionLocalServiceUtil.fetchTestQuestion(questionId);
				QuestionType qt = new QuestionTypeRegistry().getQuestionType(question.getQuestionType());
				if(!isPartial){
					if(qt.correct(actionRequest, questionId)>0) {
						correctanswers += qt.correct(actionRequest, questionId) ;
					}else if(question.isPenalize()){
						penalizedAnswers++;
					}
				}
				resultadosXML.add(qt.getResults(actionRequest, questionId));								
			}

			long random = GetterUtil.getLong(LearningActivityLocalServiceUtil.getExtraContentValue(actId,"random"));
			long score=isPartial ? 0 : correctanswers/((random!=0 && random<questionIds.length)?random:questionIds.length);
			if(score < 0)score = 0;
			
			LearningActivityResult learningActivityResult = LearningActivityResultLocalServiceUtil.getByActIdAndUserId(actId, PortalUtil.getUserId(actionRequest));
			long oldResult=-1;
			if(learningActivityResult!=null) oldResult=learningActivityResult.getResult();

			larntry.setTryResultData(resultadosXMLDoc.formattedString());
			if (!isPartial) {
				larntry.setResult(score);
				larntry.setEndDate(new java.util.Date(System.currentTimeMillis()));
			}

			LearningActivityTryLocalServiceUtil.updateLearningActivityTry(larntry);

			actionResponse.setRenderParameters(actionRequest.getParameterMap());

			if (isPartial) {
				actionResponse.setRenderParameter("improve", ParamUtil.getString(actionRequest, "improve", Boolean.FALSE.toString()));
				if(isTablet)actionResponse.setRenderParameter("isTablet", Boolean.toString(true));
				actionResponse.setRenderParameter("jspPage", "/html/execactivity/test/view.jsp");
			} else {
				actionResponse.setRenderParameter("oldResult", Long.toString(oldResult));
				actionResponse.setRenderParameter("correction", Boolean.toString(true));
				if(isTablet)actionResponse.setRenderParameter("isTablet", Boolean.toString(true));
				actionResponse.setRenderParameter("jspPage", "/html/execactivity/test/results.jsp");
			}
		}else{
			actionResponse.setRenderParameters(actionRequest.getParameterMap());
			actionRequest.setAttribute("actId", actId);
			actionResponse.setRenderParameter("jspPage", "/html/execactivity/test/preview.jsp");
		}						

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

示例8: setExtraContent

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的package包/类
@Override
public String setExtraContent(UploadRequest uploadRequest,
		PortletResponse portletResponse, LearningActivity learningActivity)
				throws NumberFormatException, Exception {

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

	String fichero = ParamUtil.getString(uploadRequest, "fichero", StringPool.FALSE);
	String textoenr = ParamUtil.getString(uploadRequest, "textoenr", StringPool.FALSE);
	String team = ParamUtil.getString(uploadRequest, "team","0");
	long teamId = 0;
	if(!team.equalsIgnoreCase("0")){
		teamId = Long.parseLong(team);
	}

	Document document = null;
	Element rootElement = null;
	if((learningActivity.getExtracontent()==null)||(learningActivity.getExtracontent().trim().length()==0)){
		document = SAXReaderUtil.createDocument();
		rootElement = document.addElement("online");
	}
	else
	{
		document=SAXReaderUtil.read(learningActivity.getExtracontent());
		rootElement =document.getRootElement();
	}

	Element ficheroXML=rootElement.element("fichero");
	if(ficheroXML!=null)
	{
		ficheroXML.detach();
		rootElement.remove(ficheroXML);
	}
	ficheroXML=SAXReaderUtil.createElement("fichero");
	ficheroXML.addText(fichero);
	rootElement.add(ficheroXML);

	Element textoenrXML=rootElement.element("textoenr");
	if(textoenrXML!=null)
	{
		textoenrXML.detach();
		rootElement.remove(textoenrXML);
	}
	textoenrXML=SAXReaderUtil.createElement("textoenr");
	textoenrXML.addText(textoenr);
	rootElement.add(textoenrXML);

	Element teamElement=rootElement.element("team");
	if(teamElement!=null)
	{
		teamElement.detach();
		rootElement.remove(teamElement);
	}
	if(teamId!=0){
		teamElement = SAXReaderUtil.createElement("team");
		teamElement.setText(Long.toString(teamId));
		rootElement.add(teamElement);
	}
	learningActivity.setExtracontent(document.formattedString());

	return null;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:63,代码来源:TaskOnlineLearningActivityType.java

示例9: setEvaluationModel

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的package包/类
@Override
public void setEvaluationModel(Course course, JSONObject model)
		throws PortalException, SystemException, DocumentException,
		IOException {
	
	Document document = null;
	Element rootElement = null;
	Date firedDate = null;
	if((course.getCourseExtraData()!=null)&&(course.getCourseExtraData().trim().length()!=0)){
		try {
			document=SAXReaderUtil.read(course.getCourseExtraData());
			rootElement =document.getRootElement();
			Element firedDateElement = rootElement.element("firedDate");
			if(firedDateElement!=null){
				firedDate =(Date)_dateFormat.parseObject(firedDateElement.getTextTrim());
			}
		} catch (Throwable e) {
		}	
	}

	document = SAXReaderUtil.createDocument();
	rootElement = document.addElement("eval");
	rootElement.addElement("courseEval").setText(EvaluationAvgCourseEval.class.getName());
	if(firedDate!=null){
		rootElement.addElement("firedDate").setText(_dateFormat.format(firedDate));
	}
	
	rootElement.addElement("passPuntuation").setText(Long.toString(model.getLong("passPuntuation")));
	JSONArray jsonArray = model.getJSONArray("evaluations");
	if(jsonArray!=null){		
		for (int i = 0; i < jsonArray.length(); i++) {
			JSONObject evaluation = jsonArray.getJSONObject(i);
			long id = evaluation.getLong("id");
			if(id!=0){
				Element evaluationElement = rootElement.addElement("evaluation");
				evaluationElement.addElement("id").setText(Long.toString(id));
				evaluationElement.addElement("weight").setText(Long.toString(evaluation.getLong("weight")));
			}
		}
	}
	
	course.setCourseExtraData(document.formattedString());
	
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:45,代码来源:EvaluationAvgCourseEval.java

示例10: createLearningActivityTry

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的package包/类
@JSONWebService
	public LearningActivityTry createLearningActivityTry(long actId,long userId, int score, double position, int plays) throws SystemException, PortalException
	{
		User user=this.getUser();
		if(user.getUserId()==userId)
		{
		LearningActivityTry lat=learningActivityTryPersistence.create(counterLocalService.increment(
				LearningActivityTry.class.getName()));
		lat.setActId(actId);
		lat.setUserId(userId);
		java.util.Date today=new java.util.Date(System.currentTimeMillis());
		lat.setStartDate(today);
		lat.setResult(score);
		
		try {			
			Element resultadoXML=SAXReaderUtil.createElement("result");
			Document resultadoXMLDoc=SAXReaderUtil.createDocument(resultadoXML);
			Element positionXML=SAXReaderUtil.createElement("position");
			positionXML.setText(String.valueOf(position));		
			resultadoXML.add(positionXML);
			Element scoreXML=SAXReaderUtil.createElement("score");
			scoreXML.setText(String.valueOf(score));		
			resultadoXML.add(scoreXML);
			Element playsXML=SAXReaderUtil.createElement("plays");
			playsXML.setText(String.valueOf(plays));		
			resultadoXML.add(playsXML);		
			lat.setTryResultData(resultadoXMLDoc.formattedString());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		lat.setEndDate(new java.util.Date(System.currentTimeMillis()));
		
//		learningActivityTryPersistence.update(lat, true);
		learningActivityTryLocalService.updateLearningActivityTry(lat);
		
		ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
		
		if(serviceContext!=null){
			courseResultLocalService.softInitializeByGroupIdAndUserId(serviceContext.getScopeGroupId(), serviceContext.getUserId());
		}
		
		//auditing
		if(serviceContext!=null){
			AuditingLogFactory.audit(serviceContext.getCompanyId(), serviceContext.getScopeGroupId(), LearningActivityTry.class.getName(), 
				actId, serviceContext.getUserId(), AuditConstants.ADD, null);
		}else{
			LearningActivity la = learningActivityPersistence.fetchByPrimaryKey(actId);
			if(la!=null){
				AuditingLogFactory.audit(la.getCompanyId(), la.getGroupId(), LearningActivityTry.class.getName(), 
						actId, la.getUserId(), AuditConstants.ADD, null);
			}
		}
		
		return lat;
		}
		return null;
	}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:59,代码来源:LearningActivityTryServiceImpl.java

示例11: addfiles

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

	ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
	UploadPortletRequest request = PortalUtil.getUploadPortletRequest(actionRequest);

	String jspPage = ParamUtil.getString(actionRequest, "jspPage");
	long actId = ParamUtil.getLong(actionRequest, "resId", 0);
	String description = request.getParameter("description");
	String youtubecode=ParamUtil.getString(request,"youtubecode","");
	boolean videoControlEnabled=ParamUtil.getBoolean(request,"videoControl");
	LearningActivity larn = LearningActivityServiceUtil.getLearningActivity(actId);
	String extraContent=larn.getExtracontent();
	Document document = SAXReaderUtil.createDocument();
	Element rootElement = document.addElement("multimediaentry");
	if(extraContent!=null &&!"".equals(extraContent)&&!Validator.isNumber(extraContent))
	{
		document=SAXReaderUtil.read(extraContent);
		rootElement =document.getRootElement();
	}

	if(!"".equals(youtubecode))
	{
		Element video=rootElement.element("video");
		if(video!=null)
		{
			video.detach();
			rootElement.remove(video);
		}
		video = SAXReaderUtil.createElement("video");
		video.setText(youtubecode);		
		rootElement.add(video);
	}
	
	Element videoControl=rootElement.element("video-control");
	if(videoControl!=null)
	{
		videoControl.detach();
		rootElement.remove(videoControl);
	}
	
	videoControl = SAXReaderUtil.createElement("video-control");
	videoControl.setText(String.valueOf(videoControlEnabled));		
	rootElement.add(videoControl);
	
	larn.setExtracontent(document.formattedString());
	larn.setDescription( description,themeDisplay.getLocale());
	//LearningActivityServiceUtil.modLearningActivity(larn, serviceContext);

	LearningActivityServiceUtil.modLearningActivity(larn);
	//auditing
	AuditingLogFactory.audit(larn.getCompanyId(), larn.getGroupId(), LearningActivity.class.getName(), larn.getPrimaryKey(), themeDisplay.getUserId(), AuditConstants.UPDATE, null);
	
	SessionMessages.add(actionRequest, "activity-saved-successfully");
	actionResponse.setRenderParameter("jspPage", jspPage);
	actionResponse.setRenderParameter("actionEditingDetails", "true");	
	actionResponse.setRenderParameter("resId", Long.toString(actId));
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:59,代码来源:ResourceExternalActivity.java

示例12: doExportData

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的package包/类
@Override
protected String doExportData(PortletDataContext context, String portletId, PortletPreferences preferences) throws Exception {
	
	log.info("\n-----------------------------\ndoExportData STARTS, groupId : " + context.getScopeGroupId() );
	
	Group group = GroupLocalServiceUtil.getGroup(context.getScopeGroupId());
	log.info(" Course: "+ group.getName());
	
	
	context.addPermissions("com.liferay.lms.model.module", context.getScopeGroupId());
	
	Document document = SAXReaderUtil.createDocument();

	Element rootElement = document.addElement("moduledata");

	rootElement.addAttribute("group-id", String.valueOf(context.getScopeGroupId()));
	
	List<Module> entries = ModuleLocalServiceUtil.findAllInGroup(context.getScopeGroupId());
	long entryOld=0L;
	for (Module entry : entries) {
		log.info("++++++++++++++ModuleDataHandlerImpl::Module "+entry.getModuleId());
		log.info("++++++++++++++ModuleDataHandlerImpl::Module entryOld "+entryOld);
		
		if(entryOld!=entry.getModuleId()){
			entryOld=entry.getModuleId();
			exportEntry(context, rootElement, entry);
		} else{
			log.info("ModuleDataHandlerImpl::Repetido el modulo "+entry.getModuleId());

		}
	}

	log.info("\n-----------------------------\ndoExportData ENDS, modules:" + entries.size() + "\n-----------------------------\n"  );
	
	return document.formattedString();
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:37,代码来源:ModuleDataHandlerImpl.java

示例13: setActivity

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的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.xml.SAXReaderUtil.createDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。