📄 permissionhelper.java
字号:
package cn.myapps.core.permission.action;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import cn.myapps.core.permission.ejb.PermissionPackage;
import cn.myapps.core.resource.ejb.ResourceProcess;
import cn.myapps.core.resource.ejb.ResourceVO;
import cn.myapps.core.user.action.WebUser;
import cn.myapps.util.ProcessFactory;
public class PermissionHelper {
public WebUser user;
public boolean checkPermission(ResourceVO r) throws ClassNotFoundException {
return PermissionPackage.checkPermission(r, user);
}
public WebUser getUser() {
return user;
}
public void setUser(WebUser user) {
this.user = user;
}
public Collection get_protectResources(String application) throws Exception {
ResourceProcess rp = (ResourceProcess) ProcessFactory
.createProcess(ResourceProcess.class);
return rp.getProtectResources(application);
}
public String getResourceDspHtml() throws Exception {
String html = "";
return null;
}
public String get_childResourcesString(ResourceVO vo, int t, String application)
throws Exception {
String html = "";
Collection childs = get_childResources(vo, application);
if (childs != null && childs.size() > 0) {
html += "<table>";
html += "<tr><td class='commFont'>";
int temp = t;
while (temp > 0) {
html += "*";
temp--;
}
html += "<input type='checkbox' name='_resourcelist' value='"
+ vo.getId() + "' />";
html += vo.getDescription();
html += "</td></tr>";
for (Iterator iter = childs.iterator(); iter.hasNext();) {
html += "<tr>";
for (int i = 0; i < 5 && iter.hasNext(); i++) {
ResourceVO rv = (ResourceVO) iter.next();
if (rv.getSuperior() != null
&& rv.getSuperior().getId().equals(vo.getId())) {
html += "<td style=\"vertical-align:top\" class=\"commFont\">";
html += get_childResourcesString(rv, t + 1, application);
html += "</td>";
}
}
html += "</tr>";
}
html += "</table>";
} else {
html += "<table>";
html += "<tr><td class=\"commFont\">";
while (t > 0) {
html += "*";
t--;
}
html += "<input type='checkbox' name='_resourcelist' value='"
+ vo.getId() + "' />";
html += vo.getDescription();
html += "</td></tr>";
html += "</table>";
}
return html;
}
public Collection get_childResources(ResourceVO vo, String application)
throws Exception {
if (vo == null)
return null;
ResourceProcess rp = (ResourceProcess) ProcessFactory
.createProcess(ResourceProcess.class);
Map childs = new HashMap();
Collection rs = rp.getProtectResources(application);
for (Iterator iter = rs.iterator(); iter.hasNext();) {
ResourceVO em = (ResourceVO) iter.next();
if (em.getSuperior() != null
&& em.getSuperior().getId().equals(vo.getId())) {
childs.put(em.getId(), em);
}
}
return childs.values();
}
/*
* public Collection get_childResources(Collection col)throws Exception {
*
* ResourceProcess rp = (ResourceProcess)ProcessFactory
* .createProcess(ResourceProcess.class); Collection
* ps=rp.getProtectResources(); for (Iterator iter = col.iterator();
* iter.hasNext();) { ResourceVO rv = (ResourceVO) iter.next(); for
* (Iterator iterator = ps.iterator(); iterator.hasNext();) { ResourceVO em =
* (ResourceVO) iterator.next(); if(em.getSuperior()!=null&&) } } }
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -