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

com.logicbus.service.AclQuery Maven / Gradle / Ivy

There is a newer version: 1.6.16
Show newest version
package com.logicbus.service;

import java.util.HashMap;
import java.util.Map;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

import com.anysoft.util.JsonTools;
import com.anysoft.util.Settings;
import com.anysoft.util.XmlTools;
import com.logicbus.backend.AbstractServant;
import com.logicbus.backend.AccessController;
import com.logicbus.backend.Context;
import com.logicbus.backend.message.XMLMessage;
import com.logicbus.backend.message.JsonMessage;
import com.logicbus.models.servant.ServiceDescription;


/**
 * 访问控制信息查询
 * 
 * 
* 查询当前访问控制器的信息,具体信息视访问控制器的实现而定.
* * 实现了一个内部核心服务,定义在/com/logicbus/service/servant.xml中,具体配置如下:
* * {@code * * } * *
* 如果配置在服务器中,访问地址为:
* {@code * http://[host]:[port]/[webcontext]/services/core/AclQuery * } * * @author duanyy * * * @version 1.2.8.2 [20141015 duanyy]
* - 支持双协议:JSON和XML
* * @version 1.4.0 [20141117 duanyy]
* - 将MessageDoc和Context进行合并整合
* * @version 1.6.10.12 [20171211 duanyy]
* - 支持混合模式
*/ public class AclQuery extends AbstractServant { protected void onDestroy() { } protected void onCreate(ServiceDescription sd) { } protected int onXml(Context ctx) { XMLMessage msg = (XMLMessage)ctx.asMessage(XMLMessage.class); int offset = getArgument("offset", 0, ctx); int limit = getArgument("limit", 30, ctx); String keyword = getArgument("keyword","",ctx); String group = getArgument("group","default",ctx); Document doc = msg.getDocument(); Element root = msg.getRoot(); Settings settings = Settings.get(); AccessController ac = (AccessController) settings.get("accessController"); if (ac != null){ AccessController acGroup = ac.getGroup(group); if (acGroup == null){ acGroup = ac; } Element acls = doc.createElement("acls"); XmlTools.setInt(acls, "offset", offset); XmlTools.setInt(acls, "limit", limit); XmlTools.setString(acls, "keyword",keyword); acGroup.report(acls); root.appendChild(acls); } return 0; } protected int onJson(Context ctx) { JsonMessage msg = (JsonMessage)ctx.asMessage(JsonMessage.class); int offset = getArgument("offset", 0, ctx); int limit = getArgument("limit", 30, ctx); String keyword = getArgument("keyword","",ctx); String group = getArgument("group","default",ctx); Map root = msg.getRoot(); Settings settings = Settings.get(); AccessController ac = (AccessController) settings.get("accessController"); if (ac != null){ AccessController acGroup = ac.getGroup(group); if (acGroup == null){ acGroup = ac; } Map acls = new HashMap(); JsonTools.setInt(acls, "offset", offset); JsonTools.setInt(acls, "limit", limit); JsonTools.setString(acls,"keyword",keyword); acGroup.report(acls); root.put("acls", acls); } return 0; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy