• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java XDIArc类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中xdi2.core.syntax.XDIArc的典型用法代码示例。如果您正苦于以下问题:Java XDIArc类的具体用法?Java XDIArc怎么用?Java XDIArc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

XDIArc类属于xdi2.core.syntax包,在下文中一共展示了XDIArc类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: convertCardToXdi

点赞 2

import xdi2.core.syntax.XDIArc; //导入依赖的package包/类
public List<XDIStatement> convertCardToXdi (Card card) throws Xdi2ClientException {
	Assert.notNull(card);
	CloudUser user = (CloudUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();

	XDIAddress cardXdiAddress = null;		
	if (StringUtils.isNotBlank(card.getXdiAddress())) {
		cardXdiAddress = XDIAddress.create(card.getXdiAddress());
	}
	else {
		XDIAddress cardsCollectionXdiAddress = XDIAddressUtil.concatXDIAddresses(user.getCloudNumber().getXDIAddress(), XDI_CARDS);
		cardXdiAddress = XDIAddressUtil.concatXDIAddresses(cardsCollectionXdiAddress, XdiEntityInstanceUnordered.createXDIArc(false, false, XDIArc.literalFromRandomUuid(), null));
	}

	List<XDIStatement> statements = new ArrayList<XDIStatement>();

	addStatement(statements, XDIAddressUtil.concatXDIAddresses(cardXdiAddress, XDI_CARD_DESCRIPTION), card.getDescription());
	addStatement(statements, XDIAddressUtil.concatXDIAddresses(cardXdiAddress, XDI_CARD_TAG), card.getTag());
	
	addStatement(statements, XDIAddressUtil.concatXDIAddresses(cardXdiAddress, XDI_CARD_BACKGROUND_IMAGE), card.getBackgroundImage());
	
	addCardButtonMessages(statements, cardXdiAddress);
	
	for (String key : card.getFields().keySet()) {
		addStatement(statements, cardXdiAddress, card, key);
	}
	
	// Put card's public info in Public LC
	statements.addAll(getCardInPublicLCStatement(cardXdiAddress, card));
	
	addCardShortcut(statements, cardXdiAddress, card);
	
	if (card.isDefault()) {
		statements.add(XDIStatement.create(user.getCloudNumber() + "$card/$ref/" + cardXdiAddress));
	}

	return statements;
}
 

开发者ID:projectdanube,
项目名称:xdi2-manager,
代码行数:38,
代码来源:CardXdiModelConverter.java

示例2: bookToXDI

点赞 2

import xdi2.core.syntax.XDIArc; //导入依赖的package包/类
private static void bookToXDI(BookDao book, XdiEntity xdiEntity) {

		xdiEntity.getXdiAttribute(XDIArc.create("<#title>"), true).setLiteralString(book.getTitle());
		xdiEntity.getXdiAttribute(XDIArc.create("<#author>"), true).setLiteralString(book.getAuthor());
		xdiEntity.getXdiAttribute(XDIArc.create("<#publisher>"), true).setLiteralString(book.getPublisher());
		xdiEntity.getXdiAttribute(XDIArc.create("<#country>"), true).setLiteralString(book.getCountry());
		xdiEntity.getXdiAttribute(XDIArc.create("<#year>"), true).setLiteralNumber(Double.valueOf(book.getYear()));
		xdiEntity.getXdiAttribute(XDIArc.create("<#price>"), true).setLiteralNumber(Double.valueOf(book.getPrice()));
	}
 

开发者ID:projectdanube,
项目名称:xdi2-example-advanced-server,
代码行数:10,
代码来源:BooksConnector.java

示例3: main

点赞 2

import xdi2.core.syntax.XDIArc; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

		// create a simple graph with context nodes, a relation, and a literal

		Graph graph = MemoryGraphFactory.getInstance().openGraph();

		ContextNode root = graph.getRootContextNode();
		ContextNode markus = root.setContextNode(XDIArc.create("=markus"));
		ContextNode animesh = root.setContextNode(XDIArc.create("=animesh"));
		ContextNode name = markus.setContextNode(XDIArc.create("<#name>"));
		Relation relation = markus.setRelation(XDIAddress.create("#friend"), animesh);
		LiteralNode literalNode = name.setLiteralNode("Markus Sabadello");

		// write some statements from our graph

		System.out.println("Statement associated with a context node: " + markus.getStatement());
		System.out.println("Statement associated with a relation: " + relation.getStatement());
		System.out.println("Statement associated with a literal: " + literalNode.getStatement());
		System.out.println();

		// we can also add a whole new statement to the graph

		graph.setStatement(XDIStatement.create("=alice/#friend/=bob"));

		// write the whole graph in different serialization formats

		System.out.println("Serialization in XDI/JSON: \n");
		XDIWriterRegistry.forFormat("XDI/JSON", null).write(graph, System.out);
		System.out.println();
		System.out.println();

		System.out.println("Serialization in XDI statements:\n");
		XDIWriterRegistry.forFormat("XDI DISPLAY", null).write(graph, System.out);

		// close the graph

		graph.close();
	}
 

