Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
net.anotheria.anosite.gen.ascustomaction.action.MultiOpDialogCustomActionDefsAction Maven / Gradle / Ivy
/**
********************************************************************************
*** MultiOpDialogCustomActionDefsAction.java ***
*** generated by AnoSiteGenerator (ASG), Version: 3.2.2 ***
*** Copyright (C) 2005 - 2023 Anotheria.net, www.anotheria.net ***
*** All Rights Reserved. ***
********************************************************************************
*** Don't edit this code, if you aren't sure ***
*** that you do exactly know what you are doing! ***
*** It's better to invest time in the generator, as into the generated code. ***
********************************************************************************
*/
package net.anotheria.anosite.gen.ascustomaction.action;
import net.anotheria.util.NumberUtils;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import net.anotheria.maf.action.ActionCommand;
import net.anotheria.maf.action.ActionMapping;
import java.util.List;
import java.util.ArrayList;
import net.anotheria.anosite.gen.ascustomaction.data.CustomActionDefFactory;
import net.anotheria.anosite.gen.ascustomaction.data.CustomActionDef;
import net.anotheria.anosite.gen.ascustomaction.bean.EditCustomActionDefFB;
import net.anotheria.asg.util.bean.PopulateUtility;
import net.anotheria.asg.data.LockableObject;
import net.anotheria.asg.util.locking.helper.DocumentLockingHelper;
public class MultiOpDialogCustomActionDefsAction extends BaseCustomActionDefAction{
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateMultiOpDialogAction
@Override
public ActionCommand execute(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
return super.execute(mapping, req, res);
} //execute
public ActionCommand anoDocExecute(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String path = stripPath(mapping.getPath());
if (path.equals("ascustomactionCustomActionDefDelete"))
return ascustomactionCustomActionDefDelete(mapping, req, res);
if (path.equals("ascustomactionCustomActionDefDuplicate"))
return ascustomactionCustomActionDefDuplicate(mapping, req, res);
if (path.equals("ascustomactionCustomActionDefUpdate"))
return ascustomactionCustomActionDefUpdate(mapping, req, res);
if (path.equals("ascustomactionCustomActionDefClose"))
return ascustomactionCustomActionDefClose(mapping, req, res);
if (path.equals("ascustomactionCustomActionDefLock"))
return ascustomactionCustomActionDefLock(mapping, req, res);
if (path.equals("ascustomactionCustomActionDefUnLock"))
return ascustomactionCustomActionDefUnLock(mapping, req, res);
throw new IllegalArgumentException("Unknown path: "+path);
}
public ActionCommand ascustomactionCustomActionDefDelete(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String[] iDs = req.getParameterValues(PARAM_ID);
if (iDs == null){
throw new RuntimeException("Parameter " + PARAM_ID + " is not set.");
}
for (String id : iDs){
CustomActionDef customactiondefCurr = getASCustomActionService().getCustomActionDef(id);
if (customactiondefCurr instanceof LockableObject){
LockableObject lockable = (LockableObject)customactiondefCurr;
DocumentLockingHelper.delete.checkExecutionPermission(lockable, false, getUserId(req));
}
getASCustomActionService().deleteCustomActionDef(id);
}
res.sendRedirect("ascustomactionCustomActionDefShow?ts="+System.currentTimeMillis());
return null;
}
public ActionCommand ascustomactionCustomActionDefDuplicate(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
CustomActionDef customactiondefSrc = getASCustomActionService().getCustomActionDef(id);
CustomActionDef customactiondefDest = CustomActionDefFactory.createCustomActionDef(customactiondefSrc);
CustomActionDef customactiondefCreated = getASCustomActionService().createCustomActionDef(customactiondefDest);
res.sendRedirect("ascustomactionCustomActionDefEdit?ts="+System.currentTimeMillis()+"&"+PARAM_ID+"="+customactiondefCreated.getId());
return null;
}
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateUpdateActionMethod
public ActionCommand ascustomactionCustomActionDefUpdate(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
EditCustomActionDefFB form = new EditCustomActionDefFB();
PopulateUtility.populate(form, req);
boolean create = false;
CustomActionDef customactiondef = null;
if (form.getId()==null) {
res.sendRedirect("asresourcedataLocalizationBundleShow?ts="+System.currentTimeMillis());
return null;
}
if (form.getId().length()>0){
customactiondef = (CustomActionDef)getASCustomActionService().getCustomActionDef(form.getId()).clone();
}else{
customactiondef = CustomActionDefFactory.createCustomActionDef();
create = true;
}
String nextAction = req.getParameter("nextAction");
if (nextAction == null || nextAction.length() == 0)
nextAction = "close";
//skipped id because it's readonly.
customactiondef.setName(form.getName());
customactiondef.setClazz(form.getClazz());
customactiondef.setAccessOperation(form.getAccessOperation());
CustomActionDef updatedCopy = null;
if (create){
updatedCopy = getASCustomActionService().createCustomActionDef(customactiondef);
}else{
canUpdateCustomActionDefs(customactiondef, req);
checkCustomActionDefs(customactiondef, req);
updatedCopy = getASCustomActionService().updateCustomActionDef(customactiondef);
}
if (nextAction.equalsIgnoreCase("stay")){
res.sendRedirect("ascustomactionCustomActionDefEdit?ts="+System.currentTimeMillis()+"&pId="+updatedCopy.getId());
}else{
unlockAfterUpdate(customactiondef, req);
res.sendRedirect("ascustomactionCustomActionDefShow?ts="+System.currentTimeMillis());
}
return null;
}
/**
* Simply unlocks document after updation.
*/
private void unlockAfterUpdate(CustomActionDef customactiondef, HttpServletRequest req) throws Exception{
if(((LockableObject)customactiondef).isLocked())
unLockCustomActionDefs(customactiondef, req, false);
}
public ActionCommand ascustomactionCustomActionDefLock(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
CustomActionDef customactiondefCurr = id != null && !id.equals("") ? getASCustomActionService().getCustomActionDef(id) : null;
if(customactiondefCurr != null && customactiondefCurr instanceof LockableObject){
LockableObject lockable = (LockableObject)customactiondefCurr;
DocumentLockingHelper.lock.checkExecutionPermission(lockable,false,getUserId(req));
lockCustomActionDefs(customactiondefCurr, req);
}
res.sendRedirect(getRedirectUrl(req, customactiondefCurr));
return null;
}
public ActionCommand ascustomactionCustomActionDefUnLock(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
CustomActionDef customactiondefCurr = id != null && !id.equals("") ? getASCustomActionService().getCustomActionDef(id) : null;
if(customactiondefCurr != null && customactiondefCurr instanceof LockableObject){
LockableObject lockable = (LockableObject)customactiondefCurr;
DocumentLockingHelper.unLock.checkExecutionPermission(lockable,isUserInRole(req, "admin"),getUserId(req));
unLockCustomActionDefs(customactiondefCurr, req, false);
}
res.sendRedirect(getRedirectUrl(req, customactiondefCurr));
return null;
}
/**
* Simplest method for redirect url creation. nextAction == showEdit - going to 'editView', to 'listView' otherwise.
*/
private String getRedirectUrl(HttpServletRequest req, CustomActionDef item){
String nextAction = req.getParameter("nextAction");
if (item==null || nextAction == null || nextAction.length() == 0)
return "ascustomactionCustomActionDefShow?ts="+System.currentTimeMillis();
else
return nextAction.equals("showEdit") ? "ascustomactionCustomActionDefEdit?ts="+System.currentTimeMillis()+"&pId="+item.getId()
: "ascustomactionCustomActionDefShow?ts="+System.currentTimeMillis();
}
public ActionCommand ascustomactionCustomActionDefClose(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
CustomActionDef customactiondefCurr = id != null && !id.equals("") ? getASCustomActionService().getCustomActionDef(id) : null;
if(customactiondefCurr != null && customactiondefCurr instanceof LockableObject && ((LockableObject)customactiondefCurr).isLocked())
unLockCustomActionDefs(customactiondefCurr, req, false);
res.sendRedirect("ascustomactionCustomActionDefShow?ts="+System.currentTimeMillis());
return null;
}
}