Package org.onesocialweb.openfire.model.vcard4

Examples of org.onesocialweb.openfire.model.vcard4.PersistentProfile


   *         entity.
   * @throws UserNotFoundException
   */
  public Profile getProfile(String requestorJID, String targetJID) throws UserNotFoundException {
    final EntityManager em = OswPlugin.getEmFactory().createEntityManager();
    PersistentProfile profile = em.find(PersistentProfile.class, targetJID);
    em.close();
    if (profile != null) {
      if (requestorJID.equals(targetJID)) {
        return profile;
      } else {
        // We should filter all fields that the requestor is not
        // supposed to see and strip all data related to ACLs.
       
        final AclAction viewAction = aclFactory.aclAction(AclAction.ACTION_VIEW, AclAction.PERMISSION_GRANT);
        List<Field> fields =profile.getFields();
        List<Field> canSeefields= new ArrayList<Field>();
        for (Field field: fields)
        {
          boolean canSee=false;
          List<AclRule> rules= field.getAclRules();
          //this is a patch, so that the profile and its fields can be retrieved even when the acl rules where not set...
          // currently the vodafonernd.com DB has many profiles without any ACL rules, which retrieves empty profiles...
          if (rules.isEmpty())
            canSee=true;
          for (AclRule rule: rules)
          {
            if ((rule.hasAction(viewAction)) && (AclManager.canSee(targetJID, rule, requestorJID)))           
              canSee=true;                   
          }
          if (canSee)
            canSeefields.add(field);           
        }
       
        profile.removeAll();       
        try{
          for (Field f: canSeefields){           
            f.setAclRules(new ArrayList<AclRule>());         
            profile.addField(f);
          }       
        }catch (CardinalityException ce){
        }catch (UnsupportedFieldException ufe){         
        }         
        return profile;
View Full Code Here


    // Overide the user to avoid spoofing
    profile.setUserId(userJID);

    // Remove an old profile
    PersistentProfile oldProfile = em.find(PersistentProfile.class, userJID);
    if (oldProfile != null) {
      em.remove(oldProfile);
    }

    // Persist the profile
View Full Code Here

        result.setError(PacketError.Condition.bad_request);
        return result;
      }

      // Parse the profile
      VCard4DomReader reader = new PersistentVCard4DomReader();
      Profile profile = reader.readProfile(new ElementAdapter(e_profile));
     
      // Commit the profile (this will also trigger the messages)
      try {
        ProfileManager.getInstance().publishProfile(sender.toBareJID(), profile);
      } catch (UserNotFoundException e) {
View Full Code Here

TOP

Related Classes of org.onesocialweb.openfire.model.vcard4.PersistentProfile

Copyright © 2018 www.massapicom. 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.