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


Java DLFolderConstants.getDataRepositoryId方法代码示例

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


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

示例1: importQuestionAnswers

import com.liferay.portlet.documentlibrary.model.DLFolderConstants; //导入方法依赖的package包/类
@Override
public void importQuestionAnswers(PortletDataContext context, Element entryElement, long questionId, long userId, ServiceContext serviceContext) throws SystemException, PortalException{
	for(Element aElement:entryElement.elements("questionanswer")){
		String patha = aElement.attributeValue("path");
		TestAnswer oldanswer=(TestAnswer)context.getZipEntryAsObject(patha);
		TestAnswer answer = TestAnswerLocalServiceUtil.addTestAnswer(questionId, oldanswer.getAnswer(), oldanswer.getFeedbackCorrect(), oldanswer.getFeedbacknocorrect(), oldanswer.isIsCorrect());
		
		//Si tenemos ficheros en las descripciones de las respuestas.
		for (Element actElementFile : aElement.elements("descriptionfile")) {
			FileEntry oldFile = (FileEntry)context.getZipEntryAsObject(actElementFile.attributeValue("path"));
			ModuleDataHandlerImpl m = new ModuleDataHandlerImpl();
			FileEntry newFile;
			long folderId=0;
			String description = "";
			
			try {
				InputStream input = context.getZipEntryAsInputStream(actElementFile.attributeValue("file"));
				long repositoryId = DLFolderConstants.getDataRepositoryId(context.getScopeGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
				folderId = DLFolderUtil.createDLFoldersForLearningActivity(userId,repositoryId,serviceContext).getFolderId();
				newFile = DLAppLocalServiceUtil.addFileEntry(userId, repositoryId , folderId , oldFile.getTitle(), "contentType", oldFile.getTitle(), StringPool.BLANK, StringPool.BLANK, IOUtils.toByteArray(input), serviceContext );
				description = ImportUtil.descriptionFileParserLarToDescription(answer.getAnswer(), oldFile, newFile);
			} catch(DuplicateFileException dfl){
				FileEntry existingFile = DLAppLocalServiceUtil.getFileEntry(context.getScopeGroupId(), folderId, oldFile.getTitle());
				description = ImportUtil.descriptionFileParserLarToDescription(answer.getAnswer(), oldFile, existingFile);
			} catch (Exception e) {
				e.printStackTrace();
			}
			answer.setAnswer(description);
			TestAnswerLocalServiceUtil.updateTestAnswer(answer);
		}
	}
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:33,代码来源:BaseQuestionType.java

示例2: cloneFile

import com.liferay.portlet.documentlibrary.model.DLFolderConstants; //导入方法依赖的package包/类
private long cloneFile(long entryId, LearningActivity actNew, long userId, ServiceContext serviceContext){
	
	long assetEntryId = 0;
	boolean addGroupPermissions = serviceContext.isAddGroupPermissions();
	
	try {
		if(log.isDebugEnabled()){log.debug("EntryId: "+entryId);}
		AssetEntry docAsset = AssetEntryLocalServiceUtil.getAssetEntry(entryId);
		//docAsset.getUrl()!=""
		//DLFileEntryLocalServiceUtil.getDLFileEntry(fileEntryId)
		if(log.isDebugEnabled()){log.debug(docAsset.getClassPK());}
		DLFileEntry docfile = DLFileEntryLocalServiceUtil.getDLFileEntry(docAsset.getClassPK());
		InputStream is = DLFileEntryLocalServiceUtil.getFileAsStream(userId, docfile.getFileEntryId(), docfile.getVersion());
		
		//Crear el folder
		DLFolder dlFolder = DLFolderUtil.createDLFoldersForLearningActivity(userId, serviceContext.getScopeGroupId(), serviceContext);

		long repositoryId = DLFolderConstants.getDataRepositoryId(actNew.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
		
		String ficheroStr = docfile.getTitle();	
		if(!docfile.getTitle().endsWith(docfile.getExtension())){
			ficheroStr = ficheroStr +"."+ docfile.getExtension();
		}
		
		serviceContext.setAddGroupPermissions(true);
		FileEntry newFile = DLAppLocalServiceUtil.addFileEntry(
				serviceContext.getUserId(), repositoryId , dlFolder.getFolderId() , ficheroStr, docfile.getMimeType(), 
				docfile.getTitle(), StringPool.BLANK, StringPool.BLANK, is, docfile.getSize() , serviceContext ) ;
		
		
		AssetEntry asset = AssetEntryLocalServiceUtil.getEntry(DLFileEntry.class.getName(), newFile.getPrimaryKey());
		
		if(log.isDebugEnabled()){log.debug(" asset : " + asset.getEntryId());};
		
		assetEntryId = asset.getEntryId();
		
	} catch (NoSuchEntryException nsee) {
		log.error(" asset not exits ");
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} finally {
		serviceContext.setAddGroupPermissions(addGroupPermissions);
	}
	
	return assetEntryId;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:48,代码来源:CourseCopyUtil.java

示例3: setActivity

import com.liferay.portlet.documentlibrary.model.DLFolderConstants; //导入方法依赖的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

示例4: doDeleteData

import com.liferay.portlet.documentlibrary.model.DLFolderConstants; //导入方法依赖的package包/类
@Override
	protected PortletPreferences doDeleteData(PortletDataContext context,
	String portletId, PortletPreferences preferences) throws Exception {
	
	log.info("\n-----------------------------\ndoDeleteData STARTS");
	
	try {
		String groupIdStr = String.valueOf(context.getScopeGroupId());
		
		Group group = GroupLocalServiceUtil.getGroup(context.getScopeGroupId());
		
		long groupId = 0;
		
		if(Validator.isNumber(groupIdStr)){
			groupId = Long.parseLong(groupIdStr);
		}
		long repositoryId = DLFolderConstants.getDataRepositoryId(group.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
		
		log.info("  Course: "+ group.getName()+ ", groupId: " + repositoryId);
		
		LearningActivityTypeRegistry learningActivityTypeRegistry = new LearningActivityTypeRegistry();
		List<Module> modules = ModuleLocalServiceUtil.findAllInGroup(groupId);

		for(Module module:modules){
			
			log.info("    Module : " + module.getTitle(Locale.getDefault()) );
			
			List<LearningActivity> activities = LearningActivityLocalServiceUtil.getLearningActivitiesOfModule(module.getModuleId());
			
			for(LearningActivity activity:activities){
				LearningActivityLocalServiceUtil.deleteLearningactivity(activity);
			}
			
			//Borrar todos los ficheros 
			DLAppLocalServiceUtil.deleteAll(repositoryId);
			
			ModuleLocalServiceUtil.deleteModule(module);
			
		}
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

	log.info("doDeleteData ENDS\n-----------------------------\n");
	
	return super.doDeleteData(context, portletId, preferences);
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:49,代码来源:ModuleDataHandlerImpl.java


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