本文整理汇总了Java中xdi2.messaging.MessageEnvelope.createMessage方法的典型用法代码示例。如果您正苦于以下问题:Java MessageEnvelope.createMessage方法的具体用法?Java MessageEnvelope.createMessage怎么用?Java MessageEnvelope.createMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xdi2.messaging.MessageEnvelope
的用法示例。
在下文中一共展示了MessageEnvelope.createMessage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteAccessData
import xdi2.messaging.MessageEnvelope; //导入方法依赖的package包/类
public static void deleteAccessData( DependentData data, String type, String uuid )
{
try
{
CloudNumber cloudNumber = data.getCloudNumber();
MessageEnvelope messageEnvelope = new MessageEnvelope();
Message message = messageEnvelope.createMessage(cloudNumber.getXDIAddress());
message.setToPeerRootXDIArc(cloudNumber.getPeerRootXDIArc());
message.setLinkContract(RootLinkContract.class);
message.setSecretToken(data.getSecretToken());
message.createDelOperation(XDIAddressUtil.concatXDIAddresses(cloudNumber.getXDIAddress(), XDIAddress.create("<#proxy>"), XDIAddress.create("[<#" + type + ">]"), XDIAddress.create("<!:uuid:" + uuid + ">")));
MessageResult messageResult = new XDIHttpClient(data.getCloudUrl()).send(messageEnvelope, null);
logger.info(messageResult.getGraph().toString("XDI DISPLAY", null));
}
catch( Exception e )
{
logger.error("addAccessData() failed - " + e.getMessage(), e);
throw new ProxyInternalErrorException("deleteAccessData() failed");
}
}
示例2: getDependentData
import xdi2.messaging.MessageEnvelope; //导入方法依赖的package包/类
public static DependentData getDependentData( Statement stmt )
{
try
{
CloudNumber cloudNumber = CloudNumber.create(stmt.getObject().toString());
XDIDiscoveryResult result = getXDIDiscoveryClient().discoverFromRegistry(cloudNumber.getXDIAddress(), null);
URL cloudUrl = result.getXdiEndpointUrl();
Graph tempGraph = MemoryGraphFactory.getInstance().openGraph();
MessageEnvelope getMessageEnvelope = new MessageEnvelope();
Message getMessage = getMessageEnvelope.createMessage(cloudNumber.getXDIAddress());
getMessage.setToPeerRootXDIArc(cloudNumber.getPeerRootXDIArc());
getMessage.setLinkContract(PublicLinkContract.class);
getMessage.createGetOperation(XDIStatement.fromRelationComponents(cloudNumber.getXDIAddress(), XDIDictionaryConstants.XDI_ADD_IS_REF, XDIConstants.XDI_ADD_COMMON_VARIABLE));
MessageResult getMessageResult = new XDIHttpClient(cloudUrl).send(getMessageEnvelope, null);
for( Statement stmt1 : getMessageResult.getGraph().getRootContextNode().getAllStatements())
{
if( XDIDictionaryConstants.XDI_ADD_IS_REF.equals(stmt1.getPredicate()) == false )
{
logger.debug("getDependentData() - Ignore " + stmt1);
continue;
}
logger.debug("getDependentData() - Process " + stmt1);
String cloudName = stmt1.getObject().toString();
DependentData rtn = new DependentData();
rtn.setCloudName(cloudName);
rtn.setCloudNumber(cloudNumber);
rtn.setCloudUrl(cloudUrl);
return rtn;
}
}
catch( Exception e )
{
logger.error("getDependentData() failed - " + e.getMessage(), e);
}
logger.error("getDependentData() - Cannot find dependent cloud " + stmt);
return null;
}
示例3: setDependentProxyServer
import xdi2.messaging.MessageEnvelope; //导入方法依赖的package包/类
public static void setDependentProxyServer( DependentData data )
{
logger.info("setDependentProxyServer - " + data);
try
{
String server = "";
if( data.getPort() != null )
{
server = data.getHostname() + ":" + data.getPort();
}
CloudNumber cloudNumber = data.getCloudNumber();
Graph tempGraph = MemoryGraphFactory.getInstance().openGraph();
XdiAttribute proxyServerMessage = XdiCommonRoot.findCommonRoot(tempGraph)
.getXdiEntity(cloudNumber.getXDIAddress(), true)
.getXdiAttributeSingleton(XDIAddress.create("<#proxy>"), true)
.getXdiAttributeSingleton(XDIAddress.create("<#server>"), true);
proxyServerMessage.setLiteralDataString(server);
logger.info("Setting proxy server as '" + server + "'");
logger.info(tempGraph.toString("XDI DISPLAY", null));
MessageEnvelope messageEnvelope = new MessageEnvelope();
Message message = messageEnvelope.createMessage(cloudNumber.getXDIAddress());
message.setToPeerRootXDIArc(cloudNumber.getPeerRootXDIArc());
message.setLinkContract(RootLinkContract.class);
message.setSecretToken(data.getSecretToken());
message.createSetOperation(tempGraph);
new XDIHttpClient(data.getCloudUrl()).send(messageEnvelope, null);
}
catch( Exception e )
{
logger.error("setDependentProxyServer() failed - " + e.getMessage(), e);
}
}
示例4: getDependent
import xdi2.messaging.MessageEnvelope; //导入方法依赖的package包/类
public static List<DependentData> getDependent( GuardianData guardian )
{
List<DependentData> rtn = null;
XDIAddress isGuardian = XDIAddress.create("$is#guardian");
try
{
MessageEnvelope getDependentMessageEnvelope = new MessageEnvelope();
Message getDependentMessage = getDependentMessageEnvelope.createMessage(guardian.getCloudNumber().getXDIAddress());
getDependentMessage.setToPeerRootXDIArc(guardian.getCloudNumber().getPeerRootXDIArc());
getDependentMessage.setLinkContract(RootLinkContract.class);
getDependentMessage.setSecretToken(guardian.getSecretToken());
getDependentMessage.createGetOperation(XDIStatement.fromRelationComponents(guardian.getCloudNumber().getXDIAddress(), isGuardian, XDIConstants.XDI_ADD_COMMON_VARIABLE));
MessageResult getDependentResult = new XDIHttpClient(guardian.getCloudUrl()).send(getDependentMessageEnvelope, null);
logger.info(getDependentResult.getGraph().toString("XDI DISPLAY", null));
for( Statement stmt : getDependentResult.getGraph().getRootContextNode().getAllStatements() )
{
if( isGuardian.equals(stmt.getPredicate()) == false )
{
logger.debug("getDependent() - Ignore " + stmt);
continue;
}
logger.debug("getDependent() - Process " + stmt);
DependentData data = getDependentData(stmt);
if( data != null )
{
if( rtn == null )
{
rtn = new ArrayList<DependentData>();
}
rtn.add(data);
}
}
}
catch( Exception e )
{
logger.error("getDependent() failed - " + e.getMessage(), e);
}
return rtn;
}
示例5: getAccessDataList
import xdi2.messaging.MessageEnvelope; //导入方法依赖的package包/类
public static List<AccessData> getAccessDataList( DependentData data, String type )
{
logger.info("getAccessDataList " + type + " " + data);
List<AccessData> rtn = new ArrayList<AccessData>();
try
{
CloudNumber cloudNumber = data.getCloudNumber();
MessageEnvelope getMessageEnvelope = new MessageEnvelope();
Message getMessage = getMessageEnvelope.createMessage(cloudNumber.getXDIAddress());
getMessage.setToPeerRootXDIArc(cloudNumber.getPeerRootXDIArc());
getMessage.setLinkContract(RootLinkContract.class);
getMessage.setSecretToken(data.getSecretToken());
getMessage.createGetOperation(XDIAddressUtil.concatXDIAddresses(cloudNumber.getXDIAddress(), XDIAddress.create("<#proxy>"), XDIAddress.create("[<#" + type + ">]")));
MessageResult getMessageResult = new XDIHttpClient(data.getCloudUrl()).send(getMessageEnvelope, null);
logger.info(getMessageResult.getGraph().toString("XDI DISPLAY", null));
for( LiteralNode literal : getMessageResult.getGraph().getRootContextNode().getAllLiterals() )
{
String uuid = null;
List<XDIArc> list = literal.getStatement().getSubject().getXDIArcs();
if( list != null )
{
for( XDIArc arc : list )
{
String s = arc.getLiteral();
if( (s != null) && s.startsWith(":uuid:") )
{
uuid = s.substring(6);
}
}
}
if( uuid != null )
{
AccessData access = AccessData.toAccessData(literal.getLiteralDataString(), uuid);
if( access != null )
{
if( access.getType() == null )
{
access.setType(type);
}
if( rtn == null )
{
rtn = new ArrayList<AccessData>();
}
rtn.add(access);
}
}
}
}
catch( Exception e )
{
logger.error("getAccessDataList() failed - " + e.getMessage(), e);
}
return rtn;
}
示例6: addAccessData
import xdi2.messaging.MessageEnvelope; //导入方法依赖的package包/类
public static void addAccessData( DependentData data, String type, AccessData acc )
{
try
{
CloudNumber cloudNumber = data.getCloudNumber();
Graph tempGraph = MemoryGraphFactory.getInstance().openGraph();
XdiAttribute proxyAccessMessage = XdiCommonRoot.findCommonRoot(tempGraph)
.getXdiEntity(cloudNumber.getXDIAddress(), true)
.getXdiAttributeSingleton(XDIAddress.create("<#proxy>"), true)
.getXdiAttributeCollection(XDIAddress.create("[<#" + type + ">]"), true)
.setXdiMemberUnordered(true, false);
proxyAccessMessage.setLiteralDataString(AccessData.fromAccessData(acc));
logger.info(tempGraph.toString("XDI DISPLAY", null));
MessageEnvelope messageEnvelope = new MessageEnvelope();
Message message = messageEnvelope.createMessage(cloudNumber.getXDIAddress());
message.setToPeerRootXDIArc(cloudNumber.getPeerRootXDIArc());
message.setLinkContract(RootLinkContract.class);
message.setSecretToken(data.getSecretToken());
message.createSetOperation(tempGraph);
MessageResult messageResult = new XDIHttpClient(data.getCloudUrl()).send(messageEnvelope, null);
logger.info(messageResult.getGraph().toString("XDI DISPLAY", null));
for( LiteralNode literal : tempGraph.getRootContextNode().getAllLiterals() )
{
String uuid = null;
List<XDIArc> list = literal.getStatement().getSubject().getXDIArcs();
if( list != null )
{
for( XDIArc arc : list )
{
String s = arc.getLiteral();
if( (s != null) && s.startsWith(":uuid:") )
{
uuid = s.substring(6);
}
}
}
if( uuid != null )
{
acc.setUuid(uuid);
return;
}
}
logger.error("addAccessData() failed - uuid not found");
}
catch( Exception e )
{
logger.error("addAccessData() failed - " + e.getMessage(), e);
}
throw new ProxyInternalErrorException("addAccessData() failed");
}
示例7: discoverManual
import xdi2.messaging.MessageEnvelope; //导入方法依赖的package包/类
public static void discoverManual(CloudNumber cloudNumber) throws Exception {
XDIDiscoveryResult resultFromRegistry = xdiDiscoveryClient.discoverFromRegistry(cloudNumber.getXDIAddress());
URI xdiEndpointUri = resultFromRegistry.getXdiEndpointUri();
MessageEnvelope messageEnvelope = new MessageEnvelope();
Message message = messageEnvelope.createMessage(cloudNumber.getXDIAddress());
message.setToPeerRootXDIArc(cloudNumber.getPeerRootXDIArc());
message.createGetOperation(XDIStatement.fromComponents(cloudNumber.getXDIAddress(), XDIDictionaryConstants.XDI_ADD_IS_REF, XDIConstants.XDI_ADD_COMMON_VARIABLE));
message.setLinkContractClass(PublicLinkContract.class);
XDIClient xdiClient = new XDIHttpClient(xdiEndpointUri);
MessagingResponse messagingResponse = xdiClient.send(messageEnvelope);
ContextNode contextNode = messagingResponse.getGraph().getDeepContextNode(cloudNumber.getXDIAddress());
ReadOnlyIterator<Relation> relations = contextNode.getRelations(XDIDictionaryConstants.XDI_ADD_IS_REF);
for (Relation relation : relations) System.out.println("Manually discovered: " + relation.follow().getXDIAddress());
}
示例8: main
import xdi2.messaging.MessageEnvelope; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
LogManager.getLogger("xdi2").setLevel(Level.OFF);
XDIWriter writer = XDIWriterRegistry.forFormat("XDI DISPLAY", null);
// discovery
XDIDiscoveryClient xdiDiscoveryClient = XDIDiscoveryClient.DEFAULT_DISCOVERY_CLIENT;
XDIDiscoveryResult xdiDiscoveryResult = xdiDiscoveryClient.discoverFromRegistry(XDIAddress.create("=markus"));
// construct message
MessageEnvelope messageEnvelope = new MessageEnvelope();
Message message = messageEnvelope.createMessage(XDIAddress.create("=sender"));
message.createGetOperation(XDIAddress.create("=markus<#email>"));
message.setToPeerRootXDIArc(xdiDiscoveryResult.getCloudNumber().getPeerRootXDIArc());
message.setLinkContractClass(PublicLinkContract.class);
// construct client, send message, read result
XDIClient client = new XDIHttpClient(xdiDiscoveryResult.getXdiEndpointUri());
MessagingResponse messagingResponse = client.send(messageEnvelope);
// print results
System.out.println("Discovery result: ");
writer.write(xdiDiscoveryResult.getMessagingResponse().getGraph(), System.out);
System.out.println();
System.out.println("Message envelope: ");
writer.write(messageEnvelope.getGraph(), System.out);
System.out.println();
System.out.println("Messaging response: ");
writer.write(messagingResponse.getGraph(), System.out);
}