예제 #1
0
 /** {@inheritDoc} */
 public List<OrgTrust> getResult(RequestContext ctx) {
   Org org = ctx.getCurrentUser().getOrg();
   Set<Org> trustedorgs = org.getTrustedOrgs();
   List<OrgTrust> trusts = new ArrayList<OrgTrust>();
   for (Org o : trustedorgs) {
     DataResult<Map<String, Object>> dr = SystemManager.sidsInOrgTrust(org.getId(), o.getId());
     OrgTrust trust = new OrgTrust(o);
     if (!dr.isEmpty()) {
       for (Map<String, Object> m : dr) {
         Long sid = (Long) m.get("id");
         trust.getSubscribed().add(sid);
       }
     }
     trusts.add(trust);
   }
   return trusts;
 }
예제 #2
0
  /**
   * @param user User that owns parent channel
   * @param channelIn base channel to unsubscribe from.
   */
  private void unsubscribeOrgsFromChannel(User user, Channel channelIn, String accessIn) {
    Org org = channelIn.getOrg();

    // find trusted orgs
    Set<Org> trustedOrgs = org.getTrustedOrgs();
    for (Org o : trustedOrgs) {
      // find systems subscribed in org Trust
      DataResult<Map<String, Object>> dr = SystemManager.sidsInOrgTrust(org.getId(), o.getId());

      for (Map<String, Object> item : dr) {
        Long sid = (Long) item.get("id");
        Server s = ServerFactory.lookupById(sid);
        if (s.isSubscribed(channelIn)) {
          // check if this is a base custom channel
          if (channelIn.getParentChannel() == null) {
            // unsubscribe children first if subscribed
            List<Channel> children = channelIn.getAccessibleChildrenFor(user);
            Iterator<Channel> i = children.iterator();
            while (i.hasNext()) {
              Channel child = i.next();
              if (s.isSubscribed(child)) {
                // unsubscribe server from child channel

                child.getTrustedOrgs().remove(o);
                child.setAccess(accessIn);
                ChannelFactory.save(child);
                s = SystemManager.unsubscribeServerFromChannel(s, child);
              }
            }
          }
          // unsubscribe server from channel
          ChannelFactory.save(channelIn);
          s = SystemManager.unsubscribeServerFromChannel(s, channelIn);
        }
      }
    }
  }