lotus.domino.Document Java Examples

The following examples show how to use lotus.domino.Document. 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: JsonDocumentCollectionContent.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
protected void writeEntry(JsonWriter jwriter, Document document 
        ) throws IOException, ServiceException, NotesException {

    String unid = document.getUniversalID();
    if (!StringUtil.isNotEmpty(unid)) {
        return;
    }
    jwriter.startArrayItem();
    jwriter.startObject();
    try {
        DateTime lastModified = document.getLastModified();
        if (lastModified != null)
            writeDominoProperty(jwriter, RestServiceConstants.ATTR_MODIFIED, lastModified);
        writeProperty(jwriter, RestServiceConstants.ATTR_UNID, unid);
        String link = _uri + unid;
        writeProperty(jwriter, RestServiceConstants.ATTR_HREF, link);
    } finally {
        jwriter.endArrayItem();     
        jwriter.endObject();
    }       
}
 
Example #2
Source File: NotesRunner.java    From org.openntf.domino with Apache License 2.0 6 votes vote down vote up
public void run2(final Session session) throws NotesException {
	Database db = session.getDatabase("", "log.nsf");
	Document doc = db.createDocument();
	Item names = doc.replaceItemValue("Names", "CN=Nathan T Freeman/O=REDPILL");
	names.setAuthors(true);
	doc.replaceItemValue("form", "test");
	doc.save(true);
	String nid = doc.getNoteID();
	doc.recycle();
	doc = db.getDocumentByID(nid);
	Vector<Double> numbers = new Vector<Double>();
	numbers.add(new Double(1));
	numbers.add(new Double(2));

	doc.replaceItemValue("Names", numbers);
	doc.save(true);
	doc.recycle();
	doc = db.getDocumentByID(nid);
	names = doc.getFirstItem("Names");
	System.out.println("Names is " + names.getType() + " with " + names.isNames() + " and " + names.isAuthors() + " and value "
			+ names.getText());
	doc.recycle();
	db.recycle();
}
 
Example #3
Source File: RestViewItemFileService.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
protected void createDocument(RestViewNavigator viewNav, RestDocumentNavigator docNav, JsonJavaObject items) throws ServiceException, JsonException, IOException {
    if(!queryNewDocument()) {
        throw new ServiceException(null, msgErrorCreatingDocument());
    }
    docNav.createDocument();
    Document doc = docNav.getDocument();
    postNewDocument(doc);
    try {
        updateFields(viewNav, docNav, items);
        String form = getParameters().getFormName();
        if (StringUtil.isNotEmpty(form)) {
            docNav.replaceItemValue(ITEM_FORM, form);
        }           
        if (getParameters().isComputeWithForm()) {
            docNav.computeWithForm();
        }
        if(!querySaveDocument(doc)) {
            throw new ServiceException(null, msgErrorCreatingDocument());
        }
        docNav.save();
        postSaveDocument(doc);
        getHttpResponse().setStatus(RSRC_CREATED.httpStatusCode);
    } finally {
        docNav.recycle(); 
    }
}
 
Example #4
Source File: OpenntfDominoDocumentData.java    From org.openntf.domino with Apache License 2.0 6 votes vote down vote up
/**
 * Opens the document with the given noteId
 * 
 * @param noteId
 * @return
 * @throws NotesException
 */
protected OpenntfDominoDocument openDocument(final String noteId) throws NotesException {

	Database db = openDatabase();
	boolean allowDelted = isAllowDeletedDocs();
	Document backendDoc = com.ibm.xsp.model.domino.DominoUtils.getDocumentById(db, noteId, allowDelted);

	if (backendDoc != null) {
		//				BackendBridge.setNoRecycle(backendDoc.getParentDatabase().getParent(), backendDoc, true);
	}

	DominoDocument dominoDoc = DominoDocument.wrap(getDatabaseName(), backendDoc, getComputeWithForm(), getConcurrencyMode(),
			allowDelted, getSaveLinksAs(), getWebQuerySaveAgent());
	OpenntfDominoDocument ntfDoc = wrap(dominoDoc, false);
	boolean editMode = "editDocument".equals(getEffectiveAction());
	ntfDoc.setEditable(editMode);
	return ntfDoc;
}
 
