pioneer
2 years ago
commit
303b0c3419
6 changed files with 326 additions and 0 deletions
Binary file not shown.
@ -0,0 +1,6 @@
|
||||
# open-JSD-10401 |
||||
|
||||
JSD-10401 客户pc端使用的我们的fs,配置的fs目录权限。移动端自己的app使用的我们的h5报表,移动端想传入过来用户 然后返回用户对应的目录数据\ |
||||
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ |
||||
仅作为开发者学习参考使用!禁止用于任何商业用途!\ |
||||
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系【pioneer】处理。 |
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin> |
||||
<id>com.fr.plugin.permission10</id> |
||||
<name><![CDATA[获取权限请求]]></name> |
||||
<active>yes</active> |
||||
<version>1.0</version> |
||||
<env-version>10.0</env-version> |
||||
<jartime>2018-07-31</jartime> |
||||
<vendor>fr.open</vendor> |
||||
<description><![CDATA[]]></description> |
||||
<change-notes><![CDATA[2018-02-26修复了空目录的bug]]></change-notes> |
||||
<extra-core> |
||||
<WebService class="com.fr.plugin.permission.PermissionServer"/> |
||||
</extra-core> |
||||
<extra-designer> |
||||
</extra-designer> |
||||
|
||||
<function-recorder class="com.fr.plugin.permission.PermissionMonitor"/> |
||||
<lifecycle-monitor class="com.fr.plugin.permission.PermissionMonitor"/> |
||||
</plugin> |
@ -0,0 +1,24 @@
|
||||
package com.fr.plugin.permission; |
||||
|
||||
import com.fr.intelli.record.Focus; |
||||
import com.fr.intelli.record.Original; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.context.PluginContext; |
||||
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor; |
||||
import com.fr.plugin.transform.FunctionRecorder; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
|
||||
@EnableMetrics |
||||
@FunctionRecorder |
||||
public class PermissionMonitor extends AbstractPluginLifecycleMonitor { |
||||
|
||||
@Focus(id = "com.fr.plugin.permission10", text = "permission10", source = Original.PLUGIN) |
||||
public void afterRun(PluginContext pluginContext) { |
||||
FineLoggerFactory.getLogger().info( "获取权限请求插件启动完成"); |
||||
} |
||||
|
||||
|
||||
public void beforeStop(PluginContext pluginContext) { |
||||
FineLoggerFactory.getLogger().info("获取权限请求插件即将停止"); |
||||
} |
||||
} |
@ -0,0 +1,26 @@
|
||||
package com.fr.plugin.permission; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
import com.fr.plugin.permission.action.DirectoryPath; |
||||
import com.fr.stable.fun.Service; |
||||
import com.fr.stable.web.RequestCMDReceiver; |
||||
import com.fr.web.core.WebActionsDispatcher; |
||||
|
||||
public class PermissionServer implements Service { |
||||
private static RequestCMDReceiver[] actions = { |
||||
new DirectoryPath() |
||||
}; |
||||
|
||||
@Override |
||||
public String actionOP() { |
||||
return "permission"; |
||||
} |
||||
|
||||
@Override |
||||
public void process(HttpServletRequest req, HttpServletResponse res, String op, String sessionid) throws Exception { |
||||
WebActionsDispatcher.dealForActionCMD(req, res, sessionid, actions); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,251 @@
|
||||
package com.fr.plugin.permission.action; |
||||
import java.io.PrintWriter; |
||||
import java.util.*; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
import com.fr.decision.webservice.bean.entry.EntryBean; |
||||
import com.fr.decision.webservice.bean.entry.HomePageBean; |
||||
import com.fr.decision.webservice.bean.entry.TemplateBean; |
||||
import com.fr.decision.webservice.v10.entry.EntryService; |
||||
import com.fr.decision.authority.data.User; |
||||
import com.fr.decision.webservice.v10.user.UserService; |
||||
import com.fr.fs.cache.EntryTypeAndID; |
||||
import com.fr.fs.cache.decision.category.impl.memory.EntryTreeFolderNode; |
||||
import com.fr.fs.control.EntryControl; |
||||
import com.fr.fs.control.UserControl; |
||||
import com.fr.fs.privilege.base.FSPrivilegeTools; |
||||
import com.fr.fs.schedule.entry.ReportletEntry; |
||||
import com.fr.fs.web.platform.entry.Entry; |
||||
import com.fr.fs.web.platform.entry.EntryConstants; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.FRLogger; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONException; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.CodeUtils; |
||||
import com.fr.stable.StableUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.web.core.ActionNoSessionCMD; |
||||
import com.fr.web.utils.WebUtils; |
||||
//http://localhost:8075/webroot/decision/view/report?op=permission&cmd=display&user=eoco
|
||||
public class DirectoryPath extends ActionNoSessionCMD { |
||||
private static String paraPath="&__bypagesize__=false&op=h5&username="; |
||||
private static String domain="https://xxx.com.cn"; |
||||
@Override |
||||
public String getCMD() { |
||||
return "display"; |
||||
} |
||||
@Override |
||||
public void actionCMD(HttpServletRequest req, HttpServletResponse res) throws Exception { |
||||
PrintWriter out = WebUtils.createPrintWriter(res); |
||||
getDisplay(req, out); |
||||
out.flush(); |
||||
out.close(); |
||||
} |
||||
|
||||
private int getId(String id){ |
||||
String[] ids = id.split("-"); |
||||
String last = ids[ids.length -1]; |
||||
try{ |
||||
int a = Integer.parseInt(last); |
||||
return a; |
||||
} |
||||
catch(Exception ex){ |
||||
ex.printStackTrace(); |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
protected void getDisplay(HttpServletRequest req,PrintWriter print){ |
||||
String username = WebUtils.getHTTPRequestParameter(req, "user"); |
||||
String callback=WebUtils.getHTTPRequestParameter(req, "callback"); |
||||
com.fr.json.JSONObject outObject= com.fr.json.JSONObject.create(); |
||||
JSONArray result=JSONArray.create(); |
||||
try { |
||||
User user = UserService.getInstance().getUserByUserName(username); |
||||
if(user==null){ |
||||
outObject.put("reportlets", result); |
||||
String out=StringUtils.isBlank(callback)?outObject.toString():callback+"("+outObject.toString()+")"; |
||||
print.write(out); |
||||
return; |
||||
} |
||||
|
||||
List<EntryBean> entryBeans2 = EntryService.getInstance().getAllEntries(user.getId()); |
||||
|
||||
if(entryBeans2.size() > 0){ |
||||
|
||||
Map<String,DirNode> idEntryBeanMap = new HashMap<>(); |
||||
List<DirNode> allNodes = new ArrayList<>(); |
||||
for(EntryBean bean : entryBeans2){ |
||||
DirNode dirNode = new DirNode(); |
||||
dirNode.id = bean.getId(); |
||||
dirNode.pid = bean.getpId(); |
||||
dirNode.text = bean.getText(); |
||||
dirNode.path = bean.getPath(); |
||||
dirNode.child = new ArrayList<>(); |
||||
idEntryBeanMap.put(dirNode.id ,dirNode); |
||||
allNodes.add(dirNode); |
||||
} |
||||
|
||||
List<DirNode> noParentNodes = new ArrayList<>(); |
||||
|
||||
for(DirNode dNode : allNodes){ |
||||
DirNode parent = idEntryBeanMap.get(dNode.pid); |
||||
if(parent != null){ |
||||
parent.child.add(dNode); |
||||
} |
||||
else{ |
||||
dNode.text = "管理目录"; |
||||
noParentNodes.add(dNode); |
||||
} |
||||
} |
||||
iterateChild(result,noParentNodes,req,username); |
||||
FineLoggerFactory.getLogger().info( "noParentNodes:"+noParentNodes.size()); |
||||
} |
||||
|
||||
|
||||
|
||||
if(result.length() > 0){ |
||||
com.fr.json.JSONObject re = (com.fr.json.JSONObject)result.get(0); |
||||
JSONArray result1 = (JSONArray)re.get("child"); |
||||
if(result1 != null){ |
||||
outObject.put("reportlets",result1); |
||||
} |
||||
else{ |
||||
outObject.put("reportlets",JSONArray.create()); |
||||
} |
||||
} |
||||
else{ |
||||
outObject.put("reportlets",JSONArray.create()); |
||||
} |
||||
|
||||
|
||||
String out=StringUtils.isBlank(callback)?outObject.toString():callback+"("+outObject.toString()+")"; |
||||
print.write(out); |
||||
} catch (Exception e) { |
||||
FRLogger.getLogger().errorWithServerLevel(e.getMessage(), e); |
||||
} |
||||
} |
||||
|
||||
private void iterateChild(JSONArray result,List<DirNode> nodes,HttpServletRequest req,String username) throws JSONException { |
||||
for(DirNode node : nodes){ |
||||
com.fr.json.JSONObject childJson = com.fr.json.JSONObject.create(); |
||||
result.put(childJson); |
||||
childJson.put("id", getId(node.id)); |
||||
childJson.put("name", node.text); |
||||
childJson.put("url", getNewUrlByPath(req,username,node.path)); |
||||
JSONArray resultChilds = JSONArray.create(); |
||||
childJson.put("child",resultChilds); |
||||
if(node.child != null && node.child.size() > 0){ |
||||
iterateChild(resultChilds,node.child,req,username); |
||||
} |
||||
|
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 得到新的url |
||||
* @param req |
||||
* @param type |
||||
* @param id |
||||
* @param username |
||||
* @return |
||||
*/ |
||||
protected String getUrl(HttpServletRequest req,int type,long id,String username){ |
||||
String url=""; |
||||
Entry entry = EntryControl.getInstance().getEntry(type, id); |
||||
if(entry instanceof ReportletEntry){ |
||||
ReportletEntry re=(ReportletEntry)entry; |
||||
url=re.getWebletPath(); |
||||
String reportpara="reportlet="; |
||||
if(url.endsWith(".frm")){ |
||||
reportpara="formlet="; |
||||
} |
||||
url=domain+req.getRequestURI().toString()+"?"+reportpara+url+paraPath+username; |
||||
} |
||||
return CodeUtils.cjkEncode(url); |
||||
} |
||||
|
||||
protected String getNewUrlByEntryBean(HttpServletRequest req,String username,EntryBean bean){ |
||||
String url=""; |
||||
if(bean != null){ |
||||
if(bean instanceof HomePageBean) { |
||||
HomePageBean re = (HomePageBean) bean; |
||||
url = re.getMobileHomePage(); |
||||
if (StringUtils.isEmpty(url)) { |
||||
url = re.getPcHomePage(); |
||||
} |
||||
if (StringUtils.isEmpty(url)) { |
||||
url = re.getPadHomePage(); |
||||
} |
||||
String reportpara = "reportlet="; |
||||
if (url.endsWith(".frm")) { |
||||
reportpara = "formlet="; |
||||
} |
||||
url = domain + req.getRequestURI().toString() + "?" + reportpara + url + paraPath + username; |
||||
} |
||||
} |
||||
|
||||
return CodeUtils.cjkEncode(url); |
||||
} |
||||
|
||||
|
||||
protected String getNewUrlByPath(HttpServletRequest req,String username,String path){ |
||||
String url=""; |
||||
if(StringUtils.isNotEmpty(path)){ |
||||
url = path; |
||||
String reportpara = "reportlet="; |
||||
if (url.endsWith(".frm")) { |
||||
reportpara = "formlet="; |
||||
} |
||||
url = domain + req.getRequestURI().toString() + "?" + reportpara + url + paraPath + username; |
||||
} |
||||
|
||||
return CodeUtils.cjkEncode(url); |
||||
} |
||||
/** |
||||
* 的到新的JSONArray |
||||
* @param req |
||||
* @param oldArr |
||||
* @param resultArr |
||||
* @param username |
||||
* @throws JSONException |
||||
*/ |
||||
protected void copyJSONArray(HttpServletRequest req,JSONArray oldArr,JSONArray resultArr,String username) throws JSONException{ |
||||
int len=oldArr.length(); |
||||
for(int i=0;i<len;i++){ |
||||
com.fr.json.JSONObject oldObj=oldArr.getJSONObject(i); |
||||
com.fr.json.JSONObject resultObj= com.fr.json.JSONObject.create(); |
||||
String id=oldObj.optString("id").substring(1);//去掉第一位的,第一位是type
|
||||
// System.out.println(">>>>>> id:"+id);
|
||||
resultObj.put("id", id); |
||||
resultObj.put("name", oldObj.optString("text")); |
||||
JSONArray resultChilds=JSONArray.create(); |
||||
if(oldObj.optBoolean("hasChildren")&&oldObj.has("ChildNodes")){ |
||||
JSONArray childs=oldObj.getJSONArray("ChildNodes"); |
||||
copyJSONArray(req,childs,resultChilds,username); |
||||
} |
||||
String url=getUrl(req,oldObj.optInt("type"), Long.valueOf(id),username); |
||||
resultObj.put("url", url); |
||||
resultObj.put("child", resultChilds); |
||||
|
||||
resultArr.put(resultObj); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
class DirNode{ |
||||
public String id; |
||||
public String pid; |
||||
|
||||
public String text; |
||||
public String path; |
||||
|
||||
public DirNode parent; |
||||
|
||||
public List<DirNode> child; |
||||
|
||||
|
||||
} |
Loading…
Reference in new issue