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.anoaccessconfiguration.action.MultiOpDialogContextInitializersAction Maven / Gradle / Ivy
/**
********************************************************************************
*** MultiOpDialogContextInitializersAction.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.anoaccessconfiguration.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.anoaccessconfiguration.data.ContextInitializerFactory;
import net.anotheria.anosite.gen.anoaccessconfiguration.data.ContextInitializer;
import net.anotheria.anosite.gen.anoaccessconfiguration.bean.EditContextInitializerFB;
import net.anotheria.asg.util.bean.PopulateUtility;
import net.anotheria.asg.data.LockableObject;
import net.anotheria.asg.util.locking.helper.DocumentLockingHelper;
public class MultiOpDialogContextInitializersAction extends BaseContextInitializerAction{
// 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("anoaccessconfigurationContextInitializerDelete"))
return anoaccessconfigurationContextInitializerDelete(mapping, req, res);
if (path.equals("anoaccessconfigurationContextInitializerDuplicate"))
return anoaccessconfigurationContextInitializerDuplicate(mapping, req, res);
if (path.equals("anoaccessconfigurationContextInitializerUpdate"))
return anoaccessconfigurationContextInitializerUpdate(mapping, req, res);
if (path.equals("anoaccessconfigurationContextInitializerClose"))
return anoaccessconfigurationContextInitializerClose(mapping, req, res);
if (path.equals("anoaccessconfigurationContextInitializerLock"))
return anoaccessconfigurationContextInitializerLock(mapping, req, res);
if (path.equals("anoaccessconfigurationContextInitializerUnLock"))
return anoaccessconfigurationContextInitializerUnLock(mapping, req, res);
throw new IllegalArgumentException("Unknown path: "+path);
}
public ActionCommand anoaccessconfigurationContextInitializerDelete(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){
ContextInitializer contextinitializerCurr = getAnoAccessConfigurationService().getContextInitializer(id);
if (contextinitializerCurr instanceof LockableObject){
LockableObject lockable = (LockableObject)contextinitializerCurr;
DocumentLockingHelper.delete.checkExecutionPermission(lockable, false, getUserId(req));
}
getAnoAccessConfigurationService().deleteContextInitializer(id);
}
res.sendRedirect("anoaccessconfigurationContextInitializerShow?ts="+System.currentTimeMillis());
return null;
}
public ActionCommand anoaccessconfigurationContextInitializerDuplicate(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
ContextInitializer contextinitializerSrc = getAnoAccessConfigurationService().getContextInitializer(id);
ContextInitializer contextinitializerDest = ContextInitializerFactory.createContextInitializer(contextinitializerSrc);
ContextInitializer contextinitializerCreated = getAnoAccessConfigurationService().createContextInitializer(contextinitializerDest);
res.sendRedirect("anoaccessconfigurationContextInitializerEdit?ts="+System.currentTimeMillis()+"&"+PARAM_ID+"="+contextinitializerCreated.getId());
return null;
}
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateUpdateActionMethod
public ActionCommand anoaccessconfigurationContextInitializerUpdate(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
EditContextInitializerFB form = new EditContextInitializerFB();
PopulateUtility.populate(form, req);
boolean create = false;
ContextInitializer contextinitializer = null;
if (form.getId()==null) {
res.sendRedirect("asresourcedataLocalizationBundleShow?ts="+System.currentTimeMillis());
return null;
}
if (form.getId().length()>0){
contextinitializer = (ContextInitializer)getAnoAccessConfigurationService().getContextInitializer(form.getId()).clone();
}else{
contextinitializer = ContextInitializerFactory.createContextInitializer();
create = true;
}
String nextAction = req.getParameter("nextAction");
if (nextAction == null || nextAction.length() == 0)
nextAction = "close";
//skipped id because it's readonly.
contextinitializer.setName(form.getName());
contextinitializer.setClassName(form.getClassName());
contextinitializer.setDescription(form.getDescription());
ContextInitializer updatedCopy = null;
if (create){
updatedCopy = getAnoAccessConfigurationService().createContextInitializer(contextinitializer);
}else{
canUpdateContextInitializers(contextinitializer, req);
checkContextInitializers(contextinitializer, req);
updatedCopy = getAnoAccessConfigurationService().updateContextInitializer(contextinitializer);
}
if (nextAction.equalsIgnoreCase("stay")){
res.sendRedirect("anoaccessconfigurationContextInitializerEdit?ts="+System.currentTimeMillis()+"&pId="+updatedCopy.getId());
}else{
unlockAfterUpdate(contextinitializer, req);
res.sendRedirect("anoaccessconfigurationContextInitializerShow?ts="+System.currentTimeMillis());
}
return null;
}
/**
* Simply unlocks document after updation.
*/
private void unlockAfterUpdate(ContextInitializer contextinitializer, HttpServletRequest req) throws Exception{
if(((LockableObject)contextinitializer).isLocked())
unLockContextInitializers(contextinitializer, req, false);
}
public ActionCommand anoaccessconfigurationContextInitializerLock(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
ContextInitializer contextinitializerCurr = id != null && !id.equals("") ? getAnoAccessConfigurationService().getContextInitializer(id) : null;
if(contextinitializerCurr != null && contextinitializerCurr instanceof LockableObject){
LockableObject lockable = (LockableObject)contextinitializerCurr;
DocumentLockingHelper.lock.checkExecutionPermission(lockable,false,getUserId(req));
lockContextInitializers(contextinitializerCurr, req);
}
res.sendRedirect(getRedirectUrl(req, contextinitializerCurr));
return null;
}
public ActionCommand anoaccessconfigurationContextInitializerUnLock(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
ContextInitializer contextinitializerCurr = id != null && !id.equals("") ? getAnoAccessConfigurationService().getContextInitializer(id) : null;
if(contextinitializerCurr != null && contextinitializerCurr instanceof LockableObject){
LockableObject lockable = (LockableObject)contextinitializerCurr;
DocumentLockingHelper.unLock.checkExecutionPermission(lockable,isUserInRole(req, "admin"),getUserId(req));
unLockContextInitializers(contextinitializerCurr, req, false);
}
res.sendRedirect(getRedirectUrl(req, contextinitializerCurr));
return null;
}
/**
* Simplest method for redirect url creation. nextAction == showEdit - going to 'editView', to 'listView' otherwise.
*/
private String getRedirectUrl(HttpServletRequest req, ContextInitializer item){
String nextAction = req.getParameter("nextAction");
if (item==null || nextAction == null || nextAction.length() == 0)
return "anoaccessconfigurationContextInitializerShow?ts="+System.currentTimeMillis();
else
return nextAction.equals("showEdit") ? "anoaccessconfigurationContextInitializerEdit?ts="+System.currentTimeMillis()+"&pId="+item.getId()
: "anoaccessconfigurationContextInitializerShow?ts="+System.currentTimeMillis();
}
public ActionCommand anoaccessconfigurationContextInitializerClose(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
ContextInitializer contextinitializerCurr = id != null && !id.equals("") ? getAnoAccessConfigurationService().getContextInitializer(id) : null;
if(contextinitializerCurr != null && contextinitializerCurr instanceof LockableObject && ((LockableObject)contextinitializerCurr).isLocked())
unLockContextInitializers(contextinitializerCurr, req, false);
res.sendRedirect("anoaccessconfigurationContextInitializerShow?ts="+System.currentTimeMillis());
return null;
}
}