Example #5
Source File: DominoDocumentItem.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
public Object evaluate(RestDocumentService service, Document document) throws ServiceException {
	// TODO: How can we cache the item name so we do not reevaluate it all the time?
	String itemName = getItemName();
	try {
		if(StringUtil.isNotEmpty(itemName) && document.hasItem(itemName)) {
				return document.getItemValue(itemName);
		}
	} catch (NotesException e) {
		throw new ServiceException(e);
	}
	String var = service.getParameters().getVar();
	if(StringUtil.isNotEmpty(var)) {
		// TODO: Do that on a per item basis only...
		Object old = service.getHttpRequest().getAttribute(var); 
		try {
			service.getHttpRequest().setAttribute(var,document);
			return getValue();
		} finally {
			service.getHttpRequest().setAttribute(var,old);
		}
	} else {
		return getValue();
	}
}
 
Example #6
Source File: DelegateProvider.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
/**
 * Removes a delegate from the calendar profile.
 * 
 * @param profile
 * @param delegateName
 * @throws NotesException
 */
private void profileRemoveDelegate(Document profile, String delegateName) throws NotesException {
    Session session = profile.getParentDatabase().getParent();
    
    // Do for each delegate access item
    
    for ( int i = 0; i < s_items.length; i++ ) {

        // Read the item value
        Vector values = profile.getItemValue(s_items[i]);
        
        // Remove this name from the vector
        for ( int j = 0; j < values.size(); j++ ) {
            String strName = (String)values.get(j);
            Name name = session.createName(strName);
            if ( delegateName.equals(name.getAbbreviated())) {
                values.remove(j);
                profile.replaceItemValue(s_items[i], values);
                break;
            }
        }
    }
}
 
Example #7
Source File: NotesFunctionsEx.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
public static Document getDocument(Object var) {
    if (var instanceof Document) {
        return (Document) var;
    }
    if (var instanceof DominoDocument) {
        return ((DominoDocument) var).getDocument();
    }
    if (var instanceof String) {
        Object data = FacesUtil.resolveRequestMapVariable(FacesContext.getCurrentInstance(), (String) var);
        if (data instanceof DominoDocument) {
            DominoDocument dd = (DominoDocument) data;
            return (Document) dd.getDocument();
        }
        if (data instanceof Document) {
            return (Document) data;
        }
    }
    throw new FacesExceptionEx(null, "Cannot find document {0}", var); // $NLX-NotesFunctionEx_CannotFindNotesDocument-1$
}
 
Example #8
Source File: JsonDocumentContent.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
protected void writeHiddenSystemItems(JsonWriter jsonWriter, Document document) 
            throws IOException, ServiceException {
        try {
            Vector<?> items = document.getItems();
            
            for (int i = 0; i < items.size(); ++i) {
                Item item = (Item)items.get(i);
                String itemName = item.getName();
                if (itemName.charAt(0) == '$') {
//                  String text = item.getText();
//                  if (text.length() > 0) {
//                      writeProperty(jsonWriter, itemName, text);  
//                  }
                    if (itemName.equalsIgnoreCase(ITEM_FILE)) {
                        // Ignore $FILE item.
                    }
                    if (itemName.equalsIgnoreCase(ITEM_FONTS)) {
                        // Ignore $FONTS item.
                    } else {
                        writeItem(jsonWriter, item, false);
                    }
                }
            }
        } catch (NotesException ex) {
            throw new ServiceException(ex);
        }
    }
 
Example #9
Source File: LegacyAPIUtils.java    From domino-jna with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a C handle to a legacy {@link Document}
 * 
 * @param db parent database
 * @param handle handle
 * @return document
 * @deprecated does not seem to work yet, always returns null
 */
public static Document createDocument(Database db, long handle) {
	initialize();

	if (createDocument==null) {
		throw new NotesError(0, "Required method BackendBridge.createDocument(Database,long) not available in this environment");
	}

	try {
		Document doc = (Document) createDocument.invoke(null, db, handle);
		return doc;
	} catch (Exception e) {
		throw new NotesError(0, "Could not convert document c handle", e);
	}
}
 
