List of usage examples for com.liferay.portal.kernel.util Constants EDIT
String EDIT
To view the source code for com.liferay.portal.kernel.util Constants EDIT.
Click Source Link
From source file:com.liferay.image.editor.hook.action.EditFileEntryAction.java
License:Open Source License
@Override public void processAction(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try {/*ww w . ja va 2 s .co m*/ if (cmd.equals(Constants.EDIT)) { updateImage(actionRequest); } else { originalStrutsPortletAction.processAction(originalStrutsPortletAction, portletConfig, actionRequest, actionResponse); } } catch (Exception e) { SessionErrors.add(actionRequest, e.getClass()); } finally { String redirect = ParamUtil.getString(actionRequest, "redirect"); actionResponse.sendRedirect(redirect); } }
From source file:com.liferay.sampledao.portlet.DAOPortlet.java
License:Open Source License
@Override public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); long foodItemId = ParamUtil.getLong(actionRequest, "foodItemId"); String name = actionRequest.getParameter("name"); int points = ParamUtil.getInteger(actionRequest, "points"); try {//from ww w .j a va 2s .c o m if (cmd.equals(Constants.ADD)) { FoodItem foodItem = new FoodItem(); foodItem.setName(name); foodItem.setPoints(points); FoodItemDAO.addFoodItem(foodItem); } else if (cmd.equals(Constants.EDIT)) { FoodItem foodItem = FoodItemDAO.getFoodItem(foodItemId); foodItem.setName(name); foodItem.setPoints(points); FoodItemDAO.updateFoodItem(foodItem); } else if (cmd.equals(Constants.DELETE)) { FoodItemDAO.deleteFoodItem(foodItemId); } } catch (SQLException sqle) { throw new PortletException(sqle); } }
From source file:com.liferay.samplehibernate.portlet.HibernatePortlet.java
License:Open Source License
@Override public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); long foodItemId = ParamUtil.getLong(actionRequest, "foodItemId"); String name = actionRequest.getParameter("name"); int points = ParamUtil.getInteger(actionRequest, "points"); try {/*w w w . j ava 2 s . c o m*/ if (cmd.equals(Constants.ADD)) { FoodItem foodItem = new FoodItem(); foodItem.setName(name); foodItem.setPoints(points); FoodItemUtil.addFoodItem(foodItem); } else if (cmd.equals(Constants.EDIT)) { FoodItem foodItem = FoodItemUtil.getFoodItem(foodItemId); foodItem.setName(name); foodItem.setPoints(points); FoodItemUtil.updateFoodItem(foodItem); } else if (cmd.equals(Constants.DELETE)) { FoodItemUtil.deleteFoodItem(foodItemId); } } catch (Exception e) { throw new PortletException(e); } }
From source file:com.liferay.so.activities.portlet.ActivitiesPortlet.java
License:Open Source License
public void updateMBComment(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String cmd = ParamUtil.getString(actionRequest, Constants.CMD); String className = ParamUtil.getString(actionRequest, "className"); long classPK = ParamUtil.getLong(actionRequest, "classPK"); long mbMessageId = ParamUtil.getLong(actionRequest, "mbMessageIdOrMicroblogsEntryId"); String body = ParamUtil.getString(actionRequest, "body"); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); try {/*from w w w. j a va 2 s . c om*/ MBMessage mbMessage = null; long groupId = themeDisplay.getScopeGroupId(); ServiceContext serviceContext = ServiceContextFactory.getInstance(MBMessage.class.getName(), actionRequest); if (cmd.equals(Constants.DELETE)) { MBMessageServiceUtil.deleteDiscussionMessage(groupId, className, classPK, className, classPK, themeDisplay.getUserId(), mbMessageId); } else if (cmd.equals(Constants.EDIT) && (mbMessageId > 0)) { mbMessage = MBMessageServiceUtil.updateDiscussionMessage(className, classPK, className, classPK, themeDisplay.getUserId(), mbMessageId, StringPool.BLANK, body, serviceContext); } else { MBMessageDisplay mbMessageDisplay = MBMessageLocalServiceUtil.getDiscussionMessageDisplay( themeDisplay.getUserId(), groupId, className, classPK, WorkflowConstants.STATUS_APPROVED); MBThread mbThread = mbMessageDisplay.getThread(); MBTreeWalker mbTreeWalker = mbMessageDisplay.getTreeWalker(); MBMessage rootMBMessage = mbTreeWalker.getRoot(); mbMessage = MBMessageServiceUtil.addDiscussionMessage(groupId, className, classPK, className, classPK, themeDisplay.getUserId(), mbThread.getThreadId(), rootMBMessage.getMessageId(), StringPool.BLANK, body, serviceContext); } if (mbMessage != null) { jsonObject = getJSONObject(mbMessage.getMessageId(), mbMessage.getBody(), mbMessage.getModifiedDate(), mbMessage.getUserId(), mbMessage.getUserName(), themeDisplay); } jsonObject.put("success", Boolean.TRUE); } catch (Exception e) { jsonObject.put("success", Boolean.FALSE); } writeJSON(actionRequest, actionResponse, jsonObject); }
From source file:com.liferay.so.activities.portlet.ActivitiesPortlet.java
License:Open Source License
public void updateMicroblogsComment(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String cmd = ParamUtil.getString(actionRequest, Constants.CMD); long classPK = ParamUtil.getLong(actionRequest, "classPK"); long microblogsEntryId = ParamUtil.getLong(actionRequest, "mbMessageIdOrMicroblogsEntryId"); String body = ParamUtil.getString(actionRequest, "body"); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); try {// ww w. j a va2 s . co m MicroblogsEntry microblogsEntry = null; if (cmd.equals(Constants.DELETE)) { MicroblogsEntryServiceUtil.deleteMicroblogsEntry(microblogsEntryId); } else if (classPK > 0) { MicroblogsEntry currentMicroblogsEntry = MicroblogsEntryLocalServiceUtil .getMicroblogsEntry(classPK); ServiceContext serviceContext = ServiceContextFactory.getInstance(MicroblogsEntry.class.getName(), actionRequest); if (cmd.equals(Constants.EDIT) && (microblogsEntryId > 0)) { microblogsEntry = MicroblogsEntryServiceUtil.updateMicroblogsEntry(microblogsEntryId, body, currentMicroblogsEntry.getSocialRelationType(), serviceContext); } else { microblogsEntry = MicroblogsEntryServiceUtil.addMicroblogsEntry(themeDisplay.getUserId(), body, MicroblogsEntryConstants.TYPE_REPLY, classPK, currentMicroblogsEntry.getSocialRelationType(), serviceContext); } } if (microblogsEntry != null) { jsonObject = getJSONObject(microblogsEntry.getMicroblogsEntryId(), microblogsEntry.getContent(), microblogsEntry.getModifiedDate(), microblogsEntry.getUserId(), microblogsEntry.getUserName(), themeDisplay); } jsonObject.put("success", Boolean.TRUE); } catch (Exception e) { jsonObject.put("success", Boolean.FALSE); } writeJSON(actionRequest, actionResponse, jsonObject); }