本文整理汇总了Java中xdi2.core.features.linkcontracts.instance.PublicLinkContract类的典型用法代码示例。如果您正苦于以下问题:Java PublicLinkContract类的具体用法?Java PublicLinkContract怎么用?Java PublicLinkContract使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PublicLinkContract类属于xdi2.core.features.linkcontracts.instance包,在下文中一共展示了PublicLinkContract类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertLinkContractToConnection
import xdi2.core.features.linkcontracts.instance.PublicLinkContract; //导入依赖的package包/类
public Connection convertLinkContractToConnection(LinkContract linkContract) {
Assert.notNull(linkContract);
CloudUser user = (CloudUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
Connection connection = new Connection();
connection = (Connection) this.convertLCBaseToAbstractConnection(linkContract, connection);
if (linkContract instanceof RootLinkContract) {
connection.setType("ROOT");
}
else if (linkContract instanceof PublicLinkContract) {
connection.setType("PUBLIC");
}
else if (linkContract instanceof RelationshipLinkContract) {
connection.setType("GENERIC");
RelationshipLinkContract glc = (RelationshipLinkContract) linkContract;
connection.setRaCloudNumber(glc.getRequestingAuthority().toString());
connection.setRaCloudName(reverseNameResolutionService.getCloudName(connection.getRaCloudNumber()));
}
return connection;
}
示例2: getDependentData
import xdi2.core.features.linkcontracts.instance.PublicLinkContract; //导入依赖的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: discoverManual
import xdi2.core.features.linkcontracts.instance.PublicLinkContract; //导入依赖的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());
}
示例4: main
import xdi2.core.features.linkcontracts.instance.PublicLinkContract; //导入依赖的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);
}