开发者ID:projectdanube,
项目名称:xdi2-example-core,
代码行数:39,
代码来源:GraphModel.java

示例4: getAccessDataList

点赞 2

import xdi2.core.syntax.XDIArc; //导入依赖的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;
}
 

开发者ID:nzatnsr,
项目名称:neustar-clouds-proxy,
代码行数:57,
代码来源:ProxyXdiService.java

示例5: addAccessData

点赞 2

import xdi2.core.syntax.XDIArc; //导入依赖的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");
}
 

开发者ID:nzatnsr,
项目名称:neustar-clouds-proxy,
代码行数:56,
代码来源:ProxyXdiService.java

示例6: callbackMessagingContainerFactory

点赞 2

import xdi2.core.syntax.XDIArc; //导入依赖的package包/类
@Override
protected void callbackMessagingContainerFactory(final String messagingContainerFactoryPath, final UriMessagingContainerFactory messagingContainerFactory, UriMessagingContainerRegistry uriMessagingContainerRegistry, T state) throws Exception {

	if (! (messagingContainerFactory instanceof RegistryUriMessagingContainerFactory)) return;

	Iterator<XDIArc> ownerPeerRootXDIArcs = messagingContainerFactory.getOwnerPeerRootXDIArcs();

	Iterator<String> requestPaths = new MappingIterator<XDIArc, String> (ownerPeerRootXDIArcs) {

		@Override
		public String map(XDIArc ownerPeerRootXDIArc) {

			return messagingContainerFactory.getRequestPath(messagingContainerFactoryPath, ownerPeerRootXDIArc);
		}
	};

	while (requestPaths.hasNext()) {

		String requestPath = requestPaths.next();
		String messagingContainerPath = requestPath;

		MessagingContainer messagingContainer = messagingContainerFactory.mountMessagingContainer(uriMessagingContainerRegistry, messagingContainerFactoryPath, requestPath);

		this.callbackMessagingContainer(messagingContainerPath, messagingContainer, uriMessagingContainerRegistry, state);
	}
}
 

开发者ID:projectdanube,
项目名称:xdi2-tools,
代码行数:27,
代码来源:AbstractMessagingContainersCommand.java

示例7: main

点赞 2

