本文整理汇总了Java中xdi2.messaging.MessageResult类的典型用法代码示例。如果您正苦于以下问题:Java MessageResult类的具体用法?Java MessageResult怎么用?Java MessageResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageResult类属于xdi2.messaging包,在下文中一共展示了MessageResult类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteAccessData
import xdi2.messaging.MessageResult; //导入依赖的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: getDataBucket
import xdi2.messaging.MessageResult; //导入依赖的package包/类
public String getDataBucket(String bucketName) {
String values = new String();
XDI3Segment query = XDI3Segment.create(cloudNumber + "[<+" + bucketName
+ ">]");
MessageResult result = getXDIStmts(query, true);
MemoryGraph response = (MemoryGraph) result.getGraph();
ContextNode root = response.getRootContextNode();
ReadOnlyIterator<Literal> literals = root.getAllLiterals();
while (literals.hasNext()) {
Literal literal = literals.next();
values += literal.getLiteralDataString();
values += ";";
}
return values;
}
示例3: processDisconnectRequest
import xdi2.messaging.MessageResult; //导入依赖的package包/类
public String processDisconnectRequest(String requestingParty,
String respondingParty) {
String targetSegment = new String();
targetSegment += this.cloudNumber;
targetSegment += "$to";
targetSegment += requestingParty;
targetSegment += "$from";
targetSegment += requestingParty;
targetSegment += "+registration$do";
MessageResult result = this.delXDIStmts(null,
XDI3Segment.create(targetSegment));
System.out.println("Result of delete lc :\n" + result.toString());
return "<html><body>Deletion of LC was successful!</body></html>";
}
示例4: getDependentData
import xdi2.messaging.MessageResult; //导入依赖的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;
}
示例5: get
import xdi2.messaging.MessageResult; //导入依赖的package包/类
public static PDSXEntity get(PersonalCloud pc, String entityType,
String oid, int order) {
PDSXEntity entity = new PDSXEntity(entityType, "Unknown", oid);
Vector<PDSXElementTemplate> templates = (Vector<PDSXElementTemplate>) (elementTemplates
.get(entityType));
for (int i = 0; i < templates.size(); i++) {
PDSXElementTemplate template = templates.elementAt(i);
XDI3Segment orderId = XDI3Segment.create(pc.getCloudNumber()
.toString()
+ "[+"
+ entityType
+ "]"
+ "#"
+ order
+ "<+"
+ template.getName() + ">&");
MessageResult result = pc.getXDIStmts(orderId,true);
MemoryGraph response = (MemoryGraph) result.getGraph();
Literal literalValue = response.getDeepLiteral(XDI3Segment
.create(pc.getCloudNumber().toString() + "[+" + entityType
+ "]" + "#" + order + "<+" + template.getName()
+ ">&"));
String value = (literalValue == null) ? "" : literalValue
.getLiteralData().toString();
PDSXElement element = new PDSXElement(entity, template, value);
}
return entity;
}
示例6: getDependent
import xdi2.messaging.MessageResult; //导入依赖的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;
}
示例7: getAccessDataList
import xdi2.messaging.MessageResult; //导入依赖的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;
}
示例8: addAccessData
import xdi2.messaging.MessageResult; //导入依赖的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");
}
示例9: linkContractExists
import xdi2.messaging.MessageResult; //导入依赖的package包/类
public boolean linkContractExists(String connectRequest) {
System.out.println("\nChecking if a link contract exists\n");
boolean result = false;
MemoryJSONGraphFactory graphFactory = new MemoryJSONGraphFactory();
String templateOwnerInumber = null;
try {
Graph g = graphFactory.parseGraph(connectRequest);
// get remote cloud number
XDIWriterRegistry.forFormat("XDI DISPLAY", null).write(g,
System.out);
ContextNode c = g.getRootContextNode();
ReadOnlyIterator<ContextNode> allCNodes = c.getAllContextNodes();
for (ContextNode ci : allCNodes) {
if (ci.containsContextNode(XDI3SubSegment.create("[$msg]"))) {
templateOwnerInumber = ci.toString();
System.out.println(templateOwnerInumber);
break;
}
}
if (templateOwnerInumber == null) {
System.out
.println("No cloudnumber for requestor/template owner");
return result;
}
// get the address of the link contract template
// $set{$do}
String lcTemplateAddress = null;
ReadOnlyIterator<Relation> allRelations = c.getAllRelations(); // g.getDeepRelations(XDI3Segment.create(templateOwnerInumber),XDI3Segment.create("$get"));
for (Relation r : allRelations) {
if (r.getArcXri().toString().equals("$set{$do}")) {
lcTemplateAddress = r.getTargetContextNodeXri().toString();
System.out.println(r.getTargetContextNodeXri());
}
}
if (lcTemplateAddress == null) {
System.out.println("No LC template address provided");
return result;
}
} catch (Exception io) {
io.printStackTrace();
return result;
}
String isPlusstmt = new String();
isPlusstmt += this.cloudNumber;
isPlusstmt += "$to";
isPlusstmt += templateOwnerInumber;
isPlusstmt += "$from";
isPlusstmt += templateOwnerInumber;
isPlusstmt += "+registration$do";
ArrayList<XDI3Segment> querySegments = new ArrayList<XDI3Segment>();
querySegments.add(XDI3Segment.create(isPlusstmt));
MessageResult responseFromRemoteCloud = this.sendQueries(querySegments,
null, false);
Graph responseGraph = responseFromRemoteCloud.getGraph();
ContextNode responseRootContext = responseGraph.getRootContextNode();
System.out.println("\n\nLink Contract exists check\n\n"
+ responseGraph.toString());
if (responseRootContext.getContextNodeCount() > 1) {
result = true;
}
return result;
}
示例10: save
import xdi2.messaging.MessageResult; //导入依赖的package包/类
public void save(PersonalCloud pc) {
ArrayList<XDI3Statement> XDIStmts = new ArrayList<XDI3Statement>();
Iterator<PDSXElement> iter = elements.iterator();
while (iter.hasNext()) {
PDSXElement attr = iter.next();
if (attr.getValue() != null) {
XDI3Statement stmt = XDI3Statement.create(attr.getAddress(pc)
.toString() + "/&/\"" + attr.getValue() + "\"");
XDIStmts.add(stmt);
}
}
// XDI3Statement entityCount = XDI3Statement
// .create(getElementCountAddress(pc) + "/&/\"" + objectMap.size()
// + "\"");
// XDIStmts.add(entityCount);
XDI3Segment orderId = XDI3Segment.create(pc.getCloudNumber().toString()
+ "[+" + objectType + "]" + "#" + order);
MessageResult result = pc.getXDIStmts(orderId,true);
if (result.isEmpty()) {
XDI3Statement orderStmt = XDI3Statement.create(pc.getCloudNumber()
.toString()
+ "[+"
+ objectType
+ "]"
+ "#"
+ order
+ "/$ref/" + this.getAddress(pc));
XDIStmts.add(orderStmt);
}
XDI3Segment getNameStmt = XDI3Segment.create(pc.getCloudNumber().toString()
+ "[+" + objectType + "]" + "*" + objectName);
MessageResult objectExists = pc.getXDIStmts(getNameStmt,true);
if (objectExists.isEmpty()) {
XDI3Statement nameRefStmt = XDI3Statement.create(pc.getCloudNumber()
.toString()
+ "[+"
+ objectType
+ "]"
+ "*"
+ objectName
+ "/$ref/" + this.getAddress(pc));
XDIStmts.add(nameRefStmt);
}
pc.setXDIStmts(XDIStmts);
// TODO
}
示例11: checkCloudNameAvailable
import xdi2.messaging.MessageResult; //导入依赖的package包/类
public static XDI3Segment checkCloudNameAvailable(CSP csp,
String cloudNameStr) throws Exception {
MessageEnvelope messageEnvelope = new MessageEnvelope();
Message message = messageEnvelope.getMessage(csp.getCSPCloudNumber(),
true);
message.setToAuthority(XDI3Segment.fromComponent(XdiPeerRoot
.createPeerRootArcXri(RESPECT_NETWORK_CLOUD_NUMBER)));
message.setLinkContractXri(XDI3Segment.create("+registrar$do"));
message.getContextNode().setDeepLiteral(XDI3Segment.create("" + XDIAuthenticationConstants.XRI_S_SECRET_TOKEN + XDIConstants.XRI_S_VALUE), csp.getCSPSecretToken());
XDI3Segment cloudName = XDI3Segment.create(cloudNameStr);
XDI3Segment cloudNamePeerRootXri = XDI3Segment
.fromComponent(XdiPeerRoot.createPeerRootArcXri(cloudName));
XDI3Segment targetAddress = cloudNamePeerRootXri;
message.createGetOperation(targetAddress);
MessageResult messageResult = xdiClientRespectNetworkRegistrar.send(
messageEnvelope, null);
if (messageResult.getGraph().isEmpty()) {
System.out.println("Cloud Name " + cloudName + " is available");
return null;
} else {
Relation relation = messageResult.getGraph().getDeepRelation(
cloudNamePeerRootXri, XDIDictionaryConstants.XRI_S_REF);
if (relation == null)
throw new RuntimeException("Cloud Number not registered.");
XDI3Segment cloudNumberPeerRootXri = relation
.getTargetContextNodeXri();
XDI3Segment cloudNumber = XdiPeerRoot
.getXriOfPeerRootArcXri(cloudNumberPeerRootXri
.getFirstSubSegment());
System.out
.println("Cloud Name " + cloudName
+ " is already registered with Cloud Number "
+ cloudNumber);
return cloudNumber;
}
}
示例12: registerCloudName
import xdi2.messaging.MessageResult; //导入依赖的package包/类
public static XDI3Segment registerCloudName(CSP csp, String cloudNameStr)
throws Exception {
MessageEnvelope messageEnvelope = new MessageEnvelope();
Message message = messageEnvelope.getMessage(csp.getCSPCloudNumber(),
true);
message.setToAuthority(XDI3Segment.fromComponent(XdiPeerRoot
.createPeerRootArcXri(RESPECT_NETWORK_CLOUD_NUMBER)));
message.setLinkContractXri(XDI3Segment.create("+registrar$do"));
message.getContextNode().setDeepLiteral(XDI3Segment.create("" + XDIAuthenticationConstants.XRI_S_SECRET_TOKEN + XDIConstants.XRI_S_VALUE), csp.getCSPSecretToken());
XDI3Segment cloudName = XDI3Segment.create(cloudNameStr);
XDI3Segment cloudNamePeerRootXri = XDI3Segment
.fromComponent(XdiPeerRoot.createPeerRootArcXri(cloudName));
XDI3Statement targetStatement = XDI3Statement.fromRelationComponents(
cloudNamePeerRootXri, XDIDictionaryConstants.XRI_S_REF,
XDIConstants.XRI_S_VARIABLE);
message.createSetOperation(targetStatement);
MessageResult messageResult = xdiClientRespectNetworkRegistrar.send(
messageEnvelope, null);
Relation relation = messageResult.getGraph().getDeepRelation(
cloudNamePeerRootXri, XDIDictionaryConstants.XRI_S_REF);
if (relation == null)
throw new RuntimeException("Cloud Number not registered.");
XDI3Segment cloudNumberPeerRootXri = relation.getTargetContextNodeXri();
cloudNumberPeerRootXri = relation.getTargetContextNodeXri();
XDI3Segment cloudNumber = XdiPeerRoot
.getXriOfPeerRootArcXri(cloudNumberPeerRootXri
.getFirstSubSegment());
System.out.println("Cloud Name " + cloudName
+ " registered with Cloud Number " + cloudNumber);
return cloudNumberPeerRootXri;
}