Examples of CommunityPojo


Examples of com.ikanow.infinit.e.data_model.store.social.community.CommunityPojo

  // (this utility function is needed for the legacy case where empty communities were
  //  treated as aliases of the dummy community ... first time I encounter a community, I need
  //  to recreate it...)
 
  public static void recreateCommunityDocIndex_unknownFields(ObjectId communityId, boolean bDeleteFirst) {
    CommunityPojo cp = CommunityPojo.fromDb(MongoDbManager.getSocial().getCommunity().findOne(new BasicDBObject("_id", communityId)), CommunityPojo.class);
    if (null != cp) {
      deleteCommunityDocIndex(communityId.toString(), cp.getParentId(), true);
        // (in the legacy world this would have been treated as a "personal" ie equivalently to a dummy community ...
        //  this does nothing if it's already a real community)
     
      if (bDeleteFirst) {
        deleteCommunityDocIndex(communityId.toString(), cp.getParentId(), cp.getIsPersonalCommunity());
      }     
      createCommunityDocIndex(communityId.toString(), cp.getParentId(), cp.getIsPersonalCommunity(), cp.getIsSystemCommunity(), false);
    }
  }
View Full Code Here

Examples of com.ikanow.infinit.e.data_model.store.social.community.CommunityPojo

       
        //OK ... issue here with child communities .. you can't just rebuild the index because it will delete the parent index also
        BasicDBObject query = new BasicDBObject("_id", communityId);
        BasicDBObject fields = new BasicDBObject("parentId", 1);
        fields.put("name", 1);
        CommunityPojo community = CommunityPojo.fromDb(DbManager.getSocial().getCommunity().findOne(query, fields), CommunityPojo.class);
        if (null == community) {
          System.out.println("WARNING_COMM_EXIST: community " + communityId + " does not exist, this will likely cause problems");
          return;
        }
        if (null != community.getParentId()) {
          if (null == community.getParentName()) {
            CommunityPojo parentComm = CommunityPojo.fromDb(DbManager.getSocial().getCommunity().findOne(new BasicDBObject("_id", community.getParentId())), CommunityPojo.class);           
            if (null == parentComm) {
              System.out.println("WARNING_COMM_EXIST: community " + community.getParentId() + " does not exist, this will likely cause problems");             
            }
            else {
              community.setParentName(parentComm.getName());
            }
          }         
          System.out.println("WARNING_CHILD_COMM: " + "commid=" + communityId + ", community" + community.getName() " has a parent, parent_id=" + community.getParentId() + " (name " + community.getParentName() + "). " +
                    "This community will not be rebuilt, and you should ensure that it is re-indexed if the parent community is subsequently rebuilt.");
          return;
View Full Code Here

Examples of com.ikanow.infinit.e.data_model.store.social.community.CommunityPojo

    return isOwnerOrModerator(communityIdStr, personIdStr, false);
  }
 
  private static boolean isOwnerOrModerator(String communityIdStr, String personIdStr, boolean bAllowContentPublisher)
  {   
    CommunityPojo community = null;
    try
    {
      BasicDBObject query = new BasicDBObject("_id", new ObjectId(communityIdStr));
      BasicDBObject dbo = (BasicDBObject)DbManager.getSocial().getCommunity().findOne(query);
     
View Full Code Here

Examples of com.ikanow.infinit.e.data_model.store.social.community.CommunityPojo

    //otherwise we are already done and can come back down (parentTree is already set or
    //we have no parent so would return an empty list anyways)
    if ( community.getParentId() != null && community.getParentTree() == null )
    {
      //get next node and move up a level
      CommunityPojo parent_community = CommunityPojo.fromDb(MongoDbManager.getSocial().getCommunity().findOne(new BasicDBObject("_id", community.getParentId())), CommunityPojo.class);
      parent_community = createParentTreeRecursion(parent_community, true);
      //now we have the parent_comm, add parentId to beginning of parentTree and update this comm
      List<ObjectId> parentTree;
      if ( parent_community.getParentTree() != null )
        parentTree = new ArrayList<ObjectId>(parent_community.getParentTree());
      else
        parentTree = new ArrayList<ObjectId>();
      parentTree.add(0, parent_community.getId());
      community.setParentTree(parentTree);
      if ( updateCommunity )
      {
        BasicDBObject update = new BasicDBObject("$set", new BasicDBObject("parentTree", parentTree));   
        MongoDbManager.getSocial().getCommunity().update(new BasicDBObject("_id", community.getId()), update);
View Full Code Here

Examples of com.ikanow.infinit.e.data_model.store.social.community.CommunityPojo

      // Get GsonBuilder object with MongoDb de/serializers registered
      BasicDBObject dbo = (BasicDBObject)DbManager.getSocial().getCommunity().findOne(query);
     
      if (dbo != null)
      {
        CommunityPojo community = CommunityPojo.fromDb(dbo, CommunityPojo.class);
        if (showDocInfo) {
          DocCountPojo dc = (DocCountPojo) DbManager.getDocument().getCounts().findOne(query);
          if (null != dc) {
            dc.set_id(null);
            community.setDocumentInfo(dc);
          }
        }
        community = filterCommunityMembers(community, RESTTools.adminLookup(userIdStr), userIdStr);
        rp.setData(community, new CommunityPojoApiMap());
        rp.setResponse(new ResponseObject("Community Info", true, "Community info returned successfully"));
View Full Code Here

Examples of com.ikanow.infinit.e.data_model.store.social.community.CommunityPojo

        {
          try {
            DBObject dboparent = DbManager.getSocial().getCommunity().findOne(new BasicDBObject("_id", new ObjectId(parentIdStr)));
            if ( dboparent != null )
            {
              CommunityPojo cp = CommunityPojo.fromDb(dboparent, CommunityPojo.class);
              parentName = cp.getName();
             
              if (cp.getIsPersonalCommunity()) {
                return new ResponsePojo(new ResponseObject("Add Community", false, "Can't create sub-community of personal community"));             
              }//TESTED
              if ((null == cp.getCommunityStatus()) || !cp.getCommunityStatus().equalsIgnoreCase("active")) {
                return new ResponsePojo(new ResponseObject("Add Community", false, "Can't create sub-community of inactive community"));             
              }//TESTED
              // Check attributes
              if (null != cp.getCommunityAttributes()) {
                CommunityAttributePojo attr = cp .getCommunityAttributes().get("usersCanCreateSubCommunities");
                if ((null == attr) || (null== attr.getValue()) || (attr.getValue().equals("false"))) {
                  if (!cp.isOwner(person.get_id()) && !SocialUtils.isModerator(userIdStr, cp) && !RESTTools.adminLookup(userIdStr)) {
                    return new ResponsePojo(new ResponseObject("Add Community", false, "Can't create sub-community when not permitted by parent"));
                  }//TESTED (owner+admin+mod)
                }
              }           
            }//TESTED - different restrictions as above
View Full Code Here

Examples of com.ikanow.infinit.e.data_model.store.social.community.CommunityPojo

        }
        else
        {
          oId = new ObjectId(idStr);
        }
        CommunityPojo c = new CommunityPojo();
        c.setId(oId);
        c.setCreated(new Date());
        c.setModified(new Date());
        c.setName(name);
        c.setDescription(description);
        if (parentIdStr != null && parentName != null)
        {
          c.setParentId(new ObjectId(parentIdStr));
          c.setParentName(parentName);
          c = SocialUtils.createParentTreeRecursion(c, false);
        }
        c.setIsPersonalCommunity(false);
        c.setTags(getTagsFromString(tags));
        c.setOwnerId(new ObjectId(ownerIdStr));
        c.setOwnerDisplayName(ownerDisplayName);
        c.setNumberOfMembers(0);
        c.setCommunityAttributes(getDefaultCommunityAttributes());
        c.setCommunityUserAttribute(getDefaultCommunityUserAttributes());
       
        // Insert new community document in the community collection
        DBObject commObj = c.toDb();

        // Create the index form of the community:
        try {
          GenericProcessingController.createCommunityDocIndex(c.getId().toString(), c.getParentId(), c.getIsPersonalCommunity(), c.getIsSystemCommunity(), false);
        }
        catch (Exception e) { // Can't create community
          rp.setResponse(new ResponseObject("Add Community", false, "Error adding new community because of index failure: " + e.getMessage()));
          return rp;
        }
        //TESTED
       
        DbManager.getSocial().getCommunity().save(commObj);       
       
        // If a child, update the parent:
        if (null != c.getParentId()) {
          BasicDBObject updateQuery = new BasicDBObject("_id", c.getParentId());
          BasicDBObject updateUpdate = new BasicDBObject(DbManager.addToSet_, new BasicDBObject("children", c.getId()));
          DbManager.getSocial().getCommunity().update(updateQuery, updateUpdate, false, true);
        }
        //TESTED
       
        // Update the new community record to add the owner to the list of members
View Full Code Here

Examples of com.ikanow.infinit.e.data_model.store.social.community.CommunityPojo

      //get the communitypojo
      communityIdStr = allowCommunityRegex(personIdStr, communityIdStr);
      DBObject communitydbo = DbManager.getSocial().getCommunity().findOne(new BasicDBObject("_id",communityId));
      if ( communitydbo != null )
      {
        CommunityPojo cp = CommunityPojo.fromDb(communitydbo, CommunityPojo.class);
        //get the personpojo
        DBObject persondbo = DbManager.getSocial().getPerson().findOne(new BasicDBObject("_id",new ObjectId(personIdStr)));
        if ( persondbo != null )
        {
          //PersonPojo pp = gson.fromJson(persondbo.toString(),PersonPojo.class);
          if ( !cp.getIsPersonalCommunity() )
          {
            if ( cp.isOwner(new ObjectId(personIdStr)) || isSysAdmin )
            {
              if (cp.getCommunityStatus().equals("disabled")) { // Delete for good, this is going to be ugly...
               
                if ((null != cp.getChildren()) && !cp.getChildren().isEmpty()) {
                  rp.setResponse(new ResponseObject("Delete community", false, "Undeleted sub-communities exist, please delete them first"));
                  return rp;
                }
                //TESTED
               
                // 1] Remove from all shares (delete shares if that leaves them orphaned)
               
                BasicDBObject deleteQuery1 = new BasicDBObject(ShareCommunityPojo.shareQuery_id_, communityId);
                BasicDBObject deleteFields1 = new BasicDBObject(SharePojo.communities_, 1);
                List<SharePojo> shares = SharePojo.listFromDb(DbManager.getSocial().getShare().find(deleteQuery1, deleteFields1), SharePojo.listType());       
                for (SharePojo share: shares) {
                  if (1 == share.getCommunities().size()) { // delete this share
                    DbManager.getSocial().getShare().remove(new BasicDBObject(SharePojo._id_, share.get_id()));
                  }
                }
                BasicDBObject update1 = new BasicDBObject(DbManager.pull_, new BasicDBObject(SharePojo.communities_,
                                              new BasicDBObject(ShareOwnerPojo._id_, communityId)));
                DbManager.getSocial().getShare().update(deleteQuery1, update1, false, true);
               
                //TESTED (both types)
               
                // 2] Remove from all sources (also delete the documents)
                // (In most cases this will leave the source orphaned, so delete it)
               
                BasicDBObject deleteQuery2 = new BasicDBObject(SourcePojo.communityIds_, communityId);
                BasicDBObject deleteFields2 = new BasicDBObject(SourcePojo.communityIds_, 1);
                List<SourcePojo> sources = SourcePojo.listFromDb(DbManager.getIngest().getSource().find(deleteQuery2, deleteFields2), SourcePojo.listType());
                List<SourcePojo> failedSources = new ArrayList<SourcePojo>();
                for (SourcePojo source: sources)
                {
                  ResponsePojo rp1 = null;
                  SourceHandler tmpHandler = new SourceHandler();
                  if (1 == source.getCommunityIds().size()) { // delete this source
                    rp1 = tmpHandler.deleteSource(source.getId().toString(), communityIdStr, personIdStr, false);
                      // (deletes all docs and removes from the share)
                  }
                  else { // Still need to delete docs from this share from this community
                    rp1 = tmpHandler.deleteSource(source.getId().toString(), communityIdStr, personIdStr, true);                   
                  }
                  if ( rp1 != null && !rp1.getResponse().isSuccess() )
                  {
                    failedSources.add(source);
                  }
                }
               
                //if we have more than 1 failed source, bail out w/ error
                if (failedSources.size() > 0 )
                {
                  StringBuilder sb = new StringBuilder();
                  for ( SourcePojo source : failedSources )
                    sb.append(source.getId().toString() + " ");
                  rp.setResponse(new ResponseObject("Delete community", false, "Could not stop sources (they might be currently running): " + sb.toString()));
                  return rp;
                }
               
                BasicDBObject update2 = new BasicDBObject(DbManager.pull_, new BasicDBObject(SourcePojo.communityIds_, communityId));
                DbManager.getSocial().getShare().update(deleteQuery2, update2, false, true);

                //TESTED (both types, check docs deleted)
               
                // 3] Remove from all map reduce jobs (delete any that it is only comm left on)
                String customJobsMessage = removeCommunityFromJobs(personIdStr, communityId);
                if ( customJobsMessage.length() > 0)
                {
                  rp.setResponse(new ResponseObject("Delete community", false, "Could not stop all map reduce jobs (they might be currently running): " + customJobsMessage));
                  return rp;
                }
               
                // 4] Finally delete the object itself
               
                DbManager.getSocial().getCommunity().remove(new BasicDBObject("_id", communityId));
               
                // Remove from index:
                GenericProcessingController.deleteCommunityDocIndex(communityId.toString(), cp.getParentId(), false);
                //TESTED
               
                // 5] Finally finally remove from parent communities
                if (null != cp.getParentId()) {
                  BasicDBObject updateQuery = new BasicDBObject("_id", cp.getParentId());
                  BasicDBObject updateUpdate = new BasicDBObject(DbManager.pull_, new BasicDBObject("children", cp.getId()));
                  DbManager.getSocial().getCommunity().update(updateQuery, updateUpdate, false, true);                 
                }
                //TESTED
               
                rp.setResponse(new ResponseObject("Delete community", true, "Community deleted forever. " + customJobsMessage));
              }
              else { // First time, just remove all users and disable
                //at this point, we have verified, community/user exist, not a personal group, user is member and owner
                //set community as inactive (for some reason we don't delete it)
                DbManager.getSocial().getCommunity().update(new BasicDBObject("_id", communityId),
                                      new BasicDBObject(DbManager.set_, new BasicDBObject("communityStatus","disabled")));
               
                //remove all members
                for ( CommunityMemberPojo cmp : cp.getMembers())
                  removeCommunityMember(personIdStr, communityIdStr, cmp.get_id().toString());
                rp.setResponse(new ResponseObject("Delete community", true, "Community disabled successfully - call delete again to remove for good, including all sources, shares, and documents"));
              }
            }
            else
View Full Code Here

Examples of com.ikanow.infinit.e.data_model.store.social.community.CommunityPojo

    ResponsePojo rp = new ResponsePojo();
    try
    {
      PersonPojo person = SocialUtils.getPerson(userId)
      boolean isAdmin = RESTTools.adminLookup(userId);
      CommunityPojo system_comm = getSystemCommunity();
      List<ObjectId> communityIds = new ArrayList<ObjectId>();
      for ( PersonCommunityPojo community : person.getCommunities())
      {
        ObjectId comm_id = community.get_id();
        if ( allowedToSeeCommunityMembers(comm_id, isAdmin, system_comm) )
View Full Code Here

Examples of com.ikanow.infinit.e.data_model.store.social.community.CommunityPojo

      //try to get system
      BasicDBObject commQueryDbo = new BasicDBObject("isSystemCommunity", true);
        // (annoyingly can't use community pojo for queries because it has default fields)
      DBObject dbo = DbManager.getSocial().getCommunity().findOne(commQueryDbo);
      if (null != dbo) {
        CommunityPojo systemGroup = CommunityPojo.fromDb(dbo, CommunityPojo.class);
       
        //Add user to system community also
        cc.addCommunityMember(cookieLookup, systemGroup.getId().toString(), "Infinit.e System", pp.get_id().toString(),
            pp.getEmail(), pp.getDisplayName(), "member", "active", true);
      }               
      rp.setResponse(new ResponseObject("WP Register User",true,"User Registered Successfully"));
      rp.setData(ap, new AuthenticationPojoApiMap());
     
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.