Example #10
Source File: BluemixUtil.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public static String createLocalDatabaseCopy(Database db, String destDbName) throws Throwable {
    Database newDb = null;
    String newDbPath = null;
    try {
        // Make a copy of the database
        newDb = db.createCopy(null, destDbName);
        newDbPath = newDb.getFilePath();
            
        // Copy all the docs
        DocumentCollection col = db.getAllDocuments();
        Document doc = col.getFirstDocument();
        while (doc != null) {
            doc.copyToDatabase(newDb);
            doc = col.getNextDocument();
        }
        
        // Copy the profile docs
        col = db.getProfileDocCollection(null);
        doc = col.getFirstDocument();
        while (doc != null) {
            doc.copyToDatabase(newDb);
            doc = col.getNextDocument();
        }
    } finally {
        if (newDb != null) {
            try {
                // Ensure db is flushed to disk
                newDb.recycle();
                // Add a pause for safety, just in case another thread handles the flush
                Thread.sleep(1000);
            } catch (NotesException e) {
                if (BluemixLogger.BLUEMIX_LOGGER.isErrorEnabled()) {
                    BluemixLogger.BLUEMIX_LOGGER.errorp(null, "createLocalDatabaseCopy", e, "Failed to recycle newDb"); // $NON-NLS-1$ $NLE-BluemixUtil.FailedtorecyclenewDb-2$
                }
            }
        }
    }
    
    return newDbPath;
}
 
Example #11
Source File: LegacyAPIUtils.java    From domino-jna with Apache License 2.0 5 votes vote down vote up
/**
 * Reads the C handle for the specific legacy {@link Document}
 * 
 * @param doc document
 * @return handle
 */
public static long getDocHandle(Document doc) {
	initialize();

	if (getDocumentHandleRW==null) {
		throw new NotesError(0, "Required method BackendBridge.getDocumentHandleRW(Document) class not available in this environment");
	}

	try {
		long cHandle = (Long) getDocumentHandleRW.invoke(null, doc);
		return cHandle;
	} catch (Exception e) {
		throw new NotesError(0, "Could not read document c handle", e);
	}
}
 
Example #12
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 #13
Source File: LegacyAPIUtils.java    From domino-jna with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a legacy {@link Document} to a {@link NotesNote}
 * 
 * @param doc legacy document
 * @return JNA note
 */
public static NotesNote toNotesNote(final Document doc) {
	return new NotesNote(new IAdaptable() {

		@Override
		public <T> T getAdapter(Class<T> clazz) {
			if (clazz == Document.class)
				return (T) doc;
			else
				return null;
		}
	});
}
 
Example #14
Source File: BaseJNATestClass.java    From domino-jna with Apache License 2.0 5 votes vote down vote up
private void createSampleDbDirProfile(Database db) throws NotesException {
	Document docProfile = db.getProfileDocument("DirectoryProfile", null);
	docProfile.replaceItemValue("Form", "DirectoryProfile");
	docProfile.replaceItemValue("Domain", db.getParent().evaluate("@Domain", docProfile));
	docProfile.replaceItemValue("GroupSortDefault", "1");
	docProfile.replaceItemValue("AutoPopulateMembersInterval", "30");
	docProfile.replaceItemValue("SecureInetPasswords", "1");
	docProfile.replaceItemValue("AltLanguageInfoAllowed", "1");
	docProfile.computeWithForm(false, false);
	docProfile.save(true, false);
	docProfile.recycle();
}
 
