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.asgenericaction.action.MultiOpDialogGenericActionDefsAction Maven / Gradle / Ivy
/**
********************************************************************************
*** MultiOpDialogGenericActionDefsAction.java ***
*** generated by AnoSiteGenerator (ASG), Version: 2.6.3 ***
*** Copyright (C) 2005 - 2010 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.asgenericaction.action;
import net.anotheria.util.NumberUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.anotheria.maf.action.ActionForward;
import net.anotheria.maf.action.ActionMapping;
import net.anotheria.maf.bean.FormBean;
import java.util.List;
import java.util.ArrayList;
import net.anotheria.anosite.gen.asgenericaction.data.GenericActionDefFactory;
import net.anotheria.anosite.gen.asgenericaction.data.GenericActionDef;
import net.anotheria.anosite.gen.asgenericaction.bean.EditGenericActionDefFB;
import net.anotheria.asg.data.LockableObject;
import net.anotheria.asg.util.locking.helper.DocumentLockingHelper;
import net.anotheria.maf.bean.annotations.Form;
public class MultiOpDialogGenericActionDefsAction extends BaseGenericActionDefAction{
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateMultiOpDialogAction
@Override
public ActionForward execute(ActionMapping mapping, @Form(EditGenericActionDefFB.class) FormBean formBean, HttpServletRequest req, HttpServletResponse res) throws Exception{
return super.execute(mapping, formBean, req, res);
} //execute
public ActionForward anoDocExecute(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
String path = stripPath(mapping.getPath());
if (path.equals("asgenericactionGenericActionDefDelete"))
return asgenericactionGenericActionDefDelete(mapping, af, req, res);
if (path.equals("asgenericactionGenericActionDefDuplicate"))
return asgenericactionGenericActionDefDuplicate(mapping, af, req, res);
if (path.equals("asgenericactionGenericActionDefUpdate"))
return asgenericactionGenericActionDefUpdate(mapping, af, req, res);
if (path.equals("asgenericactionGenericActionDefClose"))
return asgenericactionGenericActionDefClose(mapping, af, req, res);
if (path.equals("asgenericactionGenericActionDefLock"))
return asgenericactionGenericActionDefLock(mapping, af, req, res);
if (path.equals("asgenericactionGenericActionDefUnLock"))
return asgenericactionGenericActionDefUnLock(mapping, af, req, res);
throw new IllegalArgumentException("Unknown path: "+path);
}
public ActionForward asgenericactionGenericActionDefDelete(ActionMapping mapping, FormBean af, 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){
GenericActionDef genericactiondefCurr = getASGenericActionService().getGenericActionDef(id);
if (genericactiondefCurr instanceof LockableObject){
LockableObject lockable = (LockableObject)genericactiondefCurr;
DocumentLockingHelper.delete.checkExecutionPermission(lockable, false, getUserId(req));
}
getASGenericActionService().deleteGenericActionDef(id);
}
res.sendRedirect("asgenericactionGenericActionDefShow?ts="+System.currentTimeMillis());
return null;
}
public ActionForward asgenericactionGenericActionDefDuplicate(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
GenericActionDef genericactiondefSrc = getASGenericActionService().getGenericActionDef(id);
GenericActionDef genericactiondefDest = GenericActionDefFactory.createGenericActionDef(genericactiondefSrc);
GenericActionDef genericactiondefCreated = getASGenericActionService().createGenericActionDef(genericactiondefDest);
res.sendRedirect("asgenericactionGenericActionDefEdit?ts="+System.currentTimeMillis()+"&"+PARAM_ID+"="+genericactiondefCreated.getId());
return null;
}
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateUpdateActionMethod
public ActionForward asgenericactionGenericActionDefUpdate(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
EditGenericActionDefFB form = (EditGenericActionDefFB) af;
boolean create = false;
GenericActionDef genericactiondef = null;
if (form.getId()==null) {
res.sendRedirect("asresourcedataLocalizationBundleShow?ts="+System.currentTimeMillis());
return null;
}
if (form.getId().length()>0){
genericactiondef = (GenericActionDef)getASGenericActionService().getGenericActionDef(form.getId()).clone();
}else{
genericactiondef = GenericActionDefFactory.createGenericActionDef();
create = true;
}
String nextAction = req.getParameter("nextAction");
if (nextAction == null || nextAction.length() == 0)
nextAction = "close";
//skipped id because it's readonly.
genericactiondef.setName(form.getName());
genericactiondef.setClazz(form.getClazz());
GenericActionDef updatedCopy = null;
if (create){
updatedCopy = getASGenericActionService().createGenericActionDef(genericactiondef);
}else{
canUpdateGenericActionDefs(genericactiondef, req);
checkGenericActionDefs(genericactiondef, req);
updatedCopy = getASGenericActionService().updateGenericActionDef(genericactiondef);
}
if (nextAction.equalsIgnoreCase("stay")){
res.sendRedirect("asgenericactionGenericActionDefEdit?ts="+System.currentTimeMillis()+"&pId="+updatedCopy.getId());
}else{
unlockAfterUpdate(genericactiondef, req);
res.sendRedirect("asgenericactionGenericActionDefShow?ts="+System.currentTimeMillis());
}
return null;
}
/**
* Simply unlocks document after updation.
*/
private void unlockAfterUpdate(GenericActionDef genericactiondef, HttpServletRequest req) throws Exception{
if(((LockableObject)genericactiondef).isLocked())
unLockGenericActionDefs(genericactiondef, req, false);
}
public ActionForward asgenericactionGenericActionDefLock(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
GenericActionDef genericactiondefCurr = id != null && !id.equals("") ? getASGenericActionService().getGenericActionDef(id) : null;
if(genericactiondefCurr != null && genericactiondefCurr instanceof LockableObject){
LockableObject lockable = (LockableObject)genericactiondefCurr;
DocumentLockingHelper.lock.checkExecutionPermission(lockable,false,getUserId(req));
lockGenericActionDefs(genericactiondefCurr, req);
}
res.sendRedirect(getRedirectUrl(req, genericactiondefCurr));
return null;
}
public ActionForward asgenericactionGenericActionDefUnLock(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
GenericActionDef genericactiondefCurr = id != null && !id.equals("") ? getASGenericActionService().getGenericActionDef(id) : null;
if(genericactiondefCurr != null && genericactiondefCurr instanceof LockableObject){
LockableObject lockable = (LockableObject)genericactiondefCurr;
DocumentLockingHelper.unLock.checkExecutionPermission(lockable,isUserInRole(req, "admin"),getUserId(req));
unLockGenericActionDefs(genericactiondefCurr, req, false);
}
res.sendRedirect(getRedirectUrl(req, genericactiondefCurr));
return null;
}
/**
* Simplest method for redirect url creation. nextAction == showEdit - going to 'editView', to 'listView' otherwise.
*/
private String getRedirectUrl(HttpServletRequest req, GenericActionDef item){
String nextAction = req.getParameter("nextAction");
if (item==null || nextAction == null || nextAction.length() == 0)
return "asgenericactionGenericActionDefShow?ts="+System.currentTimeMillis();
else
return nextAction.equals("showEdit") ? "asgenericactionGenericActionDefEdit?ts="+System.currentTimeMillis()+"&pId="+item.getId()
: "asgenericactionGenericActionDefShow?ts="+System.currentTimeMillis();
}
public ActionForward asgenericactionGenericActionDefClose(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
GenericActionDef genericactiondefCurr = id != null && !id.equals("") ? getASGenericActionService().getGenericActionDef(id) : null;
if(genericactiondefCurr != null && genericactiondefCurr instanceof LockableObject && ((LockableObject)genericactiondefCurr).isLocked())
unLockGenericActionDefs(genericactiondefCurr, req, false);
res.sendRedirect("asgenericactionGenericActionDefShow?ts="+System.currentTimeMillis());
return null;
}
}