/** * Constructs a DN (Distinguished Name) string for the ecoinformatics.org LDAP. * * @param username The LDAP uid, e.g. "dcosta" * @param organization The LDAP organization, e.g. "LTER" * @return DN The distinguished name string. */ public String constructDN(final String username, final String organization) { String DC; try { DC = PropertyService.getProperty("auth.base"); } catch (PropertyNotFoundException pnfe) { DC = "dc=ecoinformatics,dc=org"; logMetacat.error( "Could not find property: auth.base. Setting to: " + "dc=ecoinformatics,dc=org : " + pnfe.getMessage()); } final String DN = "uid=" + username + ",o=" + organization + "," + DC; return DN; }
/** * Main method used for testing the class output * * @param args no arguments used in this main method */ public static void main(String[] args) { String CONFIG_DIR = "lib"; File dirPath = new File(CONFIG_DIR); try { PropertyService.getInstance(dirPath.getPath() + FileUtil.getFS() + "metacat.properties"); } catch (ServiceException ioe) { System.err.println("Error in loading properties: " + ioe.getMessage()); } String[] ids = new String[3]; ids[0] = "ces_dataset.23.1"; ids[1] = "knb-lter-vcr.97.1"; ids[2] = "obfs.400.1"; String pathquery = null; try { pathquery = createDocidQuery(ids); } catch (PropertyNotFoundException pnfe) { System.out.println("Could not create doc id query: " + pnfe.getMessage()); } System.out.println(pathquery); }