/** * @param source source input stream * @return InputStream the resulting input stream */ public InputStream getDestinationStream(InputStream source) throws Exception { try { boolean useTemporaryFile = ConfigurationManager.getBooleanProperty("pdffilter.largepdfs", false); // get input stream from bitstream // pass to filter, get string back PDFTextStripper pts = new PDFTextStripper(); PDDocument pdfDoc = null; Writer writer = null; File tempTextFile = null; ByteArrayOutputStream byteStream = null; if (useTemporaryFile) { tempTextFile = File.createTempFile("dspacepdfextract" + source.hashCode(), ".txt"); tempTextFile.deleteOnExit(); writer = new OutputStreamWriter(new FileOutputStream(tempTextFile)); } else { byteStream = new ByteArrayOutputStream(); writer = new OutputStreamWriter(byteStream); } try { pdfDoc = PDDocument.load(source); pts.writeText(pdfDoc, writer); } finally { try { if (pdfDoc != null) pdfDoc.close(); } catch (Exception e) { log.error("Error closing PDF file: " + e.getMessage(), e); } try { writer.close(); } catch (Exception e) { log.error("Error closing temporary extract file: " + e.getMessage(), e); } } if (useTemporaryFile) { return new FileInputStream(tempTextFile); } else { byte[] bytes = byteStream.toByteArray(); return new ByteArrayInputStream(bytes); } } catch (OutOfMemoryError oome) { log.error("Error parsing PDF document " + oome.getMessage(), oome); if (!ConfigurationManager.getBooleanProperty("pdffilter.skiponmemoryexception", false)) { throw oome; } } return null; }
/** * Return a url to the DSpace object, either use the official handle for the item or build a url * based upon the current server. * * <p>If the dspaceobject is null then a local url to the repository is generated. * * @param request current servlet request * @param dso The object to reference, null if to the repository. * @return URL */ protected String resolveURL(HttpServletRequest request, DSpaceObject dso) { // If no object given then just link to the whole repository, // since no offical handle exists so we have to use local resolution. if (dso == null) { if (baseURL == null) { if (request == null) { baseURL = ConfigurationManager.getProperty("dspace.url"); } else { baseURL = (request.isSecure()) ? "https://" : "http://"; baseURL += ConfigurationManager.getProperty("dspace.hostname"); baseURL += ":" + request.getServerPort(); baseURL += request.getContextPath(); } } return baseURL; } // return a link to handle in repository else if (ConfigurationManager.getBooleanProperty("webui.feed.localresolve")) { return resolveURL(request, null) + "/handle/" + dso.getHandle(); } // link to the Handle server or other persistent URL source else { return HandleServiceFactory.getInstance() .getHandleService() .getCanonicalForm(dso.getHandle()); } }
// initialize - get plugins and MD field settings from config @Override public void afterPropertiesSet() throws Exception { if (terms_schema == null) { String terms = ConfigurationManager.getProperty("embargo.field.terms"); String lift = ConfigurationManager.getProperty("embargo.field.lift"); if (terms == null || lift == null) { throw new IllegalStateException( "Missing one or more of the required DSpace configuration properties for EmbargoManager, check your configuration file."); } terms_schema = getSchemaOf(terms); terms_element = getElementOf(terms); terms_qualifier = getQualifierOf(terms); lift_schema = getSchemaOf(lift); lift_element = getElementOf(lift); lift_qualifier = getQualifierOf(lift); setter = (EmbargoSetter) PluginManager.getSinglePlugin(EmbargoSetter.class); if (setter == null) { throw new IllegalStateException( "The EmbargoSetter plugin was not defined in DSpace configuration."); } lifter = (EmbargoLifter) PluginManager.getSinglePlugin(EmbargoLifter.class); if (lifter == null) { throw new IllegalStateException( "The EmbargoLifter plugin was not defined in DSpace configuration."); } } }
@Override public void init(Curator curator, String taskId) throws IOException { super.init(curator, taskId); host = ConfigurationManager.getProperty(PLUGIN_PREFIX, "service.host"); port = ConfigurationManager.getIntProperty(PLUGIN_PREFIX, "service.port"); timeout = ConfigurationManager.getIntProperty(PLUGIN_PREFIX, "socket.timeout"); failfast = ConfigurationManager.getBooleanProperty(PLUGIN_PREFIX, "scan.failfast"); }
/** Create an HTML Servlet */ public HTMLServlet() { super(); if (ConfigurationManager.getProperty("webui.html.max-depth-guess") != null) { maxDepthGuess = ConfigurationManager.getIntProperty("webui.html.max-depth-guess"); } else { maxDepthGuess = 3; } }
/* * Add authenticated users to the group defined in dspace.cfg by * the authentication-ldap.login.groupmap.* key. */ private void assignGroups(String dn, String group, Context context) { if (StringUtils.isNotBlank(dn)) { System.out.println("dn:" + dn); int i = 1; String groupMap = ConfigurationManager.getProperty("authentication-ldap", "login.groupmap." + i); boolean cmp; while (groupMap != null) { String t[] = groupMap.split(":"); String ldapSearchString = t[0]; String dspaceGroupName = t[1]; if (group == null) { cmp = StringUtils.containsIgnoreCase(dn, ldapSearchString + ","); } else { cmp = StringUtils.equalsIgnoreCase(group, ldapSearchString); } if (cmp) { // assign user to this group try { Group ldapGroup = groupService.findByName(context, dspaceGroupName); if (ldapGroup != null) { groupService.addMember(context, ldapGroup, context.getCurrentUser()); groupService.update(context, ldapGroup); } else { // The group does not exist log.warn( LogManager.getHeader( context, "ldap_assignGroupsBasedOnLdapDn", "Group defined in authentication-ldap.login.groupmap." + i + " does not exist :: " + dspaceGroupName)); } } catch (AuthorizeException ae) { log.debug( LogManager.getHeader( context, "assignGroupsBasedOnLdapDn could not authorize addition to group", dspaceGroupName)); } catch (SQLException e) { log.debug( LogManager.getHeader( context, "assignGroupsBasedOnLdapDn could not find group", dspaceGroupName)); } } groupMap = ConfigurationManager.getProperty("authentication-ldap", "login.groupmap." + ++i); } } }
/** * Initialize Crosswalk table from a properties file which itself is the value of the DSpace * configuration property "crosswalk.mods.properties.X", where "X" is the alias name of this * instance. Each instance may be configured with a separate mapping table. * * <p>The MODS crosswalk configuration properties follow the format: * * <p>{field-name} = {XML-fragment} | {XPath} * * <p>1. qualified DC field name is of the form {MDschema}.{element}.{qualifier} * * <p>e.g. dc.contributor.author * * <p>2. XML fragment is prototype of metadata element, with empty or "%s" placeholders for * value(s). NOTE: Leave the %s's in becaue it's much easier then to see if something is broken. * * <p>3. XPath expression listing point(s) in the above XML where the value is to be inserted. * Context is the element itself. * * <p>Example properties line: * * <p>dc.description.abstract = <mods:abstract>%s</mods:abstract> | text() */ private void initMap() throws CrosswalkInternalException { if (modsMap != null) return; String myAlias = getPluginInstanceName(); if (myAlias == null) { log.error( "Must use PluginManager to instantiate MODSDisseminationCrosswalk so the class knows its name."); return; } String cmPropName = CONFIG_PREFIX + myAlias; String propsFilename = ConfigurationManager.getProperty(cmPropName); if (propsFilename == null) { String msg = "MODS crosswalk missing " + "configuration file for crosswalk named \"" + myAlias + "\""; log.error(msg); throw new CrosswalkInternalException(msg); } else { String parent = ConfigurationManager.getProperty("dspace.dir") + File.separator + "config" + File.separator; File propsFile = new File(parent, propsFilename); Properties modsConfig = new Properties(); try { modsConfig.load(new FileInputStream(propsFile)); } catch (IOException e) { log.error( "Error opening or reading MODS properties file: " + propsFile.toString() + ": " + e.toString()); throw new CrosswalkInternalException( "MODS crosswalk cannot " + "open config file: " + e.toString()); } modsMap = new HashMap(); Enumeration pe = modsConfig.propertyNames(); while (pe.hasMoreElements()) { String qdc = (String) pe.nextElement(); String val = modsConfig.getProperty(qdc); String pair[] = val.split("\\s+\\|\\s+", 2); if (pair.length < 2) log.warn( "Illegal MODS mapping in " + propsFile.toString() + ", line = " + qdc + " = " + val); else { modsTriple trip = modsTriple.create(qdc, pair[0], pair[1]); if (trip != null) modsMap.put(qdc, trip); } } } }
/** * Send an alert to the designated "alert recipient" - that is, when a database error or internal * error occurs, this person is sent an e-mail with details. * * <p>The recipient is configured via the "alert.recipient" property in <code>dspace.cfg</code>. * If this property is omitted, no alerts are sent. * * <p>This method "swallows" any exception that might occur - it will just be logged. This is * because this method will usually be invoked as part of an error handling routine anyway. * * @param request the HTTP request leading to the error * @param exception the exception causing the error, or null */ public static void sendAlert(HttpServletRequest request, Exception exception) { String logInfo = UIUtil.getRequestLogInfo(request); Context c = (Context) request.getAttribute("dspace.context"); Locale locale = getSessionLocale(request); EPerson user = null; try { String recipient = ConfigurationManager.getProperty("alert.recipient"); if (recipient != null) { Email email = ConfigurationManager.getEmail(I18nUtil.getEmailFilename(locale, "internal_error")); email.addRecipient(recipient); email.addArgument(ConfigurationManager.getProperty("dspace.url")); email.addArgument(new Date()); email.addArgument(request.getSession().getId()); email.addArgument(logInfo); String stackTrace; if (exception != null) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); exception.printStackTrace(pw); pw.flush(); stackTrace = sw.toString(); } else { stackTrace = "No exception"; } email.addArgument(stackTrace); try { user = c.getCurrentUser(); } catch (Exception e) { log.warn("No context, the database might be down or the connection pool exhausted."); } if (user != null) { email.addArgument(user.getFullName() + " (" + user.getEmail() + ")"); } else { email.addArgument("Anonymous"); } email.addArgument(request.getRemoteAddr()); email.send(); } } catch (Exception e) { // Not much we can do here! log.warn("Unable to send email alert", e); } }
/** * Get an instance of the relevant Read Only DAO class, which will conform to the BrowseDAO * interface * * @param context the DSpace context * @return the relevant DAO * @throws BrowseException */ public static BrowseDAO getInstance(Context context) throws BrowseException { String className = ConfigurationManager.getProperty("browseDAO.class"); if (className == null) { // SOLR implementation is the default since DSpace 4.0 return new SolrBrowseDAO(context); } try { return (BrowseDAO) Class.forName(ConfigurationManager.getProperty("browseDAO.class")) .getConstructor(Context.class) .newInstance(context); } catch (Exception e) { throw new BrowseException("The configuration for browseDAO is invalid: " + className, e); } }
/** * Gets the default locale as defined in dspace.cfg If no default locale is defined, the Locale of * the JVM is used * * @return defaultLocale the default Locale for this DSpace instance */ public static Locale getDefaultLocale() { // First, try configured default locale Locale defaultLocale = null; if ((ConfigurationManager.getProperty("default.locale") != null) && (ConfigurationManager.getProperty("default.locale") != "")) { defaultLocale = makeLocale(ConfigurationManager.getProperty("default.locale")); } // Finally, get the Locale of the JVM if (defaultLocale == null) { defaultLocale = Locale.getDefault(); } return defaultLocale; }
/** * Get the recently submitted items for the given collection. * * @param collection The collection. */ @SuppressWarnings( "unchecked") // The cast from getLastSubmitted is correct, it dose infact return a list of // Items. private java.util.List<BrowseItem> getRecientlySubmittedIems(Collection collection) throws SQLException { if (recentSubmissionItems != null) return recentSubmissionItems; String source = ConfigurationManager.getProperty("recent.submissions.sort-option"); BrowserScope scope = new BrowserScope(context); scope.setCollection(collection); scope.setResultsPerPage(RECENT_SUBMISISONS); // FIXME Exception Handling try { scope.setBrowseIndex(BrowseIndex.getItemBrowseIndex()); for (SortOption so : SortOption.getSortOptions()) { if (so.getName().equals(source)) scope.setSortBy(so.getNumber()); } BrowseEngine be = new BrowseEngine(context); this.recentSubmissionItems = be.browse(scope).getResults(); } catch (BrowseException bex) { log.error("Caught BrowseException", bex); } return this.recentSubmissionItems; }
/** Add a page title and trail links. */ public void addPageMeta(PageMeta pageMeta) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException { DSpaceObject dso = HandleUtil.obtainHandle(objectModel); if (!(dso instanceof Collection)) return; Collection collection = (Collection) dso; // Set the page title pageMeta.addMetadata("title").addContent(collection.getMetadata("name")); pageMeta.addTrailLink(contextPath + "/", T_dspace_home); HandleUtil.buildHandleTrail(collection, pageMeta, contextPath); // Add RSS links if available String formats = ConfigurationManager.getProperty("webui.feed.formats"); if (formats != null) { for (String format : formats.split(",")) { // Remove the protocol number, i.e. just list 'rss' or' atom' String[] parts = format.split("_"); if (parts.length < 1) continue; String feedFormat = parts[0].trim() + "+xml"; String feedURL = contextPath + "/feed/" + collection.getHandle() + "/" + format.trim(); pageMeta.addMetadata("feed", feedFormat).addContent(feedURL); } } }
/** * Factory method for the default results pruner configuration using dspace.cfg * * @return a ResultsPruner that represent the default retention policy */ public static ResultsPruner getDefaultPruner(Context context) { try { return getPruner(context, ConfigurationManager.getProperties()); } catch (FileNotFoundException e) { throw new IllegalStateException("VeryExceptionalException - config file not there! ", e); } }
/* * Add authenticated users to the group defined in dspace.cfg by * the login.specialgroup key. */ @Override public List<Group> getSpecialGroups(Context context, HttpServletRequest request) { // Prevents anonymous users from being added to this group, and the second check // ensures they are LDAP users try { if (!context.getCurrentUser().getNetid().equals("")) { String groupName = ConfigurationManager.getProperty("authentication-ldap", "login.specialgroup"); if ((groupName != null) && (!groupName.trim().equals(""))) { Group ldapGroup = groupService.findByName(context, groupName); if (ldapGroup == null) { // Oops - the group isn't there. log.warn( LogManager.getHeader( context, "ldap_specialgroup", "Group defined in login.specialgroup does not exist")); return ListUtils.EMPTY_LIST; } else { return Arrays.asList(ldapGroup); } } } } catch (Exception npe) { // The user is not an LDAP user, so we don't need to worry about them } return ListUtils.EMPTY_LIST; }
private boolean isEmbargoed(Context context, Item item) throws Exception { // if an embargo field isn't configured, then the item can't be embargoed String liftDateField = ConfigurationManager.getProperty("embargo.field.lift"); if (liftDateField == null) { return false; } // if there is no embargo value, the item isn't embargoed DCValue[] embargoes = item.getMetadata(liftDateField); if (embargoes.length == 0) { return false; } // if the embargo date is in the past, then the item isn't embargoed try { DCDate embargoDate = EmbargoManager.getEmbargoTermsAsDate(context, item); if ((new Date()).getTime() > embargoDate.toDate().getTime()) { return false; } } catch (SQLException e) { throw new Exception(e); } catch (AuthorizeException e) { throw new Exception(e); } catch (IOException e) { throw new Exception(e); } return true; }
// returns recently changed items, checking for accessibility private Item[] getItems(Context context, DSpaceObject dso) throws IOException, SQLException { try { // new method of doing the browse: String idx = ConfigurationManager.getProperty("recent.submissions.sort-option"); if (idx == null) { throw new IOException( "There is no configuration supplied for: recent.submissions.sort-option"); } BrowseIndex bix = BrowseIndex.getItemBrowseIndex(); if (bix == null) { throw new IOException("There is no browse index with the name: " + idx); } BrowserScope scope = new BrowserScope(context); scope.setBrowseIndex(bix); if (dso != null) { scope.setBrowseContainer(dso); } for (SortOption so : SortOption.getSortOptions()) { if (so.getName().equals(idx)) { scope.setSortBy(so.getNumber()); } } scope.setOrder(SortOption.DESCENDING); scope.setResultsPerPage(itemCount); // gather & add items to the feed. BrowseEngine be = new BrowseEngine(context); BrowseInfo bi = be.browseMini(scope); Item[] results = bi.getItemResults(context); if (includeAll) { return results; } else { // Check to see if we can include this item // Group[] authorizedGroups = AuthorizeManager.getAuthorizedGroups(context, results[i], // Constants.READ); // boolean added = false; List<Item> items = new ArrayList<Item>(); for (Item result : results) { checkAccess: for (Group group : AuthorizeManager.getAuthorizedGroups(context, result, Constants.READ)) { if ((group.getID() == Group.ANONYMOUS_ID)) { items.add(result); break checkAccess; } } } return items.toArray(new Item[items.size()]); } } catch (SortException se) { log.error("caught exception: ", se); throw new IOException(se.getMessage(), se); } catch (BrowseException e) { log.error("caught exception: ", e); throw new IOException(e.getMessage(), e); } }
/** * Look up the id of a group authorized for one of the given roles. If no group is currently * authorized to perform this role then a new group will be created and assigned the role. * * @param context The current DSpace context. * @param collectionID The collection id. * @param roleName ADMIN, WF_STEP1, WF_STEP2, WF_STEP3, SUBMIT, DEFAULT_READ. * @return The id of the group associated with that particular role, or -1 if the role was not * found. */ public static int getCollectionRole(Context context, int collectionID, String roleName) throws SQLException, AuthorizeException, IOException, TransformerException, SAXException, WorkflowConfigurationException, ParserConfigurationException { Collection collection = Collection.find(context, collectionID); // Determine the group based upon wich role we are looking for. Group roleGroup = null; if (ROLE_ADMIN.equals(roleName)) { roleGroup = collection.getAdministrators(); if (roleGroup == null) { roleGroup = collection.createAdministrators(); } } else if (ROLE_SUBMIT.equals(roleName)) { roleGroup = collection.getSubmitters(); if (roleGroup == null) roleGroup = collection.createSubmitters(); } else { if (ConfigurationManager.getProperty("workflow", "workflow.framework") .equals("xmlworkflow")) { // Resolve our id to a role roleGroup = getXMLWorkflowRole(context, collectionID, roleName, collection, roleGroup); } else { roleGroup = getOriginalWorkflowRole(roleName, collection, roleGroup); } } // In case we needed to create a group, save our changes collection.update(); context.commit(); // If the role name was valid then role should be non null, if (roleGroup != null) return roleGroup.getID(); return -1; }
/** * Returns the total number of groups returned by a specific query, without the overhead of * creating the Group objects to store the results. * * @param context DSpace context * @param query The search string * @return the number of groups matching the query */ public static int searchResultCount(Context context, String query) throws SQLException { String params = "%" + query.toLowerCase() + "%"; String dbquery = "SELECT count(*) as gcount FROM epersongroup WHERE LOWER(name) LIKE LOWER(?) OR eperson_group_id = ? "; // When checking against the eperson-id, make sure the query can be made into a number Integer int_param; try { int_param = Integer.valueOf(query); } catch (NumberFormatException e) { int_param = Integer.valueOf(-1); } // Get all the epeople that match the query TableRow row = DatabaseManager.querySingle(context, dbquery, new Object[] {params, int_param}); // use getIntColumn for Oracle count data Long count; if ("oracle".equals(ConfigurationManager.getProperty("db.name"))) { count = Long.valueOf(row.getIntColumn("gcount")); } else // getLongColumn works for postgres { count = Long.valueOf(row.getLongColumn("gcount")); } return count.intValue(); }
static { try { Set<SortOption> newSortOptionsSet = new TreeSet<SortOption>( new Comparator<SortOption>() { @Override public int compare(SortOption sortOption, SortOption sortOption1) { return Integer.valueOf(sortOption.getNumber()) .compareTo(Integer.valueOf(sortOption1.getNumber())); } }); int idx = 1; String option; while (((option = ConfigurationManager.getProperty("webui.itemlist.sort-option." + idx))) != null) { SortOption so = new SortOption(idx, option); newSortOptionsSet.add(so); idx++; } SortOption.sortOptionsSet = newSortOptionsSet; } catch (SortException se) { log.fatal("Unable to load SortOptions", se); } }
private boolean allowedToMediate(Context context) { // get the configuration String mediatorCfg = ConfigurationManager.getProperty("swordv2-server", "on-behalf-of.update.mediators"); if (mediatorCfg == null) { // if there's no explicit list of mediators, then anyone can mediate return true; } // get the email and netid of the mediator EPerson eperson = context.getCurrentUser(); if (eperson == null) { return false; } String email = eperson.getEmail(); String netid = eperson.getNetid(); String[] mediators = mediatorCfg.split(","); for (String mediator : mediators) { String m = mediator.trim(); if (email != null && m.equals(email.trim())) { return true; } if (netid != null && m.equals(netid.trim())) { return true; } } return false; }
private static void loadSpiderIpAddresses() { if (table == null) { table = new IPTable(); String filePath = ConfigurationManager.getProperty("dspace.dir"); try { File spidersDir = new File(filePath, "config/spiders"); if (spidersDir.exists() && spidersDir.isDirectory()) { for (File file : spidersDir.listFiles()) { for (String ip : readIpAddresses(file)) { table.add(ip); } log.info("Loaded Spider IP file: " + file); } } else { log.info("No spider file loaded"); } } catch (Exception e) { log.error("Error Loading Spiders:" + e.getMessage(), e); } } }
/** * Get the recently submitted items for the given community or collection. * * @param scope The collection. */ protected DiscoverResult getQueryResponse(DSpaceObject scope) { Request request = ObjectModelHelper.getRequest(objectModel); if (queryResults != null) { return queryResults; } queryArgs = new DiscoverQuery(); // Make sure we add our default filters // queryArgs.addFilterQueries(SearchUtils.getDefaultFilters("browse")); queryArgs.setQuery( "search.resourcetype: " + Constants.ITEM + ((request.getParameter("query") != null && !"".equals(request.getParameter("query"))) ? " AND (" + request.getParameter("query") + ")" : "")); // queryArgs.setQuery("search.resourcetype:" + Constants.ITEM); queryArgs.setMaxResults(0); // TODO: change this ! queryArgs.setSortField( ConfigurationManager.getProperty("recent.submissions.sort-option"), DiscoverQuery.SORT_ORDER.asc); queryArgs.addFilterQueries(getParameterFacetQueries()); // Set the default limit to 11 // query.setFacetLimit(11); queryArgs.setFacetMinCount(1); // sort // TODO: why this kind of sorting ? Should the sort not be on how many times the value appears // like we do in the filter by sidebar ? // queryArgs.setFacetSort(config.getPropertyAsType("solr.browse.sort","lex")); // queryArgs.setFacet(true); int offset = RequestUtils.getIntParameter(request, OFFSET); if (offset == -1) { offset = 0; } queryArgs.setFacetOffset(offset); // We add +1 so we can use the extra one to make sure that we need to show the next page // queryArgs.setFacetLimit(DEFAULT_PAGE_SIZE + 1); // queryArgs.addFacetField(new DiscoverFacetField(request.getParameter(FACET_FIELD))); try { queryResults = searchService.search(context, scope, queryArgs); } catch (SearchServiceException e) { log.error(e.getMessage(), e); } return queryResults; }
// load the namespace and schema from config private void init() throws CrosswalkInternalException { if (namespaces != null || schemaLocation != null) return; String myAlias = getPluginInstanceName(); if (myAlias == null) { log.error( "Must use PluginManager to instantiate XSLTDisseminationCrosswalk so the class knows its name."); throw new CrosswalkInternalException( "Must use PluginManager to instantiate XSLTDisseminationCrosswalk so the class knows its name."); } // all configs for this plugin instance start with this: String prefix = CONFIG_PREFIX + DIRECTION + "." + myAlias + "."; // get the schema location string, should already be in the // right format for value of "schemaLocation" attribute. schemaLocation = ConfigurationManager.getProperty(prefix + "schemaLocation"); if (schemaLocation == null) log.warn("No schemaLocation for crosswalk=" + myAlias + ", key=" + prefix + "schemaLocation"); // sanity check: schemaLocation should have space. else if (schemaLocation.length() > 0 && schemaLocation.indexOf(" ") < 0) log.warn( "Possible INVALID schemaLocation (no space found) for crosswalk=" + myAlias + ", key=" + prefix + "schemaLocation" + "\n\tCorrect format is \"{namespace} {schema-URL}\""); // grovel for namespaces of the form: // crosswalk.diss.{PLUGIN_NAME}.namespace.{PREFIX} = {URI} String nsPrefix = prefix + "namespace."; Enumeration pe = ConfigurationManager.propertyNames(); List nsList = new ArrayList(); while (pe.hasMoreElements()) { String key = (String) pe.nextElement(); if (key.startsWith(nsPrefix)) nsList.add( Namespace.getNamespace( key.substring(nsPrefix.length()), ConfigurationManager.getProperty(key))); } namespaces = (Namespace[]) nsList.toArray(new Namespace[nsList.size()]); preferList = ConfigurationManager.getBooleanProperty(prefix + "preferList", false); }
/** * Return the canonical name for column. * * @param column The name of the column. * @return The canonical name of the column. */ static String canonicalize(String column) { if ("oracle".equals(ConfigurationManager.getProperty("db.name"))) { // oracle requires uppercase return column.toUpperCase(); } // postgres default lowercase return column.toLowerCase(); }
static { if ("oracle".equals(ConfigurationManager.getProperty("db.name"))) { isOracle = true; isPostgres = false; } else { isOracle = false; isPostgres = true; } }
// constructor does static init too.. public LCNameAuthority() { if (url == null) { url = ConfigurationManager.getProperty("lcname.url"); // sanity check if (url == null) throw new IllegalStateException("Missing DSpace configuration keys for LCName Query"); } }
static { List aliasList = new ArrayList(); Enumeration pe = ConfigurationManager.propertyNames(); while (pe.hasMoreElements()) { String key = (String) pe.nextElement(); if (key.startsWith(CONFIG_PREFIX)) aliasList.add(key.substring(CONFIG_PREFIX.length())); } aliases = (String[]) aliasList.toArray(new String[aliasList.size()]); }
/** * Create a new instance of the Default set of utils to use with the database. This represents the * most likely case with a database, in that it does not require the fields to be truncated. Other * databases, such as Oracle, require a set limit for their VARCHAR fields, and will therefore * have a slightly different implementation * * <p>Other database implementations should extend this class for typing and future proofing * purposes */ public BrowseDAOUtilsDefault() { // Default for all other databases is unlimited valueColumnMaxChars = 0; sortColumnMaxChars = 0; if (ConfigurationManager.getProperty("webui.browse.value_columns.max") != null) { valueColumnMaxChars = ConfigurationManager.getIntProperty("webui.browse.value_columns.max"); } if (ConfigurationManager.getProperty("webui.browse.sort_columns.max") != null) { sortColumnMaxChars = ConfigurationManager.getIntProperty("webui.browse.sort_columns.max"); } valueColumnOmissionMark = ConfigurationManager.getProperty("webui.browse.value_columns.omission_mark"); if (valueColumnOmissionMark == null) { valueColumnOmissionMark = "..."; } }
private boolean isFail(Context context, Item item) { String gradeField = ConfigurationManager.getProperty("studentweb", "grade.field"); DCValue[] dcvs = item.getMetadata(gradeField); for (DCValue dcv : dcvs) { if ("fail".equals(dcv.value.trim())) { return true; } } return false; }
/** * Construct a particular kind of DSpace application. * * @param kind what kind of application is this? (XMLUI, JSPUI, etc.) */ public AbstractDSpaceWebapp(String kind) { this.kind = kind; started = new Date(); url = ConfigurationManager.getProperty("dspace.url"); if (null == url) { throw new IllegalStateException("dspace.url is undefined"); } }