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.MultiOpRolesPermissionsAction Maven / Gradle / Ivy
/**
********************************************************************************
*** MultiOpRolesPermissionsAction.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.anoaccessconfiguration.action;
import java.util.List;
import java.util.ArrayList;
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 net.anotheria.anosite.gen.anoaccessconfiguration.data.RoleFactory;
import net.anotheria.anosite.gen.anoaccessconfiguration.data.Role;
import net.anotheria.anosite.gen.anoaccessconfiguration.bean.PermissionsElementFB;
import net.anotheria.anosite.gen.anoaccessconfiguration.bean.PermissionsQuickAddFB;
import net.anotheria.anosite.gen.anoaccessconfiguration.data.Permission;
import net.anotheria.anosite.gen.anoaccessconfiguration.data.PermissionSortType;
import net.anotheria.webutils.bean.LabelValueBean;
import net.anotheria.anodoc.data.NoSuchDocumentException;
import net.anotheria.util.StringUtils;
import net.anotheria.asg.exception.ASGRuntimeException;
public class MultiOpRolesPermissionsAction extends BaseRoleAction{
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateContainerMultiOpAction
public ActionForward anoDocExecute(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
String path = stripPath(mapping.getPath());
if (path.equals("anoaccessconfigurationRolePermissionsShow"))
return anoaccessconfigurationRolePermissionsShow(mapping, af, req, res);
if (path.equals("anoaccessconfigurationRolePermissionsAdd"))
return anoaccessconfigurationRolePermissionsAdd(mapping, af, req, res);
if (path.equals("anoaccessconfigurationRolePermissionsDelete"))
return anoaccessconfigurationRolePermissionsDelete(mapping, af, req, res);
if (path.equals("anoaccessconfigurationRolePermissionsMove"))
return anoaccessconfigurationRolePermissionsMove(mapping, af, req, res);
if (path.equals("anoaccessconfigurationRolePermissionsQuickAdd"))
return anoaccessconfigurationRolePermissionsQuickAdd(mapping, af, req, res);
throw new IllegalArgumentException("Unknown path: "+path);
}
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateListShowActionMethod
public ActionForward anoaccessconfigurationRolePermissionsShow(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, "ownerId");
Role role = getAnoAccessConfigurationService().getRole(id);
addBeanToRequest(req, "ownerId", id);
checkRoles(role, req);
PermissionsElementFB form = new PermissionsElementFB() ;
form.setPosition(-1);
form.setOwnerId(role.getId());
addBeanToRequest(req, "anoaccessconfigurationRolePermissionsElementForm", form);
PermissionsQuickAddFB quickAddForm = new PermissionsQuickAddFB() ;
quickAddForm.setOwnerId(role.getId());
addBeanToRequest(req, "anoaccessconfigurationRolePermissionsQuickAddForm", quickAddForm);
//link permission to AnoAccessConfiguration.Permission
List permissions = getAnoAccessConfigurationService().getPermissions(new PermissionSortType(PermissionSortType.SORT_BY_NAME));
List permissionsValues = new ArrayList(permissions.size());
for (int i=0; i beans = new ArrayList(size);
for (int i=0; i targetList = role.getPermissions();
String toSwap = targetList.remove(position);
targetList.add(0, toSwap);
role.setPermissions(targetList);
getAnoAccessConfigurationService().updateRole(role);
}
private void moveDown(Role role, int position) throws ASGRuntimeException {
if (position targetList = role.getPermissions();
String toSwap = targetList.remove(position);
targetList.add(toSwap);
role.setPermissions(targetList);
getAnoAccessConfigurationService().updateRole(role);
}
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateListAddRowActionMethod
public ActionForward anoaccessconfigurationRolePermissionsAdd(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
PermissionsElementFB form = new PermissionsElementFB();
populateFormBean(req, form);
String id = form.getOwnerId();
Role role;
role = getAnoAccessConfigurationService().getRole(id);
canUpdateRoles(role, req);
checkRoles(role, req);
role.addPermissionsElement(form.getPermission());
getAnoAccessConfigurationService().updateRole(role);
return anoaccessconfigurationRolePermissionsShow(mapping, af, req, res);
}
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateListQuickAddActionMethod
public ActionForward anoaccessconfigurationRolePermissionsQuickAdd(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
PermissionsQuickAddFB form = new PermissionsQuickAddFB();
populateFormBean(req, form);
String id = form.getOwnerId();
Role role;
role = getAnoAccessConfigurationService().getRole(id);
canUpdateRoles(role, req);
checkRoles(role, req);
String paramIdsToAdd = form.getQuickAddIds();
String idParameters[] = StringUtils.tokenize(paramIdsToAdd, ',');
for (String anIdParam : idParameters){
String ids[] = StringUtils.tokenize(anIdParam, '-');
for (int i=Integer.parseInt(ids[0]); i<=Integer.parseInt(ids[ids.length-1]); i++){
role.addPermissionsElement(""+i);
}
}
getAnoAccessConfigurationService().updateRole(role);
return anoaccessconfigurationRolePermissionsShow(mapping, af, req, res);
}
}