View Javadoc

1   /*
2    * Copyright 2004-2006 the Seasar Foundation and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.tuigwaa.controller;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.apache.struts.action.ActionForm;
22  import org.seasar.tuigwaa.security.Action;
23  import org.seasar.tuigwaa.security.SecurityService;
24  import org.seasar.tuigwaa.system.SiteConfig;
25  
26  
27  public class FolderSettingForm extends ActionForm {
28  
29  	private static final long serialVersionUID = 6620340614498295181L;
30  
31  	private List roleFlagList = new ArrayList();
32  
33  	private String siteName;
34  
35  	private String path;
36  
37  	private String[] checkedRoleNames;
38  
39  	public FolderSettingForm(String siteName, String path,
40  			SiteConfig siteConfig, SecurityService securityService) {
41  		this.siteName = siteName;
42  		this.path = path;
43  
44  		String[] roleNames = siteConfig.getRoleNames();
45  
46  		for (int i = 0; i < roleNames.length; i++) {
47  			Action action = Action.PAGE_VIEW.createParameteredAction(path);
48  			boolean flag = securityService.hasPermission(siteName,
49  					roleNames[i], action);
50  			roleFlagList.add(new RoleFlag(roleNames[i], flag));
51  		}
52  	}
53  
54  	public List getRoleFlagList() {
55  		return roleFlagList;
56  	}
57  
58  	public void setCheckedRoleNames(String[] roleNames) {
59  		this.checkedRoleNames = roleNames;
60  	}
61  
62  	public String[] getCheckedRoleNames() {
63  		return checkedRoleNames;
64  	}
65  
66  	public String getSiteName() {
67  		return siteName;
68  	}
69  
70  	public String getPath() {
71  		return path;
72  	}
73  
74  	public class RoleFlag {
75  
76  		private String role;
77  
78  		private boolean flag;
79  
80  		public RoleFlag(String role, boolean flag) {
81  			this.role = role;
82  			this.flag = flag;
83  		}
84  
85  		public String getRole() {
86  			return role;
87  		}
88  
89  		public boolean isFlag() {
90  			return flag;
91  		}
92  	}
93  }