All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.anotheria.anosite.gen.asuserdata.action.MultiOpDialogRoleDefsAction Maven / Gradle / Ivy

There is a newer version: 4.1.2
Show newest version
/**
 ********************************************************************************
 *** MultiOpDialogRoleDefsAction.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.asuserdata.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.asuserdata.data.RoleDefFactory;
import net.anotheria.anosite.gen.asuserdata.data.RoleDef;
import net.anotheria.anosite.gen.asuserdata.bean.EditRoleDefFB;
import net.anotheria.asg.data.LockableObject;
import net.anotheria.asg.util.locking.helper.DocumentLockingHelper;
import net.anotheria.maf.bean.annotations.Form;


public class MultiOpDialogRoleDefsAction extends BaseRoleDefAction{

	// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateMultiOpDialogAction


	@Override
	public ActionForward execute(ActionMapping mapping, @Form(EditRoleDefFB.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("asuserdataRoleDefDelete"))
			return asuserdataRoleDefDelete(mapping, af, req, res);
		if (path.equals("asuserdataRoleDefDuplicate"))
			return asuserdataRoleDefDuplicate(mapping, af, req, res);
		if (path.equals("asuserdataRoleDefUpdate"))
			return asuserdataRoleDefUpdate(mapping, af, req, res);
		if (path.equals("asuserdataRoleDefClose"))
			return asuserdataRoleDefClose(mapping, af, req, res);
		if (path.equals("asuserdataRoleDefLock"))
			return asuserdataRoleDefLock(mapping, af, req, res);
		if (path.equals("asuserdataRoleDefUnLock"))
			return asuserdataRoleDefUnLock(mapping, af, req, res);
		throw new IllegalArgumentException("Unknown path: "+path);
	}

	public ActionForward asuserdataRoleDefDelete(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){
		RoleDef roledefCurr = getASUserDataService().getRoleDef(id);
		if (roledefCurr instanceof LockableObject){ 
		LockableObject lockable = (LockableObject)roledefCurr;
		DocumentLockingHelper.delete.checkExecutionPermission(lockable, false, getUserId(req));
		}
		getASUserDataService().deleteRoleDef(id);
	}
	res.sendRedirect("asuserdataRoleDefShow?ts="+System.currentTimeMillis());
	return null;
}

public ActionForward asuserdataRoleDefDuplicate(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
	String id = getStringParameter(req, PARAM_ID);
	RoleDef roledefSrc = getASUserDataService().getRoleDef(id);
	RoleDef roledefDest = RoleDefFactory.createRoleDef(roledefSrc);


	RoleDef roledefCreated = getASUserDataService().createRoleDef(roledefDest);
	res.sendRedirect("asuserdataRoleDefEdit?ts="+System.currentTimeMillis()+"&"+PARAM_ID+"="+roledefCreated.getId());

	return null;
}

// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateUpdateActionMethod

public ActionForward asuserdataRoleDefUpdate(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
	EditRoleDefFB form = (EditRoleDefFB) af;
	boolean create = false;
	RoleDef roledef = null;
	if (form.getId()==null) {
	res.sendRedirect("asresourcedataLocalizationBundleShow?ts="+System.currentTimeMillis());
	return null;
}
if (form.getId().length()>0){
	roledef = (RoleDef)getASUserDataService().getRoleDef(form.getId()).clone();
}else{
	roledef = RoleDefFactory.createRoleDef();
	create = true;
}

String nextAction = req.getParameter("nextAction");
if (nextAction == null || nextAction.length() == 0)
	nextAction = "close";

//skipped id because it's readonly.
roledef.setName(form.getName());

RoleDef updatedCopy = null;
if (create){
	updatedCopy = getASUserDataService().createRoleDef(roledef);
}else{
	canUpdateRoleDefs(roledef, req);
	checkRoleDefs(roledef, req);
	updatedCopy = getASUserDataService().updateRoleDef(roledef);
}
if (nextAction.equalsIgnoreCase("stay")){
	res.sendRedirect("asuserdataRoleDefEdit?ts="+System.currentTimeMillis()+"&pId="+updatedCopy.getId());
}else{
	unlockAfterUpdate(roledef, req);
	res.sendRedirect("asuserdataRoleDefShow?ts="+System.currentTimeMillis());
}
return null;
}
/**
 * Simply unlocks document after updation.
 */
private void unlockAfterUpdate(RoleDef roledef, HttpServletRequest req) throws Exception{
	if(((LockableObject)roledef).isLocked())
		unLockRoleDefs(roledef, req, false);
}

public ActionForward asuserdataRoleDefLock(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
	String id = getStringParameter(req, PARAM_ID);
	RoleDef roledefCurr = id != null && !id.equals("") ? getASUserDataService().getRoleDef(id) : null;
	if(roledefCurr != null && roledefCurr instanceof LockableObject){ 
		LockableObject lockable = (LockableObject)roledefCurr;
		DocumentLockingHelper.lock.checkExecutionPermission(lockable,false,getUserId(req));
		lockRoleDefs(roledefCurr, req);
	}
	res.sendRedirect(getRedirectUrl(req, roledefCurr));
	return null;
}

public ActionForward asuserdataRoleDefUnLock(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
	String id = getStringParameter(req, PARAM_ID);
	RoleDef roledefCurr = id != null && !id.equals("") ? getASUserDataService().getRoleDef(id) : null;
	if(roledefCurr != null && roledefCurr instanceof LockableObject){ 
		LockableObject lockable = (LockableObject)roledefCurr;
		DocumentLockingHelper.unLock.checkExecutionPermission(lockable,isUserInRole(req, "admin"),getUserId(req));
		unLockRoleDefs(roledefCurr, req, false);
	}
	res.sendRedirect(getRedirectUrl(req, roledefCurr));
	return null;
}

/**
 * Simplest method for redirect url creation. nextAction == showEdit - going to 'editView', to 'listView' otherwise. 
 */
private String getRedirectUrl(HttpServletRequest req, RoleDef item){
	String nextAction = req.getParameter("nextAction");
	if (item==null || nextAction == null || nextAction.length() == 0)
		return "asuserdataRoleDefShow?ts="+System.currentTimeMillis();
	else
		return nextAction.equals("showEdit") ? "asuserdataRoleDefEdit?ts="+System.currentTimeMillis()+"&pId="+item.getId()
		       : "asuserdataRoleDefShow?ts="+System.currentTimeMillis();
}

public ActionForward asuserdataRoleDefClose(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
	String id = getStringParameter(req, PARAM_ID);
	RoleDef roledefCurr = id != null && !id.equals("") ? getASUserDataService().getRoleDef(id) : null;
	if(roledefCurr != null && roledefCurr instanceof LockableObject && ((LockableObject)roledefCurr).isLocked()) 
		unLockRoleDefs(roledefCurr, req, false);
	res.sendRedirect("asuserdataRoleDefShow?ts="+System.currentTimeMillis());
	return null;
}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy