本文整理汇总了Java中xdi2.messaging.MessageEnvelope类的典型用法代码示例。如果您正苦于以下问题:Java MessageEnvelope类的具体用法?Java MessageEnvelope怎么用?Java MessageEnvelope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageEnvelope类属于xdi2.messaging包,在下文中一共展示了MessageEnvelope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCard
import xdi2.messaging.MessageEnvelope; //导入依赖的package包/类
@Secured("IS_AUTHENTICATED")
public void createCard(Card card) throws Xdi2ClientException {
Assert.notNull(card);
CloudUser user = (CloudUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
MessageEnvelope messageEnvelope = new MessageEnvelope();
MessageCollection messageCollection = messageEnvelope.getMessageCollection(user.getCloudNumber().getXDIAddress(), true);
Message message = messageCollection.createMessage();
message = user.prepareMessageToCloud(message);
message.createSetOperation(cardXdiModelConverter.convertCardToXdi(card).iterator());
log.debug("createCard message:\n" + messageEnvelope.getGraph().toString("XDI DISPLAY", null));
user.getXdiClient().send(messageEnvelope);
}
示例2: deleteCard
import xdi2.messaging.MessageEnvelope; //导入依赖的package包/类
@Secured("IS_AUTHENTICATED")
public void deleteCard(XDIAddress cardXdiAddress) throws Xdi2ClientException {
Assert.notNull(cardXdiAddress);
CloudUser user = (CloudUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
Card card = getCard(cardXdiAddress, false);
MessageEnvelope messageEnvelope = new MessageEnvelope();
MessageCollection messageCollection = messageEnvelope.getMessageCollection(user.getCloudNumber().getXDIAddress(), true);
Message message = messageCollection.createMessage();
message = user.prepareMessageToCloud(message);
// Delete card
message.createDelOperation(XDIAddress.create(card.getXdiAddress()));
// Delete card in Public LC
message.createDelOperation(cardXdiModelConverter.getCardInPublicLCStatement(XDIAddress.create(card.getXdiAddress()), card).iterator());
// Delete card shortcut
message.createDelOperation(cardXdiModelConverter.getCardShortcutAddress(card));
log.debug("deleteCard message:\n" + messageEnvelope.getGraph().toString("XDI DISPLAY", null));
user.getXdiClient().send(messageEnvelope);
}
示例3: setDefaultCard
import xdi2.messaging.MessageEnvelope; //导入依赖的package包/类
@Secured("IS_AUTHENTICATED")
public void setDefaultCard(XDIAddress cardXdiAddress) throws Xdi2ClientException {
Assert.notNull(cardXdiAddress);
CloudUser user = (CloudUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
MessageEnvelope messageEnvelope = new MessageEnvelope();
MessageCollection messageCollection = messageEnvelope.getMessageCollection(user.getCloudNumber().getXDIAddress(), true);
long messageIndex = 0;
// if there is a default card, we must delete it first
Message message = messageCollection.createMessage(messageIndex++);
message = user.prepareMessageToCloud(message);
message.createDelOperation(XDIStatement.create(user.getCloudNumber() + "$card/$ref/{}"));
// create a new $ref
message = messageCollection.createMessage(messageIndex);
message = user.prepareMessageToCloud(message);
message.createSetOperation(XDIStatement.create(user.getCloudNumber() + "$card/$ref/" + cardXdiAddress));
log.debug("setDefaultCard message:\n" + messageEnvelope.getGraph().toString("XDI DISPLAY", null));
user.getXdiClient().send(messageEnvelope);
}
示例4: revokeFacebookConnect
import xdi2.messaging.MessageEnvelope; //导入依赖的package包/类
public void revokeFacebookConnect() throws Xdi2ClientException, IOException, JSONException {
CloudUser user = (CloudUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
FacebookConnect facebookConnect = getFacebookConnectStatus();
if (facebookConnect.getAccessToken() != null) {
facebookApi.revokeAccessToken(facebookConnect.getAccessToken());
XDIAddress facebookAccessTokenXdiAddress = XDIAddress.create("" + FacebookMapping.XDI_ADD_FACEBOOK_CONTEXT + facebookConnect.getUserId() + XDISecurityConstants.XDI_ADD_OAUTH_TOKEN);
XDIAddress facebookUserIdXdiAddress = XDIAddress.create("" + FacebookMapping.XDI_ADD_FACEBOOK_CONTEXT + user.getCloudNumber());
MessageEnvelope messageEnvelope = new MessageEnvelope();
MessageCollection messageCollection = messageEnvelope.getMessageCollection(user.getCloudNumber().getXDIAddress(), true);
Message message = messageCollection.createMessage();
message = user.prepareMessageToCloud(message);
message.createDelOperation(facebookAccessTokenXdiAddress);
message.createDelOperation(facebookUserIdXdiAddress);
user.getXdiClient().send(messageEnvelope);
}
}
示例5: getFacebookProfile
import xdi2.messaging.MessageEnvelope; //导入依赖的package包/类
public FacebookProfile getFacebookProfile() throws Xdi2ClientException, IOException {
CloudUser user = (CloudUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
FacebookConnect facebookConnect = getFacebookConnectStatus();
FacebookProfile profile = new FacebookProfile();
XDIAddress facebookContext = XDIAddress.create("" + FacebookMapping.XDI_ADD_FACEBOOK_CONTEXT + facebookConnect.getUserId());
MessageEnvelope messageEnvelope = new MessageEnvelope();
MessageCollection messageCollection = messageEnvelope.getMessageCollection(user.getCloudNumber().getXDIAddress(), true);
Message message = messageCollection.createMessage();
message = user.prepareMessageToCloud(message);
for (XDIAddress fieldXdiAddress : XDI_FACEBOOK_PROFILE.values()) {
message.createGetOperation(XDIAddressUtil.concatXDIAddresses(facebookContext, fieldXdiAddress));
}
MessagingResponse messagingResponse = user.getXdiClient().send(messageEnvelope);
for (String field : XDI_FACEBOOK_PROFILE.keySet()) {
profile.putField(field, generateFacebookField(XDIAddressUtil.concatXDIAddresses(facebookContext, XDI_FACEBOOK_PROFILE.get(field)), messagingResponse.getResultGraph()));
}
return profile;
}
示例6: getPersonalProfile
import xdi2.messaging.MessageEnvelope; //导入依赖的package包/类
@Secured("IS_AUTHENTICATED")
public PersonalProfile getPersonalProfile() throws Xdi2ClientException {
CloudUser user = (CloudUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
MessageEnvelope messageEnvelope = new MessageEnvelope();
MessageCollection messageCollection = messageEnvelope.getMessageCollection(user.getCloudNumber().getXDIAddress(), true);
Message message = messageCollection.createMessage();
message = user.prepareMessageToCloud(message);
xdiModelConverter.prepareMessageForPersonalProfile(message);
long start = System.currentTimeMillis();
MessagingResponse messagingResponse = user.getXdiClient().send(messageEnvelope);
log.debug("network time: " + (System.currentTimeMillis() - start));
PersonalProfile profile = xdiModelConverter.convertToPersonalProfile(messagingResponse.getResultGraph());
return profile;
}
示例7: updatePersonalProfile
import xdi2.messaging.MessageEnvelope; //导入依赖的package包/类
@Secured("IS_AUTHENTICATED")
public void updatePersonalProfile(PersonalProfile profile) throws Xdi2ClientException {
Assert.notNull(profile);
CloudUser user = (CloudUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
MessageEnvelope messageEnvelope = new MessageEnvelope();
MessageCollection messageCollection = messageEnvelope.getMessageCollection(user.getCloudNumber().getXDIAddress(), true);
Message message = messageCollection.createMessage();
message = user.prepareMessageToCloud(message);
List<XDIStatement> statements = xdiModelConverter.convertPersonalProfileToStatements(profile);
message.createSetOperation(statements.iterator());
user.getXdiClient().send(messageEnvelope);
}
示例8: getCloudNames
import xdi2.messaging.MessageEnvelope; //导入依赖的package包/类
@Secured("IS_AUTHENTICATED")
public List<String> getCloudNames() throws Xdi2ClientException {
CloudUser user = (CloudUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
MessageEnvelope messageEnvelope = new MessageEnvelope();
MessageCollection messageCollection = messageEnvelope.getMessageCollection(user.getCloudNumber().getXDIAddress(), true);
Message message = messageCollection.createMessage();
message = user.prepareMessageToCloud(message);
message.createGetOperation(XDIStatement.create(user.getCloudNumber() + "/$is$ref/{}"));
MessagingResponse messagingResponse = user.getXdiClient().send(messageEnvelope);
ReadOnlyIterator<Relation> relations = messagingResponse.getResultGraph().getDeepRelations(user.getCloudNumber().getXDIAddress(), XDIAddress.create("$is$ref"));
List<String> cloudNames = new ArrayList<String>();
while (relations.hasNext()) {
Relation r = relations.next();
cloudNames.add(r.getTargetXDIAddress().toString());
}
return cloudNames;
}
示例9: getCloudNumber
import xdi2.messaging.MessageEnvelope; //导入依赖的package包/类
@Secured("IS_AUTHENTICATED")
public String getCloudNumber() throws Xdi2ClientException {
CloudUser user = (CloudUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
MessageEnvelope messageEnvelope = new MessageEnvelope();
MessageCollection messageCollection = messageEnvelope.getMessageCollection(user.getCloudNumber().getXDIAddress(), true);
Message message = messageCollection.createMessage();
message = user.prepareMessageToCloud(message);
message.createGetOperation(XDIStatement.create(user.getCloudNumber() + "/$is$ref/{}"));
MessagingResponse messagingResponse = user.getXdiClient().send(messageEnvelope);
ContextNode contextNode = messagingResponse.getResultGraph().getDeepContextNode(user.getCloudNumber().getXDIAddress());
return contextNode.toString();
}
示例10: getDependents
import xdi2.messaging.MessageEnvelope; //导入依赖的package包/类
@Secured("IS_AUTHENTICATED")
public List<String> getDependents() throws Xdi2ClientException {
CloudUser user = (CloudUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
MessageEnvelope messageEnvelope = new MessageEnvelope();
MessageCollection messageCollection = messageEnvelope.getMessageCollection(user.getCloudNumber().getXDIAddress(), true);
Message message = messageCollection.createMessage();
message = user.prepareMessageToCloud(message);
message.createGetOperation(XDIStatement.create(user.getCloudNumber() + "/$is#guardian/{}"));
MessagingResponse messagingResponse = user.getXdiClient().send(messageEnvelope);
ReadOnlyIterator<Relation> relations = messagingResponse.getResultGraph().getDeepRelations(user.getCloudNumber().getXDIAddress(), XDIAddress.create("$is#guardian"));
List<String> dependents = new ArrayList<String>();
while (relations.hasNext()) {
Relation r = relations.next();
String dependentCloudNumber = r.getTargetXDIAddress().toString();
dependents.add(reverseNameResolutionService.getCloudName(dependentCloudNumber));
}
return dependents;
}
示例11: getConnections
import xdi2.messaging.MessageEnvelope; //导入依赖的package包/类
@Secured("IS_AUTHENTICATED")
public List<Connection> getConnections() throws Xdi2ClientException {
CloudUser user = (CloudUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
MessageEnvelope messageEnvelope = new MessageEnvelope();
MessageCollection messageCollection = messageEnvelope.getMessageCollection(user.getCloudNumber().getXDIAddress(), true);
Message message = messageCollection.createMessage();
message = user.prepareMessageToCloud(message);
message.createGetOperation(user.getCloudNumber().getXDIAddress());
MessagingResponse messagingResponse = user.getXdiClient().send(messageEnvelope);
Iterator<LinkContract> linkContracts = LinkContracts.getAllLinkContracts(messagingResponse.getResultGraph());
List<Connection> connections = new ArrayList<>();
while (linkContracts.hasNext()) {
LinkContract linkContract = linkContracts.next();
connections.add(xdiModelConverter.convertLinkContractToConnection(linkContract));
}
return connections;
}
示例12: getConnection
import xdi2.messaging.MessageEnvelope; //导入依赖的package包/类
@Secured("IS_AUTHENTICATED")
public Connection getConnection(final String id) throws Xdi2ClientException {
Assert.hasLength(id);
CloudUser user = (CloudUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
MessageEnvelope messageEnvelope = new MessageEnvelope();
MessageCollection messageCollection = messageEnvelope.getMessageCollection(user.getCloudNumber().getXDIAddress(), true);
Message message = messageCollection.createMessage();
message = user.prepareMessageToCloud(message);
String xdiAddress = Connection.convertIdToXdiAddress(id);
message.createGetOperation(XDIAddress.create(xdiAddress));
MessagingResponse messagingResponse = user.getXdiClient().send(messageEnvelope);
Iterator<LinkContract> linkContracts = LinkContracts.getAllLinkContracts(messagingResponse.getResultGraph());
if (linkContracts.hasNext() == false) {
return null;
}
return xdiModelConverter.convertLinkContractToConnection(linkContracts.next());
}
示例13: deleteConnection
import xdi2.messaging.MessageEnvelope; //导入依赖的package包/类
@Secured("IS_AUTHENTICATED")
public void deleteConnection(String id) throws Xdi2ClientException {
Assert.hasLength(id);
CloudUser user = (CloudUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
MessageEnvelope messageEnvelope = new MessageEnvelope();
MessageCollection messageCollection = messageEnvelope.getMessageCollection(user.getCloudNumber().getXDIAddress(), true);
Message message = messageCollection.createMessage();
message = user.prepareMessageToCloud(message);
String xdiAddress = Connection.convertIdToXdiAddress(id);
message.createDelOperation(XDIAddress.create(xdiAddress));
user.getXdiClient().send(messageEnvelope);
}
示例14: getConnectionTemplates
import xdi2.messaging.MessageEnvelope; //导入依赖的package包/类
@Secured("IS_AUTHENTICATED")
public List<ConnectionTemplate> getConnectionTemplates() throws Xdi2ClientException {
CloudUser user = (CloudUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
MessageEnvelope messageEnvelope = new MessageEnvelope();
MessageCollection messageCollection = messageEnvelope.getMessageCollection(user.getCloudNumber().getXDIAddress(), true);
Message message = messageCollection.createMessage();
message = user.prepareMessageToCloud(message);
message.createGetOperation(user.getCloudNumber().getXDIAddress());
MessagingResponse messagingResponse = user.getXdiClient().send(messageEnvelope);
Iterator<LinkContractTemplate> linkContracts = LinkContractTemplates.getAllLinkContractTemplates(messagingResponse.getResultGraph());
List<ConnectionTemplate> connections = new ArrayList<>();
while (linkContracts.hasNext()) {
LinkContractTemplate linkContractTemplate = linkContracts.next();
connections.add(xdiModelConverter.convertLinkContractTemplateToConnectionTemplate(linkContractTemplate));
}
return connections;
}
示例15: getConnectionTemplate
import xdi2.messaging.MessageEnvelope; //导入依赖的package包/类
@Secured("IS_AUTHENTICATED")
public ConnectionTemplate getConnectionTemplate(final String id) throws Xdi2ClientException {
Assert.hasLength(id);
CloudUser user = (CloudUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
MessageEnvelope messageEnvelope = new MessageEnvelope();
MessageCollection messageCollection = messageEnvelope.getMessageCollection(user.getCloudNumber().getXDIAddress(), true);
Message message = messageCollection.createMessage();
message = user.prepareMessageToCloud(message);
String xdiAddress = Connection.convertIdToXdiAddress(id);
message.createGetOperation(XDIAddress.create(xdiAddress));
MessagingResponse messagingResponse = user.getXdiClient().send(messageEnvelope);
Iterator<LinkContractTemplate> linkContractTemplate = LinkContractTemplates.getAllLinkContractTemplates(messagingResponse.getResultGraph());
if (linkContractTemplate.hasNext() == false) {
return null;
}
return xdiModelConverter.convertLinkContractTemplateToConnectionTemplate(linkContractTemplate.next());
}