Example #15
Source File: TestAgentExecution.java    From domino-jna with Apache License 2.0 5 votes vote down vote up
public void testAgentExecution_runAgentWithLegacyDoc() {
	runWithSession(new IDominoCallable<Object>() {

		@Override
		public Object call(Session session) throws Exception {
			NotesDatabase dbData = getFakeNamesDb();
			Database dbDataLegacy = session.getDatabase(dbData.getServer(), dbData.getRelativeFilePath());
			
			NotesAgent testAgent = dbData.getAgent("AgentRun Test LS");
			
			StringWriter stdOut = new StringWriter();
			
			boolean checkSecurity = true;
			boolean reopenDbAsSigner = false;
			int timeoutSeconds = 0;
			
			Document doc = dbDataLegacy.createDocument();
			doc.replaceItemValue("testitem", "1234");

			testAgent.run(
					new NotesAgentRunContext()
					.setCheckSecurity(checkSecurity)
					.setReopenDbAsSigner(reopenDbAsSigner)
					.setOutputWriter(stdOut)
					.setTimeoutSeconds(timeoutSeconds)
					.setDocumentContextAsLegacyDoc(doc)
					);

			String retValue = doc.getItemValueString("returnValue");
			System.out.println("Return value: "+retValue);
			
			doc.recycle();
			
			System.out.println(stdOut);
			
			return null;
		}
	});
}
 
Example #16
Source File: ViewEntryImpl.java    From domino-jna with Apache License 2.0 5 votes vote down vote up
@Override
public Document getDocument() throws NotesException {
	try {
		return m_parent.getParent().getDocumentByID(Integer.toString(m_data.getNoteId(), 16));
	}
	catch (NotesException e) {
		if (e.id == 4091)
			return null;
		else
			throw e;
	}
}
 
Example #17
Source File: MimeMessageParser.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
private static void writeAddresses(Document document, String itemName, AddressList addresses) throws NotesException {

        document.removeItem(itemName);
        
        if ( addresses != null && addresses.size() > 0 ) {
            Vector<String> values = new Vector<String>();
            for ( int i = 0; i < addresses.size(); i++ ) {
                Address address = addresses.get(i);
                values.add(address.toString());
            }
            
            document.replaceItemValue(itemName, values);
        }
    }
 
Example #18
Source File: DataInitializer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
void createState(Database db, String key, String name) throws NotesException {
	Document doc = db.createDocument();
	try {
		doc.replaceItemValue("Form","State");		
		doc.replaceItemValue("Key",key);		
		doc.replaceItemValue("Name",name);		
		doc.save();
	} finally {
		doc.recycle();
	}
}
 
Example #19
Source File: Delegate901Provider.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
private Vector[] loadVectors(Document profile) throws NotesException {
    Vector[] vectors = new Vector[s_items.length];
    
    for ( int i = 0; i < s_items.length; i++ ) {
        String item = s_items[i];
        vectors[i] = profile.getItemValue(item);
    }
    
    return vectors;
}
 
Example #20
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 #21
Source File: RestViewNavigatorFactory.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
protected ViewNavigator createNavigator() throws NotesException {
    String parentId = getParameters().getParentId();
    Document doc = null;
    
    if (parentId.length() == 32)                
        doc = view.getParent().getDocumentByUNID(parentId);
    else
        doc = view.getParent().getDocumentByID(parentId);
    
    return view.createViewNavFromDescendants(doc);
}
 
Example #22
Source File: Create200KLotus.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
	try {
		Document doc = null;
		System.out.println("START Creation of Documents:" + new Date().toString());
		Session s = Factory.getSession(SessionType.CURRENT);
		Set<Document> docset = new HashSet<Document>();
		Database db = s.getDatabase("", "OneMillionLotus.nsf", true);
		if (!db.isOpen()) {
			Database db2 = s.getDatabase("", "billing.ntf", true);
			db = db2.createCopy("", "OneMillionLotus.nsf");
			if (!db.isOpen())
				db.open();
		}

		for (int i = 1; i < 200000; i++) {
			doc = db.createDocument();
			doc.replaceItemValue("form", "doc");
			doc.replaceItemValue("Subject", String.valueOf(System.nanoTime()));
			doc.save();
			doc.recycle();
			if (i % 5000 == 0) {
				System.out.println("Created " + i + " documents so far. Still going...");
			}
		}
		System.out.println("ENDING Creation of Documents: " + new Date().toString());
	} catch (lotus.domino.NotesException e) {
		System.out.println(e.toString());
	}
}
 
