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.ascustomdata.action.MultiOpDialogCustomGuardDefsAction Maven / Gradle / Ivy
/**
********************************************************************************
*** MultiOpDialogCustomGuardDefsAction.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.ascustomdata.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.ascustomdata.data.CustomGuardDefFactory;
import net.anotheria.anosite.gen.ascustomdata.data.CustomGuardDef;
import net.anotheria.anosite.gen.ascustomdata.bean.EditCustomGuardDefFB;
import net.anotheria.asg.util.bean.PopulateUtility;
import net.anotheria.asg.data.LockableObject;
import net.anotheria.asg.util.locking.helper.DocumentLockingHelper;
public class MultiOpDialogCustomGuardDefsAction extends BaseCustomGuardDefAction{
// 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("ascustomdataCustomGuardDefDelete"))
return ascustomdataCustomGuardDefDelete(mapping, req, res);
if (path.equals("ascustomdataCustomGuardDefDuplicate"))
return ascustomdataCustomGuardDefDuplicate(mapping, req, res);
if (path.equals("ascustomdataCustomGuardDefUpdate"))
return ascustomdataCustomGuardDefUpdate(mapping, req, res);
if (path.equals("ascustomdataCustomGuardDefClose"))
return ascustomdataCustomGuardDefClose(mapping, req, res);
if (path.equals("ascustomdataCustomGuardDefLock"))
return ascustomdataCustomGuardDefLock(mapping, req, res);
if (path.equals("ascustomdataCustomGuardDefUnLock"))
return ascustomdataCustomGuardDefUnLock(mapping, req, res);
throw new IllegalArgumentException("Unknown path: "+path);
}
public ActionCommand ascustomdataCustomGuardDefDelete(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){
CustomGuardDef customguarddefCurr = getASCustomDataService().getCustomGuardDef(id);
if (customguarddefCurr instanceof LockableObject){
LockableObject lockable = (LockableObject)customguarddefCurr;
DocumentLockingHelper.delete.checkExecutionPermission(lockable, false, getUserId(req));
}
getASCustomDataService().deleteCustomGuardDef(id);
}
res.sendRedirect("ascustomdataCustomGuardDefShow?ts="+System.currentTimeMillis());
return null;
}
public ActionCommand ascustomdataCustomGuardDefDuplicate(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
CustomGuardDef customguarddefSrc = getASCustomDataService().getCustomGuardDef(id);
CustomGuardDef customguarddefDest = CustomGuardDefFactory.createCustomGuardDef(customguarddefSrc);
CustomGuardDef customguarddefCreated = getASCustomDataService().createCustomGuardDef(customguarddefDest);
res.sendRedirect("ascustomdataCustomGuardDefEdit?ts="+System.currentTimeMillis()+"&"+PARAM_ID+"="+customguarddefCreated.getId());
return null;
}
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateUpdateActionMethod
public ActionCommand ascustomdataCustomGuardDefUpdate(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
EditCustomGuardDefFB form = new EditCustomGuardDefFB();
PopulateUtility.populate(form, req);
boolean create = false;
CustomGuardDef customguarddef = null;
if (form.getId()==null) {
res.sendRedirect("asresourcedataLocalizationBundleShow?ts="+System.currentTimeMillis());
return null;
}
if (form.getId().length()>0){
customguarddef = (CustomGuardDef)getASCustomDataService().getCustomGuardDef(form.getId()).clone();
}else{
customguarddef = CustomGuardDefFactory.createCustomGuardDef();
create = true;
}
String nextAction = req.getParameter("nextAction");
if (nextAction == null || nextAction.length() == 0)
nextAction = "close";
//skipped id because it's readonly.
customguarddef.setName(form.getName());
customguarddef.setClazz(form.getClazz());
customguarddef.setParameter1(form.getParameter1());
customguarddef.setParameter2(form.getParameter2());
customguarddef.setParameter3(form.getParameter3());
customguarddef.setParameter4(form.getParameter4());
customguarddef.setParameter5(form.getParameter5());
customguarddef.setDescription(form.getDescription());
CustomGuardDef updatedCopy = null;
if (create){
updatedCopy = getASCustomDataService().createCustomGuardDef(customguarddef);
}else{
canUpdateCustomGuardDefs(customguarddef, req);
checkCustomGuardDefs(customguarddef, req);
updatedCopy = getASCustomDataService().updateCustomGuardDef(customguarddef);
}
if (nextAction.equalsIgnoreCase("stay")){
res.sendRedirect("ascustomdataCustomGuardDefEdit?ts="+System.currentTimeMillis()+"&pId="+updatedCopy.getId());
}else{
unlockAfterUpdate(customguarddef, req);
res.sendRedirect("ascustomdataCustomGuardDefShow?ts="+System.currentTimeMillis());
}
return null;
}
/**
* Simply unlocks document after updation.
*/
private void unlockAfterUpdate(CustomGuardDef customguarddef, HttpServletRequest req) throws Exception{
if(((LockableObject)customguarddef).isLocked())
unLockCustomGuardDefs(customguarddef, req, false);
}
public ActionCommand ascustomdataCustomGuardDefLock(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
CustomGuardDef customguarddefCurr = id != null && !id.equals("") ? getASCustomDataService().getCustomGuardDef(id) : null;
if(customguarddefCurr != null && customguarddefCurr instanceof LockableObject){
LockableObject lockable = (LockableObject)customguarddefCurr;
DocumentLockingHelper.lock.checkExecutionPermission(lockable,false,getUserId(req));
lockCustomGuardDefs(customguarddefCurr, req);
}
res.sendRedirect(getRedirectUrl(req, customguarddefCurr));
return null;
}
public ActionCommand ascustomdataCustomGuardDefUnLock(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
CustomGuardDef customguarddefCurr = id != null && !id.equals("") ? getASCustomDataService().getCustomGuardDef(id) : null;
if(customguarddefCurr != null && customguarddefCurr instanceof LockableObject){
LockableObject lockable = (LockableObject)customguarddefCurr;
DocumentLockingHelper.unLock.checkExecutionPermission(lockable,isUserInRole(req, "admin"),getUserId(req));
unLockCustomGuardDefs(customguarddefCurr, req, false);
}
res.sendRedirect(getRedirectUrl(req, customguarddefCurr));
return null;
}
/**
* Simplest method for redirect url creation. nextAction == showEdit - going to 'editView', to 'listView' otherwise.
*/
private String getRedirectUrl(HttpServletRequest req, CustomGuardDef item){
String nextAction = req.getParameter("nextAction");
if (item==null || nextAction == null || nextAction.length() == 0)
return "ascustomdataCustomGuardDefShow?ts="+System.currentTimeMillis();
else
return nextAction.equals("showEdit") ? "ascustomdataCustomGuardDefEdit?ts="+System.currentTimeMillis()+"&pId="+item.getId()
: "ascustomdataCustomGuardDefShow?ts="+System.currentTimeMillis();
}
public ActionCommand ascustomdataCustomGuardDefClose(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
CustomGuardDef customguarddefCurr = id != null && !id.equals("") ? getASCustomDataService().getCustomGuardDef(id) : null;
if(customguarddefCurr != null && customguarddefCurr instanceof LockableObject && ((LockableObject)customguarddefCurr).isLocked())
unLockCustomGuardDefs(customguarddefCurr, req, false);
res.sendRedirect("ascustomdataCustomGuardDefShow?ts="+System.currentTimeMillis());
return null;
}
}