Java Code Examples for lotus.domino.Document#getItemValueString()

The following examples show how to use lotus.domino.Document#getItemValueString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RestViewNavigatorFactory.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
public String getForm() throws ServiceException {
    String result = "";
    if (isDocument()) {
        try {
            Document document = entry.getDocument();
            if (document != null) {
                result = document.getItemValueString(ITEM_FORM);
            }
        } catch (NotesException ex) {
            throw new ServiceException(ex,""); // $NON-NLS-1$
        }
    }
    return result;
}
 
Example 2
Source File: RecentContactsProvider.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
/**
 * Given a note received from another user, parse the from display name and internet address.
 * 
 * @param doc
 *           Email note to parse for sender data
 * @return
 * @throws NotesException
 */
private List<RecentContact> parseReceivedFromNote(final Document doc) throws NotesException
{
   // Currently only getting from address - may get items like others that were on the email
   // in the future.
   final List<RecentContact> recentContacts = new ArrayList<RecentContact>(1);
   final RecentContact sender = new RecentContact();
   recentContacts.add(sender);

   final Vector dateVec = doc.getItemValue("DeliveredDate"); //$NON-NLS-1$
   if (doc.hasItem("INetFrom")) //$NON-NLS-1$
   {
      sender.InternetAddress = doc.getItemValueString("INetFrom"); //$NON-NLS-1$

      if (sender.InternetAddress.contains("<"))
      {
         processComboInet(sender, sender.InternetAddress);
      }
      else
      {
         sender.DisplayName = doc.getItemValueString("From"); //$NON-NLS-1$
         sender.DisplayName = sender.DisplayName.replaceAll("CN=|OU=|O=|@.*", ""); //$NON-NLS-1$
      }
   }
   else
   {
      processComboInet(sender, doc.getItemValueString("From")); //$NON-NLS-1$
   }

   sender.lastContacted = getDateFromVector(dateVec);

   return recentContacts;
}
 
Example 3
Source File: Delegate901Provider.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
protected void setImpl(Database database, Delegate delegate, Document profile) throws ModelException, NotesException {
    AdministrationProcess adminp = null;
    
    try {
        Session session = database.getParent();
        
        // Can't modify the owner's access
        
        String owner = profile.getItemValueString(OWNER_ITEM);
        verifyDelegateNotOwner(session, delegate.getName(), owner);
        
        // Can't modify a delegate that's not there
        
        Vector[] vectors = loadVectors(profile);
        Name name = session.createName(delegate.getName());
        if ( !delegateExists(vectors, name.getCanonical()) ) {
            throw new ModelException("Delegate not found", ModelException.ERR_NOT_FOUND); // $NON-NLS-1$
        }
        
        // Update the right vector(s)

        delegateRemove(vectors, name.getCanonical());
        delegateAdd(vectors, name.getCanonical(), delegate.getAccess());
        
        // Send the adminp request
        
        String mailFile = database.getFilePath();
        String server = session.getServerName();
        
        adminp = session.createAdministrationProcess(null);
        String unid = adminp.delegateMailFile(owner, 
                            vectors[0], vectors[1], vectors[2], vectors[3], vectors[4], vectors[5],  
                            null, mailFile, server);
    }
    finally {
        BackendUtil.safeRecycle(adminp);
    }
}
 
Example 4
Source File: Delegate901Provider.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
protected void addImpl(Database database, Delegate delegate, Document profile) throws ModelException, NotesException {
    AdministrationProcess adminp = null;
    
    try {
        Session session = database.getParent();
        
        // Can't add the owner as a delegate
        
        String owner = profile.getItemValueString(OWNER_ITEM);
        verifyDelegateNotOwner(session, delegate.getName(), owner);
        
        // Can't add someone that's already there
        
        Vector[] vectors = loadVectors(profile);
        Name name = session.createName(delegate.getName());
        if ( delegateExists(vectors, name.getCanonical()) ) {
            throw new ModelException("A delegate of that name already exists", ModelException.ERR_CONFLICT); // $NON-NLS-1$
        }
        
        // Add the delegate to the right vector(s)
        
        delegateAdd(vectors, name.getCanonical(), delegate.getAccess());
        
        // Send the adminp request
        
        String mailFile = database.getFilePath();
        String server = session.getServerName();
        
        adminp = session.createAdministrationProcess(null);
        String unid = adminp.delegateMailFile(owner, 
                            vectors[0], vectors[1], vectors[2], vectors[3], vectors[4], vectors[5],  
                            null, mailFile, server);
    }
    finally {
        BackendUtil.safeRecycle(adminp);
    }
}
 
