List of usage examples for com.liferay.portal.kernel.util Constants REVERT
String REVERT
To view the source code for com.liferay.portal.kernel.util Constants REVERT.
Click Source Link
From source file:com.liferay.document.library.web.internal.portlet.action.EditFileEntryMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); FileEntry fileEntry = null;//from w w w . j a v a 2 s. c o m PortletConfig portletConfig = getPortletConfig(actionRequest); try { UploadException uploadException = (UploadException) actionRequest .getAttribute(WebKeys.UPLOAD_EXCEPTION); if (uploadException != null) { Throwable cause = uploadException.getCause(); if (cmd.equals(Constants.ADD_TEMP)) { if (cause instanceof FileUploadBase.IOFileUploadException) { if (_log.isInfoEnabled()) { _log.info("Temporary upload was cancelled"); } } } else { if (uploadException.isExceededFileSizeLimit()) { throw new FileSizeException(cause); } if (uploadException.isExceededLiferayFileItemSizeLimit()) { throw new LiferayFileItemException(cause); } if (uploadException.isExceededUploadRequestSizeLimit()) { throw new UploadRequestSizeException(cause); } throw new PortalException(cause); } } else if (cmd.equals(Constants.ADD) || cmd.equals(Constants.ADD_DYNAMIC) || cmd.equals(Constants.UPDATE) || cmd.equals(Constants.UPDATE_AND_CHECKIN)) { fileEntry = updateFileEntry(portletConfig, actionRequest, actionResponse); } else if (cmd.equals(Constants.ADD_MULTIPLE)) { addMultipleFileEntries(portletConfig, actionRequest, actionResponse); hideDefaultSuccessMessage(actionRequest); } else if (cmd.equals(Constants.ADD_TEMP)) { addTempFileEntry(actionRequest, actionResponse); } else if (cmd.equals(Constants.DELETE)) { deleteFileEntry(actionRequest, false); } else if (cmd.equals(Constants.DELETE_TEMP)) { deleteTempFileEntry(actionRequest, actionResponse); } else if (cmd.equals(Constants.CANCEL_CHECKOUT)) { cancelFileEntriesCheckOut(actionRequest); } else if (cmd.equals(Constants.CHECKIN)) { checkInFileEntries(actionRequest); } else if (cmd.equals(Constants.CHECKOUT)) { checkOutFileEntries(actionRequest); } else if (cmd.equals(Constants.MOVE_TO_TRASH)) { deleteFileEntry(actionRequest, true); } else if (cmd.equals(Constants.RESTORE)) { restoreTrashEntries(actionRequest); } else if (cmd.equals(Constants.REVERT)) { revertFileEntry(actionRequest); } WindowState windowState = actionRequest.getWindowState(); if (cmd.equals(Constants.ADD_TEMP) || cmd.equals(Constants.DELETE_TEMP)) { actionResponse.setRenderParameter("mvcPath", "/null.jsp"); } else if (cmd.equals(Constants.PREVIEW)) { SessionMessages.add(actionRequest, _portal.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_FORCE_SEND_REDIRECT); hideDefaultSuccessMessage(actionRequest); actionResponse.setRenderParameter("mvcRenderCommandName", "/document_library/edit_file_entry"); } else if (!windowState.equals(LiferayWindowState.POP_UP)) { } else { String redirect = ParamUtil.getString(actionRequest, "redirect"); int workflowAction = ParamUtil.getInteger(actionRequest, "workflowAction", WorkflowConstants.ACTION_SAVE_DRAFT); if ((fileEntry != null) && (workflowAction == WorkflowConstants.ACTION_SAVE_DRAFT)) { redirect = getSaveAndContinueRedirect(portletConfig, actionRequest, fileEntry, redirect); sendRedirect(actionRequest, actionResponse, redirect); } else { if (windowState.equals(LiferayWindowState.POP_UP)) { redirect = _portal.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { if (cmd.equals(Constants.ADD) && (fileEntry != null)) { String portletId = HttpUtil.getParameter(redirect, "p_p_id", false); String namespace = _portal.getPortletNamespace(portletId); redirect = HttpUtil.addParameter(redirect, namespace + "className", DLFileEntry.class.getName()); redirect = HttpUtil.addParameter(redirect, namespace + "classPK", fileEntry.getFileEntryId()); } actionRequest.setAttribute(WebKeys.REDIRECT, redirect); } } } } } catch (Exception e) { handleUploadException(portletConfig, actionRequest, actionResponse, cmd, e); } }
From source file:com.liferay.dynamic.data.lists.service.impl.DDLRecordLocalServiceImpl.java
License:Open Source License
/** * Reverts the record to the given version. * * @param userId the primary key of the user who is reverting the record * @param recordId the primary key of the record * @param version the version to revert to * @param serviceContext the service context to be applied. This can set * the record modified date./*from ww w. j av a 2 s. c om*/ * @throws PortalException if a portal exception occurred */ @Override public void revertRecord(long userId, long recordId, String version, ServiceContext serviceContext) throws PortalException { DDLRecordVersion recordVersion = ddlRecordVersionLocalService.getRecordVersion(recordId, version); if (!recordVersion.isApproved()) { return; } DDMFormValues ddmFormValues = storageEngine.getDDMFormValues(recordVersion.getDDMStorageId()); serviceContext.setCommand(Constants.REVERT); ddlRecordLocalService.updateRecord(userId, recordId, true, recordVersion.getDisplayIndex(), ddmFormValues, serviceContext); }
From source file:com.liferay.dynamic.data.lists.service.impl.DDLRecordLocalServiceImpl.java
License:Open Source License
/** * See <code>DLFileVersionPolicyImpl#isKeepFileVersionLabel</code> in the * <code>com.liferay.document.library.service</code> module. *///from w w w . j a va 2 s.c o m protected boolean isKeepRecordVersionLabel(DDLRecordVersion lastRecordVersion, DDLRecordVersion latestRecordVersion, ServiceContext serviceContext) throws PortalException { if (Objects.equals(serviceContext.getCommand(), Constants.REVERT)) { return false; } if (serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_SAVE_DRAFT) { return false; } if (Objects.equals(lastRecordVersion.getVersion(), latestRecordVersion.getVersion())) { return false; } DDMFormValues lastDDMFormValues = storageEngine.getDDMFormValues(lastRecordVersion.getDDMStorageId()); DDMFormValues latestDDMFormValues = storageEngine.getDDMFormValues(latestRecordVersion.getDDMStorageId()); if (!lastDDMFormValues.equals(latestDDMFormValues)) { return false; } ExpandoBridge lastExpandoBridge = lastRecordVersion.getExpandoBridge(); ExpandoBridge latestExpandoBridge = latestRecordVersion.getExpandoBridge(); Map<String, Serializable> lastAttributes = lastExpandoBridge.getAttributes(); Map<String, Serializable> latestAttributes = latestExpandoBridge.getAttributes(); if (!lastAttributes.equals(latestAttributes)) { return false; } return true; }
From source file:com.liferay.dynamic.data.mapping.service.impl.DDMFormInstanceRecordLocalServiceImpl.java
License:Open Source License
@Override public void revertFormInstanceRecord(long userId, long ddmFormInstanceRecordId, String version, ServiceContext serviceContext) throws PortalException { DDMFormInstanceRecordVersion ddmFormInstanceRecordVersion = ddmFormInstanceRecordVersionLocalService .getFormInstanceRecordVersion(ddmFormInstanceRecordId, version); if (!ddmFormInstanceRecordVersion.isApproved()) { return;//from www . ja v a 2s.c o m } StorageEngine storageEngine = storageEngineAccessor.getStorageEngine(); DDMFormValues ddmFormValues = storageEngine.getDDMFormValues(ddmFormInstanceRecordVersion.getStorageId()); serviceContext.setCommand(Constants.REVERT); updateFormInstanceRecord(userId, ddmFormInstanceRecordId, true, ddmFormValues, serviceContext); }
From source file:com.liferay.dynamic.data.mapping.service.impl.DDMFormInstanceRecordLocalServiceImpl.java
License:Open Source License
protected boolean isKeepFormInstanceRecordVersionLabel( DDMFormInstanceRecordVersion lastDDMFormInstanceRecordVersion, DDMFormInstanceRecordVersion latestDDMFormInstanceRecordVersion, ServiceContext serviceContext) throws PortalException { if (Objects.equals(serviceContext.getCommand(), Constants.REVERT)) { return false; }/*from w w w.j av a2s . com*/ if (serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_SAVE_DRAFT) { return false; } if (Objects.equals(lastDDMFormInstanceRecordVersion.getVersion(), latestDDMFormInstanceRecordVersion.getVersion())) { return false; } StorageEngine storageEngine = storageEngineAccessor.getStorageEngine(); DDMFormValues lastDDMFormValues = storageEngine .getDDMFormValues(lastDDMFormInstanceRecordVersion.getStorageId()); DDMFormValues latestDDMFormValues = storageEngine .getDDMFormValues(latestDDMFormInstanceRecordVersion.getStorageId()); if (!lastDDMFormValues.equals(latestDDMFormValues)) { return false; } ExpandoBridge lastExpandoBridge = lastDDMFormInstanceRecordVersion.getExpandoBridge(); ExpandoBridge latestExpandoBridge = latestDDMFormInstanceRecordVersion.getExpandoBridge(); Map<String, Serializable> lastAttributes = lastExpandoBridge.getAttributes(); Map<String, Serializable> latestAttributes = latestExpandoBridge.getAttributes(); if (!lastAttributes.equals(latestAttributes)) { return false; } return true; }
From source file:com.liferay.dynamic.data.mapping.service.impl.DDMStructureLocalServiceImpl.java
License:Open Source License
@Override public void revertStructure(long userId, long structureId, String version, ServiceContext serviceContext) throws PortalException { DDMStructureVersion structureVersion = ddmStructureVersionLocalService.getStructureVersion(structureId, version);/*from w w w. j a v a2 s. c om*/ if (!structureVersion.isApproved()) { throw new InvalidStructureVersionException("Unable to revert from an unapproved file version"); } DDMStructure structure = structureVersion.getStructure(); serviceContext.setAttribute("majorVersion", Boolean.TRUE); serviceContext.setAttribute("status", WorkflowConstants.STATUS_APPROVED); serviceContext.setCommand(Constants.REVERT); ddmStructureLocalService.updateStructure(userId, structure.getGroupId(), structureVersion.getParentStructureId(), structure.getClassNameId(), structure.getStructureKey(), structureVersion.getNameMap(), structureVersion.getDescriptionMap(), structureVersion.getDDMForm(), structureVersion.getDDMFormLayout(), serviceContext); }
From source file:com.liferay.dynamic.data.mapping.service.impl.DDMTemplateLocalServiceImpl.java
License:Open Source License
@Override public void revertTemplate(long userId, long templateId, String version, ServiceContext serviceContext) throws PortalException { DDMTemplateVersion templateVersion = ddmTemplateVersionLocalService.getTemplateVersion(templateId, version); if (!templateVersion.isApproved()) { throw new InvalidTemplateVersionException("Unable to revert from an unapproved template version"); }/*from w ww . j av a2 s . c o m*/ DDMTemplate template = templateVersion.getTemplate(); serviceContext.setAttribute("majorVersion", Boolean.TRUE); serviceContext.setAttribute("status", WorkflowConstants.STATUS_APPROVED); serviceContext.setCommand(Constants.REVERT); ddmTemplateLocalService.updateTemplate(userId, templateId, templateVersion.getClassPK(), templateVersion.getNameMap(), templateVersion.getDescriptionMap(), template.getType(), template.getMode(), templateVersion.getLanguage(), templateVersion.getScript(), template.getCacheable(), serviceContext); }
From source file:com.liferay.EditRecordAction.java
License:Open Source License
@Override public void processAction(ActionMapping actionMapping, ActionForm actionForm, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try {//from ww w . j a va 2s . c om if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { updateRecord(actionRequest); } else if (cmd.equals(Constants.DELETE)) { deleteRecord(actionRequest); } else if (cmd.equals(Constants.REVERT)) { revertRecordVersion(actionRequest); } else if (cmd.equals(Constants.TRANSLATE)) { updateRecord(actionRequest); setForward(actionRequest, "portlet.dynamic_data_lists.update_translation_redirect"); } if (Validator.isNotNull(cmd) && !cmd.equals(Constants.TRANSLATE)) { sendRedirect(actionRequest, actionResponse); } } catch (Exception e) { if (e instanceof NoSuchRecordException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass()); setForward(actionRequest, "portlet.dynamic_data_lists.error"); } else if (e instanceof FileSizeException || e instanceof StorageFieldRequiredException) { SessionErrors.add(actionRequest, e.getClass()); } else { throw e; } } }
From source file:com.liferay.portlet.dynamicdatalists.action.EditRecordAction.java
License:Open Source License
@Override public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try {// w ww . j a v a 2 s . com if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { updateRecord(actionRequest); } else if (cmd.equals(Constants.DELETE)) { deleteRecord(actionRequest); } else if (cmd.equals(Constants.REVERT)) { revertRecordVersion(actionRequest); } if (Validator.isNotNull(cmd)) { sendRedirect(actionRequest, actionResponse); } } catch (Exception e) { if (e instanceof NoSuchRecordException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.dynamic_data_lists.error"); } else if (e instanceof FileSizeException || e instanceof StorageFieldRequiredException) { SessionErrors.add(actionRequest, e.getClass().getName()); } else { throw e; } } }
From source file:com.liferay.portlet.wiki.action.EditPageAction.java
License:Open Source License
public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); WikiPage page = null;/*w w w . j av a 2 s . c o m*/ try { if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { page = updatePage(actionRequest); } else if (cmd.equals(Constants.DELETE)) { deletePage(actionRequest); } else if (cmd.equals(Constants.REVERT)) { revertPage(actionRequest); } else if (cmd.equals(Constants.SUBSCRIBE)) { subscribePage(actionRequest); } else if (cmd.equals(Constants.UNSUBSCRIBE)) { unsubscribePage(actionRequest); } if (Validator.isNotNull(cmd)) { String redirect = ParamUtil.getString(actionRequest, "redirect"); if (page != null) { boolean saveAndContinue = ParamUtil.getBoolean(actionRequest, "saveAndContinue"); if (saveAndContinue) { redirect = getSaveAndContinueRedirect(portletConfig, actionRequest, page, redirect); } else if (redirect.endsWith("title=")) { redirect += page.getTitle(); } } sendRedirect(actionRequest, actionResponse, redirect); } } catch (Exception e) { if (e instanceof NoSuchNodeException || e instanceof NoSuchPageException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.wiki.error"); } else if (e instanceof DuplicatePageException || e instanceof PageContentException || e instanceof PageVersionException || e instanceof PageTitleException) { SessionErrors.add(actionRequest, e.getClass().getName()); } else if (e instanceof TagsEntryException) { SessionErrors.add(actionRequest, e.getClass().getName(), e); } else { throw e; } } }