Example #23
Source File: JsonMessageParser.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public void fromJson(Document document) throws JsonException {

        // SPR #DDEY9L6MX5: Add a Form item
        try {
            if ( !document.hasItem(FORM_ITEM) ) {
                document.replaceItemValue(FORM_ITEM, MEMO_FORM);
            }
        }
        catch (NotesException e) {
            // Ignore exception
        }
        
		JsonFactory factory = new JsonObjectFactory(document);
    	JsonParser.fromJson(factory, _reader);
    }
 
Example #24
Source File: JsonMessageGenerator.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
public void toJson(Document document, String url) throws JsonException, IOException {
	JsonMessageAdapter messageAdapter = new JsonMessageAdapter(document, url);
    _generator.toJson(messageAdapter);
}
 
Example #25
Source File: JsonDocumentContent.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
public JsonDocumentContent(Document document, RestDocumentService service) {
    this.document = document;
    this.service = service;
}
 
Example #26
Source File: DataInitializer.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
void createAllType(Database db, int index) throws NotesException {
	Session session = db.getParent();
	String sIndex = Integer.toString(index);
	Document doc = db.createDocument();
	try {
		doc.replaceItemValue("Form","AllTypes");	
		
		doc.replaceItemValue("fldIcon",index);		
		doc.replaceItemValue("fldText","text_"+sIndex);		
		doc.replaceItemValue("fldNumber",index*100);
		doc.replaceItemValue("fldDate",createDate(session, 2010, 1, index));
		doc.replaceItemValue("fldTime",createTime(session, 5, 1, index));
		doc.replaceItemValue("fldDateTime",createDateTime(session, 2011, 2, index, 8, 9, index));
		doc.replaceItemValue("fldDateTimeRange",createDateTimeRange(session, 2012, 3, index, 8, 9, index));
		doc.replaceItemValue("fldDialogList","dlg_"+sIndex);	
		
		Vector<Object> mx = new Vector<Object>();
		mx.add("text_"+sIndex+"_1");
		mx.add("text_"+sIndex+"_2");
		mx.add("text_"+sIndex+"_3");
		doc.replaceItemValue("fldText2",mx);		
		
		Vector<Object> mn = new Vector<Object>();
		mn.add(index*100+1);
		mn.add(index*100+2);
		mn.add(index*100+3);
		doc.replaceItemValue("fldNumber2",mn);		

		Vector<Object> md = new Vector<Object>();
		md.add(createDate(session, 2010, 1, index));
		md.add(createDate(session, 2010, 2, index));
		md.add(createDate(session, 2010, 3, index));
		doc.replaceItemValue("fldDate2",md);		

		Vector<Object> mt = new Vector<Object>();
		mt.add(createTime(session, 6, 1, index));
		mt.add(createTime(session, 6, 2, index));
		mt.add(createTime(session, 6, 3, index));
		doc.replaceItemValue("fldTime2",mt);		

		Vector<Object> mdt = new Vector<Object>();
		mdt.add(createDateTime(session, 2011, 1, index, 6, 1, index));
		mdt.add(createDateTime(session, 2011, 2, index, 6, 2, index));
		mdt.add(createDateTime(session, 2011, 3, index, 6, 3, index));
		doc.replaceItemValue("fldDateTime2",mdt);		

		if(false) { // DateTime range do not work with multiple values?
			Vector<Object> mrg = new Vector<Object>();
			mrg.add(createDateTimeRange(session, 2012, 2, index, 4, 1, index));
			mrg.add(createDateTimeRange(session, 2012, 3, index, 5, 1, index));
			mrg.add(createDateTimeRange(session, 2012, 4, index, 6, 1, index));
			doc.replaceItemValue("fldDateTimeRange2",mrg);
		}
		
		Vector<Object> mdg = new Vector<Object>();
		mdg.add("dlgx_"+sIndex+"_1");
		mdg.add("dlgx_"+sIndex+"_1");
		mdg.add("dlgx_"+sIndex+"_1");
		doc.replaceItemValue("fldDialogList2",mdg);		

		doc.save();
	} finally {
		doc.recycle();
	}
}
 