Example 5
Source File: Delegate901Provider.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
protected void deleteImpl(Database database, String name, Document profile) throws ModelException, NotesException {
    AdministrationProcess adminp = null;
    
    try {
        Session session = database.getParent();
        
        // Can't remove the owner
        
        String owner = profile.getItemValueString(OWNER_ITEM);
        verifyDelegateNotOwner(session, name, owner);
        
        // Can't remove a delegate that's not there
        
        Vector[] vectors = loadVectors(profile);
        Name no = session.createName(name);
        if ( !delegateExists(vectors, no.getCanonical()) ) {
            throw new ModelException("Delegate not found", ModelException.ERR_NOT_FOUND); // $NON-NLS-1$
        }

        // Send the adminp request
        
        Vector removeList = new Vector();
        removeList.add(no.getCanonical());
        
        String mailFile = database.getFilePath();
        String server = session.getServerName();
        
        adminp = session.createAdministrationProcess(null);
        String unid = adminp.delegateMailFile(owner, 
                            null, null, null, null, null, null, 
                            removeList, mailFile, server);
    }
    finally {
        BackendUtil.safeRecycle(adminp);
    }
}
 
Example 6
Source File: DelegateProvider.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
/**
 * Does most of the work of deleting a delegate.
 * 
 * <p>This version edits the ACL directly. A subclass may use adminp
 * to delete the delegate.
 * 
 * @param database
 * @param name The abbreviated name of the delegate to delete.
 * @param owner The canonical name of the mail file owner.
 * @throws ModelException
 * @throws NotesException
 */
protected void deleteImpl(Database database, String name, Document profile) throws ModelException, NotesException {
    ACL acl = null;
    
    try {
        if ( !hasManagerAccess(database) ) {
            throw new ModelException("Manager access is required to remove a delegate.", ModelException.ERR_NOT_ALLOWED); // $NLX-DelegateProvider.Manageraccessisrequiredtoremovead-1$
        }
        
        // Get the ACL
        
        acl = database.getACL();
        boolean deleted = false;
        ACLEntry entry = acl.getFirstEntry();
        
        // Get the owner of the mailfile
        
        String owner = profile.getItemValueString(OWNER_ITEM);
        
        // Look at each ACL entry
        
        while ( entry != null ) {
            
            Name no = entry.getNameObject();
            
            // If it's a match, delete it
            
            if ( name.equalsIgnoreCase(no.getAbbreviated()) ) {

                // But you can't remove the owner's access
                
                if ( owner != null && owner.equalsIgnoreCase(entry.getName()) ) {
                    throw new ModelException("Cannot remove the owner's access", ModelException.ERR_NOT_ALLOWED); // $NLX-DelegateProvider.Cannotremovetheownersaccess-1$
                }
                
                // It's gone
                
                acl.removeACLEntry(name);
                acl.save();
                deleted = true;
                break;
            }
            
            entry = acl.getNextEntry();
        }
        
        if ( !deleted ) {
            throw new ModelException("Delegate not found", ModelException.ERR_NOT_FOUND); // $NLX-DelegateProvider.Delegatenotfound.1-1$
        }
    } 
    finally {
        BackendUtil.safeRecycle(acl);
    }
}
 
Example 7
Source File: DelegateProvider.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
/**
 * Reads the list of delegates from the ACL.
 * 
 * <p>We don't use this code anymore, but it's kept here for
 * sentimental reasons.
 * 
 * @param database
 * @return
 * @throws NotesException
 */
private List<Delegate> getDelegatesFromAcl(Database database) throws NotesException {
    List<Delegate> delegates = new ArrayList<Delegate>();
    ACL acl = null;
    Document profile = null;
    
    try {
        // Get the owner of the mailfile
        
        profile = profileGet(database);
        String owner = profile.getItemValueString(OWNER_ITEM);
        
        // Get the ACL
        
        acl = database.getACL();
        ACLEntry entry = acl.getFirstEntry();
        
        // Convert each ACL entry to a delegate
        
        while ( entry != null ) {
            
            Delegate delegate = null;
            
            // Convert entry to delegate, unless this is the owner of the mail file
            
            if ( owner == null || !owner.equalsIgnoreCase(entry.getName()) ) {
                delegate = getDelegateFromAclEntry(entry);
            }
            
            // Add the delegate to the list
            
            if ( delegate != null ) {
                delegates.add(delegate);
            }
            
            entry = acl.getNextEntry();
        }

    }
    finally {
        BackendUtil.safeRecycle(acl);
        BackendUtil.safeRecycle(profile);
    }
    
    return delegates;
}