本文整理汇总了Java中com.liferay.portal.util.PortalUtil.getUploadPortletRequest方法的典型用法代码示例。如果您正苦于以下问题:Java PortalUtil.getUploadPortletRequest方法的具体用法?Java PortalUtil.getUploadPortletRequest怎么用?Java PortalUtil.getUploadPortletRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.liferay.portal.util.PortalUtil
的用法示例。
在下文中一共展示了PortalUtil.getUploadPortletRequest方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uploadPHPFile
import com.liferay.portal.util.PortalUtil; //导入方法依赖的package包/类
private void uploadPHPFile(ResourceRequest resourceRequest,
ResourceResponse resourceResponse) throws IOException {
UploadRequest uploadRequest = PortalUtil.getUploadPortletRequest(resourceRequest);
File objFile = uploadRequest.getFile("PHPFILE");
String objFileName = uploadRequest.getFileName("PHPFILE");
_log.info("objFile: [" + objFile + "], objFileName: [" + objFileName + "]");
InputStream is = new FileInputStream(objFile);
byte[] buff = new byte[is.available()];
is.read(buff);
is.close();
String publicKeyStr = new String(buff);
resourceResponse.setContentType("text/html");
PrintWriter writer = resourceResponse.getWriter();
JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
String[] arrStr = publicKeyStr.split("-----BEGIN PUBLIC KEY-----");
publicKeyStr = arrStr[1];
arrStr = publicKeyStr.split("-----END PUBLIC KEY-----");
jsonObject.put("publicKey", arrStr[0]);
phpPublicKey = arrStr[0];
writer.print(jsonObject.toString());
writer.flush();
writer.close();
}
示例2: prettify
import com.liferay.portal.util.PortalUtil; //导入方法依赖的package包/类
protected String prettify(PortletRequest request) throws IOException,
PortletException {
UploadPortletRequest uploadPortletRequest = PortalUtil
.getUploadPortletRequest(request);
String liferayVersion = ParamUtil.getString(uploadPortletRequest,
"liferayVersion", "7.0.4-ga5");
boolean printDefaultValue = ParamUtil.getBoolean(uploadPortletRequest,
"printDefaultValue");
Properties customProperties = PropertiesUtil.load(
uploadPortletRequest.getFileAsStream("portalPropertiesFile"),
"UTF-8");
String prettyProperties = prettier.prettify(customProperties,
liferayVersion, printDefaultValue);
incrementCounter(request);
return prettyProperties;
}
开发者ID:tmoreira2020,项目名称:portal-properties-prettier-app,代码行数:22,代码来源:PortalPropertiesPrettierPortlet.java
示例3: deleteResources
import com.liferay.portal.util.PortalUtil; //导入方法依赖的package包/类
@Override
public void deleteResources(ActionRequest actionRequest,
ActionResponse actionResponse, LearningActivity larn)
throws PortalException, SystemException, DocumentException,
IOException {
UploadRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
ThemeDisplay themeDisplay = (ThemeDisplay) uploadRequest.getAttribute(WebKeys.THEME_DISPLAY);
try {
Folder folder = DLAppLocalServiceUtil.getFolder(themeDisplay.getScopeGroupId(), 0, String.valueOf(larn.getActId()));
java.util.List<FileEntry> files = DLAppLocalServiceUtil.getFileEntries(themeDisplay.getScopeGroupId(), folder.getFolderId());
for(FileEntry file:files){
DLAppLocalServiceUtil.deleteFileEntry(file.getFileEntryId());
}
DLAppLocalServiceUtil.deleteFolder(folder.getFolderId());
} catch (Exception e) {
//No existe carpeta, por lo que no hay recursos asociados que eliminar.
}
super.deleteResources(actionRequest, actionResponse, larn);
}
示例4: addEdit
import com.liferay.portal.util.PortalUtil; //导入方法依赖的package包/类
public void addEdit(ActionRequest request, ActionResponse response)
throws SystemException, PortalException, IOException {
if (SessionErrors.isEmpty(request)) {
ServiceContext serviceContext = ServiceContextThreadLocal
.getServiceContext();
UploadRequest uploadRequest = PortalUtil
.getUploadPortletRequest(request);
String title = ParamUtil.getString(uploadRequest,JobPosKeys.AddEditAttributes.TITLE, PortletKeys.TEXT_BOX);
String positionCatNo = ParamUtil.getString(uploadRequest,JobPosKeys.AddEditAttributes.POSITIONCATNO, PortletKeys.TEXT_BOX);
long workingUnitId = ParamUtil.getLong(uploadRequest,JobPosKeys.AddEditAttributes.WORKINGUNITID);
long subWorkingUnitId = ParamUtil.getLong(uploadRequest,JobPosKeys.AddEditAttributes.SUBWORKINGUNITID);
int leader = ParamUtil.getInteger(uploadRequest,JobPosKeys.AddEditAttributes.LEADER);
Long editId = ParamUtil.getLong(uploadRequest,
JobPosKeys.AddEditAttributes.EDIT_ID,
PortletKeys.LONG_DEFAULT);
// Date pingTime = new Date();
if (editId == PortletKeys.LONG_DEFAULT) {
JobPosLocalServiceUtil.addJobPos(title, positionCatNo, workingUnitId,subWorkingUnitId, leader, serviceContext);
//System.out.println(" sssss " + name + " " + address);
} else {
JobPos jobPos = JobPosLocalServiceUtil
.getJobPos(editId);
JobPosLocalServiceUtil.saveJobPos(jobPos,
serviceContext);
}
}
if (!SessionErrors.isEmpty(request)) {
PortalUtil.copyRequestParameters(request, response);
} else {
response.sendRedirect(ParamUtil.getString(request,
PortletKeys.REDIRECT_PAGE));
}
}
示例5: addEditJobPos2Role
import com.liferay.portal.util.PortalUtil; //导入方法依赖的package包/类
public void addEditJobPos2Role(ActionRequest request, ActionResponse response)
throws SystemException, PortalException, IOException {
if (SessionErrors.isEmpty(request)) {
ServiceContext serviceContext = ServiceContextThreadLocal
.getServiceContext();
UploadRequest uploadRequest = PortalUtil
.getUploadPortletRequest(request);
long roleId = ParamUtil.getLong(uploadRequest,JobPosKeys.AddEditAttributes.ROLEID);
long jobPosId = ParamUtil.getLong(uploadRequest,JobPosKeys.AddEditAttributes.JOBPOSID);
System.out.println(" sssss " + roleId + " " + jobPosId);
// Date pingTime = new Date();
if (roleId != PortletKeys.LONG_DEFAULT && jobPosId != PortletKeys.LONG_DEFAULT) {
JobPos2RoleLocalServiceUtil.addJobPos2Role(jobPosId, roleId, serviceContext);
//System.out.println(" sssss " + name + " " + address);
}
}
PortalUtil.copyRequestParameters(request, response);
/*
if (!SessionErrors.isEmpty(request)) {
PortalUtil.copyRequestParameters(request, response);
} else {
response.sendRedirect(ParamUtil.getString(request,
PortletKeys.REDIRECT_PAGE));
}
*/
}
示例6: deleteJobPos2Role
import com.liferay.portal.util.PortalUtil; //导入方法依赖的package包/类
public void deleteJobPos2Role(ActionRequest request, ActionResponse response)
throws SystemException, PortalException, IOException {
if (SessionErrors.isEmpty(request)) {
ServiceContext serviceContext = ServiceContextThreadLocal
.getServiceContext();
UploadRequest uploadRequest = PortalUtil
.getUploadPortletRequest(request);
long roleId = ParamUtil.getLong(uploadRequest,JobPosKeys.BaseJobPosAttributes.DELETE_ID);
long jobPosId = ParamUtil.getLong(uploadRequest,JobPosKeys.AddEditAttributes.JOBPOSID);
System.out.println(" sssss " + roleId + " " + jobPosId);
// Date pingTime = new Date();
if (roleId != PortletKeys.LONG_DEFAULT && jobPosId != PortletKeys.LONG_DEFAULT) {
JobPos2RoleLocalServiceUtil.removeJobPos2Role(jobPosId, roleId);//(jobPosId, roleId, serviceContext);
//System.out.println(" sssss " + name + " " + address);
}
}
PortalUtil.copyRequestParameters(request, response);
/*
if (!SessionErrors.isEmpty(request)) {
PortalUtil.copyRequestParameters(request, response);
} else {
response.sendRedirect(ParamUtil.getString(request,
PortletKeys.REDIRECT_PAGE));
}
*/
}
示例7: addEditJobPos
import com.liferay.portal.util.PortalUtil; //导入方法依赖的package包/类
public void addEditJobPos(ActionRequest request, ActionResponse response)
throws SystemException, PortalException, IOException {
if (SessionErrors.isEmpty(request)) {
ServiceContext serviceContext = ServiceContextThreadLocal
.getServiceContext();
UploadRequest uploadRequest = PortalUtil
.getUploadPortletRequest(request);
long employeeId = ParamUtil.getLong(uploadRequest,EmployeeKeys.BaseEmployeeAttributes.EDIT_ID);
long jobPosId = ParamUtil.getLong(uploadRequest,EmployeeKeys.AddEditAttributes.JOBPOSID);
// Date pingTime = new Date();
if (employeeId != PortletKeys.LONG_DEFAULT && jobPosId != PortletKeys.LONG_DEFAULT) {
//JobPos2RoleLocalServiceUtil.addJobPos2Role(jobPosId, roleId, serviceContext);
EmployeeLocalServiceUtil.addEmployee2JoPos(employeeId, jobPosId);
//System.out.println(" sssss " + name + " " + address);
}
}
PortalUtil.copyRequestParameters(request, response);
/*
if (!SessionErrors.isEmpty(request)) {
PortalUtil.copyRequestParameters(request, response);
} else {
response.sendRedirect(ParamUtil.getString(request,
PortletKeys.REDIRECT_PAGE));
}
*/
}
示例8: deleteJobPos
import com.liferay.portal.util.PortalUtil; //导入方法依赖的package包/类
public void deleteJobPos(ActionRequest request, ActionResponse response)
throws SystemException, PortalException, IOException {
if (SessionErrors.isEmpty(request)) {
ServiceContext serviceContext = ServiceContextThreadLocal
.getServiceContext();
UploadRequest uploadRequest = PortalUtil
.getUploadPortletRequest(request);
long employeeId = ParamUtil.getLong(uploadRequest,EmployeeKeys.BaseEmployeeAttributes.EDIT_ID);
long jobPosId = ParamUtil.getLong(uploadRequest,EmployeeKeys.BaseEmployeeAttributes.DELETE_ID);
System.out.println(" Xoa " + employeeId + " " + jobPosId);
// Date pingTime = new Date();
if (employeeId != PortletKeys.LONG_DEFAULT && jobPosId != PortletKeys.LONG_DEFAULT) {
//JobPos2RoleLocalServiceUtil.addJobPos2Role(jobPosId, roleId, serviceContext);
EmployeeLocalServiceUtil.removeJobPos(employeeId, jobPosId);
//System.out.println(" sssss " + name + " " + address);
}
}
PortalUtil.copyRequestParameters(request, response);
/*
if (!SessionErrors.isEmpty(request)) {
PortalUtil.copyRequestParameters(request, response);
} else {
response.sendRedirect(ParamUtil.getString(request,
PortletKeys.REDIRECT_PAGE));
}
*/
}
示例9: addEditJobPos
import com.liferay.portal.util.PortalUtil; //导入方法依赖的package包/类
public void addEditJobPos(ActionRequest request, ActionResponse response)
throws SystemException, PortalException, IOException {
if (SessionErrors.isEmpty(request)) {
ServiceContext serviceContext = ServiceContextThreadLocal
.getServiceContext();
UploadRequest uploadRequest = PortalUtil
.getUploadPortletRequest(request);
String title = ParamUtil.getString(uploadRequest,JobPosKeys.AddEditAttributes.TITLE, PortletKeys.TEXT_BOX);
String positionCatNo = ParamUtil.getString(uploadRequest,JobPosKeys.AddEditAttributes.POSITIONCATNO, PortletKeys.TEXT_BOX);
long workingUnitId = ParamUtil.getLong(uploadRequest,JobPosKeys.AddEditAttributes.WORKINGUNITID);
long subWorkingUnitId = ParamUtil.getLong(uploadRequest,JobPosKeys.AddEditAttributes.SUBWORKINGUNITID);
int leader = ParamUtil.getInteger(uploadRequest,JobPosKeys.AddEditAttributes.LEADER);
Long editId = ParamUtil.getLong(uploadRequest,
JobPosKeys.AddEditAttributes.EDIT_ID,
PortletKeys.LONG_DEFAULT);
//System.out.println(" sssss " + title + " " + workingUnitId + " " + leader + " " + editId);
// Date pingTime = new Date();
if (editId == PortletKeys.LONG_DEFAULT) {
JobPosLocalServiceUtil.addJobPos(title, positionCatNo, workingUnitId,subWorkingUnitId, leader, serviceContext);
//System.out.println(" sssss " + name + " " + address);
} else {
JobPos jobPos = JobPosLocalServiceUtil
.getJobPos(editId);
jobPos.setTitle(title);
jobPos.setSubWorkingUnitId(subWorkingUnitId);
jobPos.setPositionCatNo(positionCatNo);
jobPos.setLeader(leader);
JobPosLocalServiceUtil.saveJobPos(jobPos,
serviceContext);
}
}
if (!SessionErrors.isEmpty(request)) {
PortalUtil.copyRequestParameters(request, response);
} else {
response.sendRedirect(ParamUtil.getString(request,
PortletKeys.REDIRECT_PAGE));
}
}
示例10: changePassword
import com.liferay.portal.util.PortalUtil; //导入方法依赖的package包/类
public void changePassword(ActionRequest request, ActionResponse response)
throws Exception {
if (SessionErrors.isEmpty(request)) {
ServiceContext serviceContext = ServiceContextThreadLocal
.getServiceContext();
UploadRequest uploadRequest = PortalUtil
.getUploadPortletRequest(request);
Long editId = ParamUtil.getLong(uploadRequest,
EmployeeKeys.AddEditAttributes.EDIT_ID,
PortletKeys.LONG_DEFAULT);
ManagerLdap ld = new ManagerLdap();
if (editId != PortletKeys.LONG_DEFAULT) {
Employee employee = EmployeeLocalServiceUtil.getEmployee(editId);
//System.out.println(" sssss " + fullName + " " + mainJobPosId + " " + workingUnitId + " " + employee.getMappingUserId());
User user = null;
if (employee.getMappingUserId() != PortletKeys.LONG_DEFAULT){
// System.out.println(" Doi mat khau " + employee.getMappingUserId() + password + " " + repassword);
String password = ParamUtil.getString(uploadRequest,EmployeeKeys.AddEditAttributes.PASSWORD, PortletKeys.TEXT_BOX);
String repassword = ParamUtil.getString(uploadRequest,EmployeeKeys.AddEditAttributes.REPASSWORD, PortletKeys.TEXT_BOX);
try{
Date now = new Date();
//UserLocalServiceUtil.upd
//UserLocalServiceUtil.updatePassword(employee.getMappingUserId(), password, repassword, false);
// false, false, serviceContext.getCreateDate(now));
UserLocalServiceUtil.updatePasswordManually(employee.getMappingUserId() , password, true, false, serviceContext.getCreateDate(now));
user = UserLocalServiceUtil.getUser(employee.getMappingUserId());
if (user != null && ld.getIsZimbraLdap(serviceContext.getCompanyId())){
//employee.setMappingUserId(user.getUserId());
ld.changePassord(serviceContext, user,password);
}
} catch (Exception e) {
System.out.println("Loi o day " + e.getMessage());
}
}
}
}
if (!SessionErrors.isEmpty(request)) {
PortalUtil.copyRequestParameters(request, response);
} else {
response.sendRedirect(ParamUtil.getString(request,
PortletKeys.REDIRECT_PAGE));
}
}
示例11: addEditApplication
import com.liferay.portal.util.PortalUtil; //导入方法依赖的package包/类
public void addEditApplication(ActionRequest request, ActionResponse response) throws SystemException, PortalException, IOException {
if (SessionErrors.isEmpty(request)) {
ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
UploadRequest uploadRequest = PortalUtil.getUploadPortletRequest(request);
String appName = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_NAME, PortletKeys.TEXT_BOX);
String appCode = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_CODE, PortletKeys.TEXT_BOX);
String appPin = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_PIN, PortletKeys.TEXT_BOX);
String appUrl = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_URL, PortletKeys.TEXT_BOX);
Long editId = ParamUtil.getLong(uploadRequest, ApplicationKeys.AddEditAttributes.EDIT_ID, PortletKeys.LONG_DEFAULT);
OutputBlob bigIconBlob = null;
OutputBlob smallIconBlob = null;
try {
File bigIconFile = uploadRequest.getFile(ApplicationKeys.AddEditAttributes.APP_BIGICON);
File smallIconFile = uploadRequest.getFile(ApplicationKeys.AddEditAttributes.APP_SMALLICON);
InputStream bigIconStream = new FileInputStream(bigIconFile);
InputStream smallIconStream = new FileInputStream(smallIconFile);
bigIconBlob = new OutputBlob(bigIconStream, bigIconFile.length());
smallIconBlob = new OutputBlob(smallIconStream, smallIconFile.length());
}
catch (FileNotFoundException ex) {
}
Date pingTime = new Date();
if (editId == PortletKeys.LONG_DEFAULT) {
ApplicationLocalServiceUtil.addApplication(appCode, appName, appPin, appUrl, bigIconBlob, smallIconBlob, pingTime, serviceContext);
} else {
Application application = ApplicationLocalServiceUtil.getApplication(editId);
if (smallIconBlob != null) {
application.setAppSmallIcon(smallIconBlob);
}
if (bigIconBlob != null) {
application.setAppBigIcon(bigIconBlob);
}
application.setAppCode(appCode);
application.setAppPin(appPin);
application.setAppUrl(appUrl);
application.setPingTime(pingTime);
ApplicationLocalServiceUtil.updateApplication(application, serviceContext);
}
}
if (!SessionErrors.isEmpty(request)) {
PortalUtil.copyRequestParameters(request, response);
} else {
response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE));
}
}
示例12: importCourse
import com.liferay.portal.util.PortalUtil; //导入方法依赖的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());
}
}
}
示例13: addfiles
import com.liferay.portal.util.PortalUtil; //导入方法依赖的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));
}
示例14: setActivity
import com.liferay.portal.util.PortalUtil; //导入方法依赖的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");
}
}