Example #27
Source File: RecentContactsProvider.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
/**
 * Given a note that was sent to other users - parse display names and internet addresses. List of PersonRecords will
 * be returned for data parsed from TO, CC, and BCC fields.
 * 
 * @param doc
 *           Email note to parse for recipient data
 * @return
 * @throws NotesException
 */
private List<RecentContact> parseSentToFromNote(final Document doc) throws NotesException
{
   final List<RecentContact> recentContacts = new LinkedList<RecentContact>();

   final Vector dateVec = doc.getItemValue("PostedDate"); //$NON-NLS-1$
   final Date emailDate = getDateFromVector(dateVec);

   final String[][] itemPairsToRead = { { "InetSendTo", "SendTo" }, //$NON-NLS-1$ //$NON-NLS-2$ 
                       { "InetCopyTo", "CopyTo" }, //$NON-NLS-1$ //$NON-NLS-2$
                       { "InetBlindCopyTo", "BlindCopyTo" } }; //$NON-NLS-1$ //$NON-NLS-2$

   for (int i = 0; i < itemPairsToRead.length; ++i)
   {
      final Vector inetVector = doc.getItemValue(itemPairsToRead[i][0]);
      final Vector nameVector = doc.getItemValue(itemPairsToRead[i][1]);

      if (nameVector == null || nameVector.size() == 0)
      {
         continue;
      }

      final boolean hasInet = (inetVector != null && inetVector.size() > 0);

      for (int addrIndex = 0; addrIndex < nameVector.size(); ++addrIndex)
      {
         final RecentContact person = new RecentContact();

         if (hasInet && !(person.InternetAddress = (String) inetVector.get(addrIndex)).contains("<"))
         {
            person.DisplayName = (String) nameVector.get(addrIndex);
            person.DisplayName = person.DisplayName.replaceAll("CN=|OU=|O=|@.*", ""); //$NON-NLS-1$
         }
         else
         {
            // This is not a notes recipient then - address in SendTo
            processComboInet(person, (String) nameVector.get(addrIndex));
         }

         person.lastContacted = emailDate;
         recentContacts.add(person);
      }
   }

   return recentContacts;
}
 
Example #28
Source File: DelegateProvider.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
/**
 * Does most of the work of updating a delegate.
 * 
 * <p>This version edits the ACL directly. A subclass may use adminp
 * to update the delegate.
 * 
 * @param database
 * @param delegate
 * @throws ModelException
 * @throws NotesException
 */
protected void setImpl(Database database, Delegate delegate, Document profile) throws ModelException, NotesException {
    ACL acl = null;
    
    try {
        if ( !hasManagerAccess(database) ) {
            throw new ModelException("Manager access is required to modify a delegate.", ModelException.ERR_NOT_ALLOWED); // $NLX-DelegateProvider.Manageraccessisrequiredtomodifyad-1$
        }
        
        acl = database.getACL();
        
        // Find the matching delegate
        
        boolean updated = false;
        ACLEntry entry = acl.getFirstEntry();
        while ( entry != null ) {
            Name no = entry.getNameObject();

            if ( delegate.getName().equalsIgnoreCase(no.getAbbreviated()) ) {
                // Clear the current access
                entry.setLevel(ACL.LEVEL_NOACCESS);
                entry.setPublicReader(false);
                entry.setPublicWriter(false);
                
                // Apply the new access
                aclEntryFromDelegate(delegate, entry);
                acl.save();
                updated = true;
                break;
            }
            
            entry = acl.getNextEntry();
        }

        if ( !updated ) {
            throw new ModelException("Delegate not found", ModelException.ERR_NOT_FOUND); // $NLX-DelegateProvider.Delegatenotfound-1$
        }
    } 
    finally {
        BackendUtil.safeRecycle(acl);
    }
}
 
Example #29
Source File: RestDocumentNavigatorFactory.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
protected void initDocument(Document doc) {
    //doc.setPreferJavaDates(true);
}
 
Example #30
Source File: JsonMessageParser.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
public JsonObjectFactory(Document document) {
	_document = document;
}