Java Code Examples for lotus.domino.Session#createName()
The following examples show how to use
lotus.domino.Session#createName() .
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: ViewRowDataOverride.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
/** * Return the name of Database contain the View this View Entry comes from. * If Database is remote - then name is <db server>!!<database file path> * * @return Return the name of Database contain the View this View Entry comes from. * @throws NotesException */ public String getDatabaseName() throws NotesException { Database db = getDatabase(); Session session = db.getParent(); String databaseName = PlatformUtil.getRelativeFilePath(db); if (StringUtil.isNotEmpty(db.getServer())) { Name serverName = session.createName(db.getServer()); if(serverName.isHierarchical()){ // SPR# EGLN92PHT6 // Use common rather than abbreviated name due to encoding complications with abbreviated format databaseName = serverName.getCommon() + "!!" + databaseName; // $NON-NLS-1$ // serverName.getAbbreviated() + "!!" + databaseName; // $NON-NLS-1$ } } return databaseName; }
Example 2
Source File: DominoNABNamePickerData.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
private static String formatName(String baseName, NameFormat format) throws NotesException { // optionally reformat the name, as contributed in #14 subpart D1: // https://github.com/OpenNTF/XPagesExtensionLibrary/pull/14 if( StringUtil.isEmpty(baseName) ){ // don't format empty string return baseName; } if (NameFormat.UNFORMATTED == format) { return baseName; } else { Session sess = ExtLibUtil.getCurrentSession(); Name nm = sess.createName(baseName); // throws NotesException switch(format){ case ABBREVIATED: return nm.getAbbreviated(); case CANONICAL: return nm.getCanonical(); case COMMON: return nm.getCommon(); default: return baseName; // won't happen } } }
Example 3
Source File: DelegateProvider.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
/** * 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 4
Source File: DominoUserBeanDataProvider.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") // $NON-NLS-1$ private PeopleData getPeopleData(PersonImpl person) { String id = person.getId(); if(StringUtil.isEmpty(id)) { return EMPTY_DATA; } PeopleData data = (PeopleData)getProperties(id,PeopleData.class); if(data==null) { synchronized(getSyncObject()) { data = (PeopleData)getProperties(id,PeopleData.class); if(data==null) { try { data = new PeopleData(); Session session = ExtLibUtil.getCurrentSession(FacesContext.getCurrentInstance()); // TODO get a Notes/Domino id from an identity provider... Name n = session.createName(id); data.displayName = getCommonName(session, id, n); //n.getCommon(); data.abbreviatedName = n.getAbbreviated(); data.canonicalName = n.getCanonical(); data.effectiveUserName = session.getEffectiveUserName(); addProperties(id,data); } catch(NotesException ex) { throw new FacesExceptionEx(ex,"Error while retrieving user names"); // $NLX-DominoUserBeanDataProvider.Errorwhileretrievingusernames-1$ } } } } return data; }
Example 5
Source File: Delegate901Provider.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
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 6
Source File: Delegate901Provider.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
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 7
Source File: Delegate901Provider.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
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 8
Source File: FreeRooms901Provider.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
private Room parseRoom(Session session, String rawValue) throws NotesException { Room room = null; String displayName = null; String distinguishedName = null; String domain = null; String email = null; int capacity = 0; StringTokenizer tokenizer = new StringTokenizer(rawValue, ";"); if ( tokenizer.hasMoreTokens() ) { // Get room name String rawName = tokenizer.nextToken(); Name name = session.createName(rawName); displayName = name.getCommon(); distinguishedName = name.getAbbreviated(); } if ( tokenizer.hasMoreTokens() ) { try { // Get room capacity String rawCapacity = tokenizer.nextToken(); capacity = Integer.parseInt(rawCapacity); } catch (NumberFormatException e) { // Ignore } } if ( tokenizer.hasMoreTokens() ) { // Get email address, but ignore bad addresses. // TODO: Revisit this. The initial implementation of freeResourceSearch was returning // a bad email address for rooms without a stored email address. The bad address // had a trailing "@". When the freeResourceSearch is fixed, we can remove some of // this code. String rawEmail = tokenizer.nextToken(); if ( rawEmail != null && !rawEmail.endsWith("@") ) { email = rawEmail; } } return new Room(displayName, distinguishedName, domain, email, capacity); }
Example 9
Source File: Delegate901Provider.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
private void verifyDelegateNotOwner(Session session, String delegate, String canonicalOwner) throws ModelException, NotesException { Name no = session.createName(canonicalOwner); if ( delegate.equalsIgnoreCase(no.getAbbreviated()) ) { throw new ModelException("Owner cannot be a delegate.", ModelException.ERR_NOT_ALLOWED); // $NON-NLS-1$ } }
Example 10
Source File: DelegateProvider.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
/** * Adds a delegate to the calendar profile. * * @param profile * @param delegate * @throws NotesException */ private void profileAddDelegate(Document profile, Delegate delegate) throws NotesException { Session session = profile.getParentDatabase().getParent(); Name name = session.createName(delegate.getName()); DelegateAccess da = delegate.getAccess(); String appendItems[] = null; if ( da.getWhat() == DelegateAccess.What.CALENDAR ) { if ( da.isCreate() || da.isEdit() || da.isDelete() ) { appendItems = new String[] {READ_CALENDAR_ITEM, WRITE_CALENDAR_ITEM}; } else { appendItems = new String[] {READ_CALENDAR_ITEM}; } } else if ( da.getWhat() == DelegateAccess.What.MAIL ) { if ( da.isEdit() ) { if ( da.isDelete() ) { appendItems = new String[] {WRITE_CALENDAR_ITEM, EDIT_MAIL_ITEM, DELETE_MAIL_ITEM}; } else { appendItems = new String[] {WRITE_CALENDAR_ITEM, EDIT_MAIL_ITEM}; } } else if ( da.isCreate() ) { if ( da.isDelete() ) { appendItems = new String[] {WRITE_CALENDAR_ITEM, WRITE_MAIL_ITEM, DELETE_MAIL_ITEM}; } else { appendItems = new String[] {WRITE_CALENDAR_ITEM, WRITE_MAIL_ITEM}; } } else { appendItems = new String[] {READ_MAIL_ITEM}; } } // Do for each delegate access item if ( appendItems != null ) { for ( int i = 0; i < appendItems.length; i++ ) { // Read the item value Vector values = profile.getItemValue(appendItems[i]); // Add the name to the vector values.add(name.getCanonical()); profile.replaceItemValue(appendItems[i], values); } } }
Example 11
Source File: LookupProvider.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
public MailUser findMailUser(Session session, String userName) throws ModelException { MailUser mu = null; Directory lookupDir = null; Name no = null; try { lookupDir = session.getDirectory(); if ( lookupDir == null ) { throw new ModelException("Cannot lookup the name."); // $NLX-LookupProvider.Cannotlookupthename-1$ } Vector<String> vName = new Vector<String>(); vName.addElement(userName); DirectoryNavigator dirNav = lookupDir.lookupNames("($Users)", vName, s_userLookupItems, true); //$NON-NLS-1$ if( dirNav == null || dirNav.getCurrentMatches() == 0 ){ throw new ModelException("Name not found.", ModelException.ERR_NOT_FOUND); // $NLX-LookupProvider.Namenotfound-1$ } // Digest the results of the lookup Vector<String> value = null; value = dirNav.getFirstItemValue(); String fullName = value.elementAt(0); no = session.createName(fullName); value = dirNav.getNextItemValue(); String mailFile = value.elementAt(0); if ( StringUtil.isNotEmpty(mailFile) && !mailFile.toLowerCase().endsWith(DOT_NSF) ) { mailFile = mailFile + DOT_NSF; } value = dirNav.getNextItemValue(); String mailServer = value.elementAt(0); value = dirNav.getNextItemValue(); String emailAddress = value.elementAt(0); mu = new MailUser(no.getCommon(), no.getAbbreviated(), emailAddress, mailServer, mailFile); } catch (NotesException e) { throw new ModelException("Error looking up user name.", e); // $NLX-LookupProvider.Errorlookingupusername-1$ } finally { BackendUtil.safeRecycle(no); BackendUtil.safeRecycle(lookupDir); } return mu; }
Example 12
Source File: LookupProvider.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
public Server findServer(Session session, String serverName) throws ModelException { Server server = null; Directory lookupDir = null; Name no = null; try { lookupDir = session.getDirectory(); if ( lookupDir == null ) { throw new ModelException("Cannot lookup the server."); // $NLX-LookupProvider.Cannotlookuptheserver-1$ } Vector<String> vName = new Vector<String>(); vName.addElement(serverName); DirectoryNavigator dirNav = lookupDir.lookupNames("($Servers)", vName, s_serverLookupItems, true); //$NON-NLS-1$ if( dirNav == null || dirNav.getCurrentMatches() == 0 ){ throw new ModelException("Server not found.", ModelException.ERR_NOT_FOUND); // $NLX-LookupProvider.Servernotfound-1$ } // Digest the results of the server lookup String hostName = null; Vector<String> value = null; value = dirNav.getFirstItemValue(); String fullName = value.elementAt(0); no = session.createName(fullName); Vector<String> ports = dirNav.getNextItemValue(); value = dirNav.getNextItemValue(); for ( int i = 0; i < ports.size(); i++) { if ( "TCPIP".equals(ports.elementAt(i)) ) { //$NON-NLS-1$ hostName = value.elementAt(i); break; } } value = dirNav.getNextItemValue(); String clusterName = value.elementAt(0); value = dirNav.getNextItemValue(); boolean imsaServer = false; if ( value != null && value.size() > 0 ) { String strImsaServer = value.elementAt(0); if ( "1".equals(strImsaServer) ) { imsaServer = true; } } server = new Server(no.getAbbreviated(), hostName, clusterName, imsaServer); } catch (NotesException e) { throw new ModelException("Error looking up server.", e); // $NLX-LookupProvider.Errorlookingupserver-1$ } finally { BackendUtil.safeRecycle(no); BackendUtil.safeRecycle(lookupDir); } return server; }
Example 13
Source File: NotesRunner.java From org.openntf.domino with Apache License 2.0 | 4 votes |
public void run1(final Session session) throws NotesException { Long sessId = getLotusId(session); sessionid.set(sessId); Database db = session.getDatabase("", "names.nsf"); System.out.println("Db id:" + getLotusId(db)); Name name = null; int i = 0; try { for (i = 0; i <= 100000; i++) { name = session.createName(UUID.randomUUID().toString()); getLotusId(name); DateTime dt = session.createDateTime(new Date()); getLotusId(dt); DateTime end = session.createDateTime(new Date()); getLotusId(end); DateRange dr = session.createDateRange(dt, end); getLotusId(dr); Document doc = db.createDocument(); getLotusId(doc); Item i1 = doc.replaceItemValue("Foo", dr); getLotusId(i1); Item i2 = doc.replaceItemValue("Bar", dr.getText()); getLotusId(i2); Item i3 = doc.replaceItemValue("Blah", dr.getStartDateTime().getLocalTime()); getLotusId(i3); lotus.domino.ColorObject color = session.createColorObject(); getLotusId(color); color.setRGB(128, 128, 128); Item i4 = doc.replaceItemValue("color", color.getNotesColor()); getLotusId(i4); i1.recycle(); i2.recycle(); i3.recycle(); i4.recycle(); DateTime create = doc.getCreated(); getLotusId(create); @SuppressWarnings("unused") String lc = create.getLocalTime(); // if (i % 10000 == 0) { // System.out.println(Thread.currentThread().getName() + " Name " + i + " is " + name.getCommon() + " " // + "Local time is " + lc + " " + dr.getText()); // } dr.recycle(); doc.recycle(); dt.recycle(); end.recycle(); create.recycle(); color.recycle(); name.recycle(); } } catch (Throwable t) { t.printStackTrace(); System.out.println("Exception at loop point " + i); } }