private Set<ITrustedEntity> retrieveTrustedEntities(final TrustQuery query) throws TrustException { final Set<ITrustedEntity> result = new LinkedHashSet<ITrustedEntity>(); try { if (this.trustRepo == null) { throw new TrustBrokerException("ITrustRepository service is not available"); } if (query.getTrusteeId() != null) { final ITrustedEntity trustedEntity = this.trustRepo.retrieveEntity(query.getTrustorId(), query.getTrusteeId()); if (trustedEntity != null) result.add(trustedEntity); } else { result.addAll( this.trustRepo.retrieveEntities( query.getTrustorId(), query.getTrusteeType(), query.getTrustValueType())); } } catch (ServiceUnavailableException sue) { throw new TrustBrokerException(sue.getLocalizedMessage(), sue); } return result; }
private boolean removeLocalTrustRelationships(final TrustQuery query) throws TrustException { try { if (this.trustRepo == null) { throw new TrustBrokerException("ITrustRepository service is not available"); } if (query.getTrusteeId() != null) { return this.trustRepo.removeEntity(query.getTrustorId(), query.getTrusteeId()); } else { return this.trustRepo.removeEntities( query.getTrustorId(), query.getTrusteeType(), query.getTrustValueType()); } } catch (ServiceUnavailableException sue) { throw new TrustBrokerException(sue.getLocalizedMessage(), sue); } }
/* * @see org.societies.api.privacytrust.trust.ITrustBroker#retrieveTrustValue(org.societies.api.identity.Requestor, org.societies.api.privacytrust.trust.TrustQuery) */ @Override @Async public Future<Double> retrieveTrustValue(final Requestor requestor, final TrustQuery query) throws TrustException { if (requestor == null) { throw new NullPointerException("requestor can't be null"); } if (query == null) { throw new NullPointerException("query can't be null"); } if (query.getTrusteeId() == null) { throw new IllegalArgumentException("trusteeId in query can't be null"); } if (query.getTrustValueType() == null) { throw new IllegalArgumentException("trustValueType in query can't be null"); } LOG.debug( "Retrieving trust value matching query '{}'" + " on behalf of requestor '{}'", query, requestor); if (this.isLocalQuery(query)) { // L O C A L LOG.debug("query '{}' is LOCAL", query); return new AsyncResult<Double>(this.retrieveLocalTrustValue(requestor, query)); } else { // R E M O T E LOG.debug("query '{}' is REMOTE", query); return new AsyncResult<Double>(this.retrieveRemoteTrustValue(requestor, query)); } }
/* * @see org.societies.api.internal.privacytrust.trust.ITrustBroker#unregisterTrustUpdateListener(org.societies.api.privacytrust.trust.event.ITrustUpdateEventListener, org.societies.api.privacytrust.trust.TrustQuery) */ @Override public void unregisterTrustUpdateListener( final ITrustUpdateEventListener listener, final TrustQuery query) throws TrustException { if (query == null) throw new NullPointerException("query can't be null"); if (query.getTrusteeType() != null) { this.doUnregisterTrustUpdateListenerByType( null, listener, query.getTrustorId(), query.getTrusteeType(), query.getTrustValueType()); } else { this.doUnregisterTrustUpdateListener( null, listener, query.getTrustorId(), query.getTrusteeId(), query.getTrustValueType()); } }