Changeset 676 for MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice
- Timestamp:
- 09/08/10 10:27:10 (14 years ago)
- Location:
- MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/Cache.java
r656 r676 57 57 private static Document cacheindex_doc; 58 58 59 59 60 public Cache () { 60 61 cachepath = Admin.getConfig().getProperty("cache.path"); … … 145 146 File f = new File (formPath(key_info)); 146 147 Admin.notifyUser("CACHE.getFromCache:"+key_info); 148 147 149 148 150 if (f.exists()) { // read from file to InputStream; -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/CollectionProxyAction.java
r627 r676 3 3 import java.io.IOException; 4 4 import java.net.URL; 5 6 import net.sf.json.JSONObject; 7 import net.sf.json.xml.XMLSerializer; 5 8 6 9 /** … … 26 29 27 30 public URL getTargetRequest() throws IOException { 28 31 29 32 URL targetURL = null; 30 33 //targetURL =new URL( getBaseURL(), getActionkey()); -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/GenericWorkspaceAction.java
r659 r676 2 2 3 3 import java.io.BufferedInputStream; 4 import java.io.ByteArrayInputStream; 4 5 import java.io.File; 5 6 import java.io.FileInputStream; … … 10 11 11 12 import javax.servlet.http.HttpServletRequest; 13 import javax.xml.transform.TransformerException; 14 15 import net.sf.json.JSON; 16 import net.sf.json.JSONSerializer; 17 import net.sf.json.xml.XMLSerializer; 18 19 import org.apache.commons.io.IOUtils; 12 20 import org.apache.struts2.interceptor.ServletRequestAware; 13 21 … … 102 110 sourceStream = _sourceStream; 103 111 } 104 112 113 105 114 public URL getBaseURL() { 106 115 File file=new File(getPath()); … … 143 152 } 144 153 154 145 155 public String getPath() { 146 156 String targetPath = getBasePath() + getWorkspaceProfile(); … … 170 180 // set srcFile (for MDTransformer to pass to xsl-scripts) 171 181 MDTransformer.getMDTransformer().setSrcFile(getURL()); 182 //InputStream tmp_s = MDTransformer.getMDTransformer().transformXML(sourceStream, "attr2elements"); 172 183 InputStream s = MDTransformer.getMDTransformer().transformXML(sourceStream, getFullFormat()); 173 184 resultStream = getPart(s); … … 190 201 } 191 202 192 public void save() throws IOException { 193 sourceStream = getSourceStream(); 194 } 195 203 196 204 197 205 } -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/QueryWorkspaceAction.java
r660 r676 50 50 return proxy_key; 51 51 } 52 /* 53 @Override 54 public InputStream getSourceStream() throws IOException { 55 InputStream stream = null; 56 57 //query part of the stream 58 Document document; 59 DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); 60 DocumentBuilder docBuilder; 61 try { 62 docBuilder = docFactory.newDocumentBuilder(); 63 try { 64 document = docBuilder.parse(getPath()); 65 } catch (SAXException e) { 66 // TODO Auto-generated catch block 67 68 e.printStackTrace(); 69 } 70 } catch (ParserConfigurationException e) { 71 // TODO Auto-generated catch block 72 e.printStackTrace(); 73 } 74 75 76 77 Transformer transformer; 78 79 try { 80 transformer = TransformerFactory.newInstance().newTransformer(); 81 transformer.setOutputProperty(OutputKeys.INDENT, "yes"); 82 83 //initialize StreamResult with File object to save to file 84 StreamResult result = new StreamResult(new StringWriter()); 85 DOMSource source = new DOMSource(document); 86 try { 87 transformer.transform(source, result); 88 } catch (TransformerException e1) { 89 // TODO Auto-generated catch block 90 e1.printStackTrace(); 91 } 92 93 String xmlString = result.getWriter().toString(); 94 Admin.notifyUser("writeCacheCounter:" + xmlString); 95 96 97 stream = new ByteArrayInputStream(xmlString.getBytes("UTF-8")); 98 } catch (TransformerConfigurationException e) { 99 // TODO Auto-generated catch block 100 e.printStackTrace(); 101 } catch (TransformerFactoryConfigurationError e) { 102 // TODO Auto-generated catch block 103 e.printStackTrace(); 104 } 105 106 107 return stream; 108 } 109 */ 110 /* 111 public InputStream getPart(InputStream stream){ 112 String jsonTxt; 113 try { 114 jsonTxt = IOUtils.toString( stream ); 115 Admin.notifyUser(jsonTxt); 116 117 try{ 118 JSONObject json = (JSONObject) JSONSerializer.toJSON( jsonTxt ); 119 120 Admin.notifyUser("1"); 121 //TODO find tho node 122 JSONObject jsonquery = json.getJSONObject("Query"); 123 Admin.notifyUser("2"); 124 stream = new ByteArrayInputStream( jsonquery.toString().getBytes() ); 125 Admin.notifyUser("3"); 126 Admin.notifyUser(jsonquery.toString()); 127 } catch (Exception e) { 128 // TODO Auto-generated catch block 129 e.printStackTrace(); 130 Admin.notifyUser("error:" + e.getMessage()); 131 } 132 } catch (IOException e) { 133 Admin.notifyUser("error2:" + e.getMessage()); 134 } 135 136 137 return stream; 138 } 139 */ 140 52 141 53 } -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/model/Query.java
r656 r676 84 84 85 85 public Query(String queryString, String type) { 86 86 87 this.type =type; 87 88 setQueryString(queryString); … … 116 117 query_string = queryString; 117 118 if (type.equals(RECORDSET)) { 119 120 118 121 parse(); 119 122 //preprocess(); … … 200 203 e.printStackTrace(); 201 204 } 205 206 202 207 return query_cql; 203 208 }
Note: See TracChangeset
for help on using the changeset viewer.