/** * Extract <set> XML string from setItem object * * @param setItem individual set instance in native format * @return an XML String containing the XML <set> content */ public String getSetXML(String setSpec) throws IllegalArgumentException { String setName = "Metadata originating from " + setSpec; StringBuffer sb = new StringBuffer(); sb.append("<set>"); sb.append("<setSpec>"); sb.append(OAIUtil.xmlEncode(setSpec)); sb.append("</setSpec>"); sb.append("<setName>"); sb.append(OAIUtil.xmlEncode(setName)); sb.append("</setName>"); sb.append("</set>"); return sb.toString(); }
private Document getNativeRecord(String path) { Document nativeRecord = null; // HashMap recordMap = null; if (datestampMap.containsKey(path)) { // recordMap = new HashMap(); // File file = localIdentifier2File(path); try { InputStream is = context.getResourceAsStream(path); // FileInputStream fis = new FileInputStream(file); nativeRecord = OAIUtil.parse(is); // Node node = XPathAPI.selectSingleNode(doc, "/record/header"); // String header = OAIUtil.toString(node); // recordMap.put("headerNode", node); // FileInputStream fis = new FileInputStream(file); // BufferedInputStream bis = new BufferedInputStream(fis); // byte[] buffer = new byte[(int)file.length()]; // bis.read(buffer, 0, (int)file.length()); // recordMap.put("recordBytes", buffer); // bis.close(); // fis.close(); // return recordMap; } catch (Exception e) { e.printStackTrace(); return null; } } return nativeRecord; }
/** * Extract <set> XML string from setItem object * * @param setItem individual set instance in native format * @return an XML String containing the XML <set> content */ public String getSetXMLRepository(String key, String setSpec) throws IllegalArgumentException { String setName = "Metadata originating from " + setSpec; String setDescription = "RepositoryIdentifier is " + key; StringBuffer sb = new StringBuffer(); sb.append("<set>"); sb.append("<setSpec>"); sb.append(OAIUtil.xmlEncode(setSpec)); sb.append("</setSpec>"); sb.append("<setName>"); sb.append(OAIUtil.xmlEncode(setName)); sb.append("</setName>"); if (setDescription != null) { sb.append("<setDescription>"); sb.append(getSetDCDescription(OAIUtil.xmlEncode(setDescription))); sb.append("</setDescription>"); } sb.append("</set>"); return sb.toString(); }
/** * Extract <set> XML string from setItem object * * @param setItem individual set instance in native format * @return an XML String containing the XML <set> content */ public String getSetXML(Map<String, Object> setItem) throws IllegalArgumentException { String setSpec = getSetSpec(setItem); String setName = getSetName(setItem); String setDescription = getSetDescription(setItem); StringBuilder sb = new StringBuilder(); sb.append("<set>"); sb.append("<setSpec>"); sb.append(OAIUtil.xmlEncode(setSpec)); sb.append("</setSpec>"); sb.append("<setName>"); sb.append(OAIUtil.xmlEncode(setName)); sb.append("</setName>"); if (setDescription != null) { sb.append("<setDescription>"); sb.append(OAIUtil.xmlEncode(setDescription)); sb.append("</setDescription>"); } sb.append("</set>"); return sb.toString(); }
private static ArrayList getSets(Properties properties) { InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("sets.properties"); Properties setProps = new Properties(); try { setProps.load(is); } catch (Exception e) { e.printStackTrace(); } TreeMap treeMap = new TreeMap(); Enumeration propNames = setProps.propertyNames(); while (propNames.hasMoreElements()) { String propertyName = (String) propNames.nextElement(); String s = new StringBuffer("<set><setSpec>") .append(OAIUtil.xmlEncode(propertyName)) .append("</setSpec><setName>") .append(OAIUtil.xmlEncode((String) setProps.get(propertyName))) .append("</setName></set>") .toString(); treeMap.put(propertyName, s); } return new ArrayList(treeMap.values()); }