本文整理汇总了Java中xdi2.messaging.MessageEnvelope.getMessageCollection方法的典型用法代码示例。如果您正苦于以下问题:Java MessageEnvelope.getMessageCollection方法的具体用法?Java MessageEnvelope.getMessageCollection怎么用?Java MessageEnvelope.getMessageCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xdi2.messaging.MessageEnvelope
的用法示例。
在下文中一共展示了MessageEnvelope.getMessageCollection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: deleteConnectionTemplate
import xdi2.messaging.MessageEnvelope; //导入方法依赖的package包/类
@Secured("IS_AUTHENTICATED")
public void deleteConnectionTemplate(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);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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;
}
示例7: 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;
}
示例8: 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);
}
示例9: 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;
}
示例10: 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();
}
示例11: 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;
}
示例12: 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());
}
示例13: 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;
}
示例14: getFacebookConnectStatus
import xdi2.messaging.MessageEnvelope; //导入方法依赖的package包/类
public FacebookConnect getFacebookConnectStatus() throws Xdi2ClientException, IOException {
CloudUser user = (CloudUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
FacebookConnect facebookConnect = new FacebookConnect();
// Generate the OAuth URI
String oAuthUri = facebookApi.startOAuth(null, generateOAuthReturnUri(), user.getCloudNumber().getXDIAddress());
log.debug("Facebook OAuth URI " + oAuthUri);
facebookConnect.setoAuthUri(oAuthUri);
// Get User Id and Access Token
MessageEnvelope messageEnvelope = new MessageEnvelope();
MessageCollection messageCollection = messageEnvelope.getMessageCollection(user.getCloudNumber().getXDIAddress(), true);
Message message = messageCollection.createMessage();
message = user.prepareMessageToCloud(message);
message.createGetOperation(FacebookMapping.XDI_ADD_FACEBOOK_CONTEXT);
MessagingResponse messagingResponse = user.getXdiClient().send(messageEnvelope);
XDIAddress facebookUserIdXri = GraphUtil.retrieveFacebookUserIdXri(messagingResponse.getResultGraph(), user.getCloudNumber().getXDIAddress());
if (facebookUserIdXri != null) {
String facebookAccessToken = GraphUtil.retrieveFacebookAccessToken(messagingResponse.getResultGraph(), facebookUserIdXri);
facebookConnect.setUserId(facebookUserIdXri.toString());
facebookConnect.setAccessToken(facebookAccessToken);
log.debug(user.getCloudName() + " is connected to facebook (" + facebookUserIdXri.toString() + ") with token " + facebookAccessToken);
}
return facebookConnect;
}
示例15: handleFacebookOAuthResponse
import xdi2.messaging.MessageEnvelope; //导入方法依赖的package包/类
public void handleFacebookOAuthResponse(String code, String state) throws Exception {
CloudUser user = (CloudUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
log.debug("Got response from facebook: " + code);
facebookApi.checkState(state, user.getCloudNumber().getXDIAddress());
String facebookAccessToken = facebookApi.exchangeCodeForAccessToken(generateOAuthReturnUri(), code);
if (facebookAccessToken == null) throw new Exception("No access token received.");
String facebookUserId = facebookApi.retrieveUserId(facebookAccessToken);
XDIAddress facebookUserIdXri = facebookMapping.facebookUserIdToFacebookUserIdXri(facebookUserId);
// Facebook User Id ex: (https://facebook.com/)[=]!1111/$ref/(https://facebook.com/)[=]!10205481317089832
XDIStatement facebookUserIdStatement = XDIStatement.create(FacebookMapping.XDI_ADD_FACEBOOK_CONTEXT + user.getCloudNumber().toString() + "/$ref/" + FacebookMapping.XDI_ADD_FACEBOOK_CONTEXT + facebookUserIdXri);
// Facebook OAuth Token ex: (https://facebook.com/)[=]!10205481317089832<$oauth><$token>&/&/"dfasdhfgasdfaghsdf"
XDIStatement facebookAccessTokenStatement = XDIStatement.create("" + FacebookMapping.XDI_ADD_FACEBOOK_CONTEXT + facebookUserIdXri + XDISecurityConstants.XDI_ADD_OAUTH_TOKEN + "/&/\"" + facebookAccessToken + "\"");
MessageEnvelope messageEnvelope = new MessageEnvelope();
MessageCollection messageCollection = messageEnvelope.getMessageCollection(user.getCloudNumber().getXDIAddress(), true);
Message message = messageCollection.createMessage();
message = user.prepareMessageToCloud(message);
message.createSetOperation(facebookUserIdStatement);
message.createSetOperation(facebookAccessTokenStatement);
user.getXdiClient().send(messageEnvelope);
}