import xdi2.core.syntax.XDIArc; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

		// create and print a graph with a collection

		Graph graph = MemoryGraphFactory.getInstance().openGraph();
		ContextNode contextNode = graph.getRootContextNode().setContextNode(XDIArc.create("=markus"));

		XdiAttributeCollection telAttributeCollection = XdiAbstractContext.fromContextNode(contextNode).getXdiAttributeCollection(XDIArc.create("[<#tel>]"), true);
		telAttributeCollection.setXdiInstanceUnordered(true, false).setLiteralString("+1.206.555.1111");
		telAttributeCollection.setXdiInstanceUnordered(true, false).setLiteralString("+1.206.555.2222");

		System.out.println(graph.toString(new MimeType("application/xdi+json;pretty=1")));

		// write and re-read the graph, then find and print the members of the attribute collection

		Graph graph2 = MemoryGraphFactory.getInstance().openGraph();
		XDIReaderRegistry.getAuto().read(graph2, new StringReader(graph.toString()));
		ContextNode contextNode2 = graph.getDeepContextNode(XDIAddress.create("=markus"));

		XdiAttributeCollection telCollection2 = XdiAbstractContext.fromContextNode(contextNode2).getXdiAttributeCollection(XDIArc.create("[<#tel>]"), false);

		for (Iterator<XdiAttributeInstanceUnordered> i = telCollection2.getXdiInstancesUnordered(); i.hasNext(); ) {

			System.out.println(i.next().getLiteralNode().getLiteralData());
		}
	}
 

开发者ID:projectdanube,
项目名称:xdi2-example-core,
代码行数:27,
代码来源:Collections.java

示例8: migrateMessagingContainerFactory

点赞 1

import xdi2.core.syntax.XDIArc; //导入依赖的package包/类
private static void migrateMessagingContainerFactory(final String messagingContainerFactoryPath, final UriMessagingContainerFactory inputMessagingContainerFactory, UriMessagingContainerFactory outputMessagingContainerFactory, UriMessagingContainerRegistry inputMessagingContainerRegistry, UriMessagingContainerRegistry outputMessagingContainerRegistry) throws Xdi2TransportException, Xdi2MessagingException {

		if (inputMessagingContainerFactory == null || ! (inputMessagingContainerFactory instanceof RegistryUriMessagingContainerFactory)) return;
		if (outputMessagingContainerFactory == null || ! (outputMessagingContainerFactory instanceof RegistryUriMessagingContainerFactory)) return;

		if (! (((RegistryUriMessagingContainerFactory) inputMessagingContainerFactory).getPrototypeMessagingContainer() instanceof GraphMessagingContainer)) return;
		if (! (((RegistryUriMessagingContainerFactory) outputMessagingContainerFactory).getPrototypeMessagingContainer() instanceof GraphMessagingContainer)) return;

		Iterator<XDIArc> ownerPeerRootXDIArcs = inputMessagingContainerFactory.getOwnerPeerRootXDIArcs();

		Iterator<String> requestPaths = new MappingIterator<XDIArc, String> (ownerPeerRootXDIArcs) {

			@Override
			public String map(XDIArc ownerPeerRootXDIArc) {

				return inputMessagingContainerFactory.getRequestPath(messagingContainerFactoryPath, ownerPeerRootXDIArc);
			}
		};

		while (requestPaths.hasNext()) {

			String requestPath = requestPaths.next();
			String messagingContainerPath = requestPath;

			MessagingContainer inputMessagingContainer = inputMessagingContainerFactory.mountMessagingContainer(inputMessagingContainerRegistry, messagingContainerFactoryPath, requestPath);
			MessagingContainer outputMessagingContainer = outputMessagingContainerFactory.mountMessagingContainer(outputMessagingContainerRegistry, messagingContainerFactoryPath, requestPath);

			migrateMessagingContainer(messagingContainerPath, inputMessagingContainer, outputMessagingContainer);

			inputMessagingContainerRegistry.unmountMessagingContainer(inputMessagingContainer);
			outputMessagingContainerRegistry.unmountMessagingContainer(outputMessagingContainer);
		}

		System.out.println("At path " + messagingContainerFactoryPath + " migrated from " + inputMessagingContainerFactory.getClass().getSimpleName() + " to " + outputMessagingContainerFactory.getClass().getSimpleName());
	}
 

开发者ID:projectdanube,
项目名称:xdi2-tools,
代码行数:36,
代码来源:CommandMigrateGraphs.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)