- Timestamp:
- 07/12/10 12:46:30 (14 years ago)
- Location:
- MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/Cache.java
r521 r582 81 81 InputStream instream; 82 82 try { 83 instream = new FileInputStream(f); 83 instream = new FileInputStream(f); 84 84 85 return instream; 85 86 } catch (FileNotFoundException e) { -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/CompRegistryProxyAction.java
r519 r582 1 package eu.clarin.cmdi.mdservice.action;1 package eu.clarin.cmdi.mdservice.action; 2 2 3 import java.io.File; 4 import java.io.FileOutputStream; 3 5 import java.io.IOException; 4 6 import java.io.InputStream; 7 import java.io.OutputStream; 5 8 import java.net.MalformedURLException; 6 9 import java.net.URL; … … 36 39 public String getFullFormat() { 37 40 if (compid==null || compid.equals("")) { 38 return "complist2" + getFormat(); 41 if (getActionkey().equals("elements")){ 42 return "terms2" + getFormat(); 43 } else { 44 return "complist2" + getFormat(); 45 } 39 46 } else { 40 47 return "comp2" + getFormat(); … … 60 67 } 61 68 62 69 70 @SuppressWarnings("deprecation") 71 @Override 72 public void prepare() throws Exception { 73 74 Admin.notifyUser("CRPA.prepare"); 75 if (!getActionkey().equals("elements")) { 76 super.prepare(); 77 } else { 78 Admin.notifyUser("CRPA.prepareSourceStream - elements"); 79 String xcid; 80 InputStream _sourceStream; 81 InputStream __sourceStream; 82 InputStream _resultStream; 83 84 _sourceStream = Cache.getCache().getFromCache(getRequestKey()); 85 if (_sourceStream == null) { 86 Admin.notifyUser("CRPA.prepareSourceStream- profiles"); 87 setActionkey("profiles"); 88 setFormat("xmlresolved"); 89 __sourceStream = Cache.getCache().getFromCache(getRequestKey()); 90 if (__sourceStream == null) { 91 __sourceStream = getSourceStream(); 92 xcid = Cache.getCache().putInCache(getRequestKey(),__sourceStream); 93 Admin.notifyUser("CRPA-putting in cache: " + getRequestKey()); 94 __sourceStream = Cache.getCache().getFromCache(getRequestKey()); 95 } else{ 96 Admin.notifyUser("CRPA-reading from cache: " + getRequestKey()); 97 } 98 Admin.notifyUser("CCCRPA." + getTargetRequest()); 99 Admin.notifyUser("CCCRPA." + getFullFormat()); 100 MDTransformer.getMDTransformer().setSrcFile(getTargetRequest()); 101 _sourceStream = MDTransformer.getMDTransformer().transformXML(__sourceStream, getFullFormat()); 102 Admin.notifyUser("CRPA.- elements"); 103 setActionkey("elements"); 104 setFormat("htmllist"); 105 xcid = Cache.getCache().putInCache(getRequestKey(),_sourceStream); 106 Admin.notifyUser("CRPA-putting in cache: " + getRequestKey()); 107 _sourceStream = Cache.getCache().getFromCache(getRequestKey()); 108 } else { 109 Admin.notifyUser("CRPA-reading from cache: " + getRequestKey()); 110 } 111 /* 112 File file=new File(Cache.getCache().formPath(getRequestKey())); 113 Admin.notifyUser("File-absolutePath " + file.getAbsolutePath()); 114 URL url = null; 115 try{ 116 url = file.toURL(); 117 Admin.notifyUser("URL-tostring " + url.toString()); 118 } catch (MalformedURLException me){ 119 } 120 */ 121 122 MDTransformer.getMDTransformer().setSrcFile(getTargetRequest()); 123 _resultStream = MDTransformer.getMDTransformer().transformXML(_sourceStream, getFullFormat()); 124 125 setSourceStream(_sourceStream); 126 setResultStream(_resultStream); 127 128 if (getFormat().equals("txt")) { 129 File f=new File(Cache.getCache().formPath("terms_autocomplete.txt")); 130 OutputStream out=new FileOutputStream(f); 131 byte buf[]=new byte[1024]; 132 int len; 133 while((len=getResultStream().read(buf))>0) 134 out.write(buf,0,len); 135 out.close(); 136 Admin.notifyUser("terms_autocomplete.txt"); 137 } 138 139 140 } 141 142 } 143 144 63 145 /** 64 146 * uses base_url and (optionally) compid to form a url -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/GenericProxyAction.java
r535 r582 106 106 return resultStream; 107 107 } 108 108 public void setResultStream(InputStream _resultStream){ 109 resultStream = _resultStream; 110 } 111 public void setSourceStream(InputStream _sourceStream){ 112 sourceStream = _sourceStream; 113 } 114 109 115 /* 110 116 public InputStream getSourceStream() throws IOException { … … 150 156 } 151 157 158 152 159 public void prepare() throws Exception { 153 160 … … 156 163 157 164 // Caching 158 // does not work yet see Cache.java for details 159 160 String xcid; 165 String xcid; 166 Admin.notifyUser("GPA.prepareSourceStream"); 167 sourceStream = Cache.getCache().getFromCache(getRequestKey()); 168 if (sourceStream == null) { 169 //sourceStream = getTargetRequest().openStream(); 170 sourceStream = getSourceStream(); 171 xcid = Cache.getCache().putInCache(getRequestKey(),sourceStream); 172 Admin.notifyUser("putting in cache: " + getRequestKey()); 161 173 sourceStream = Cache.getCache().getFromCache(getRequestKey()); 162 if (sourceStream == null) { 163 //sourceStream = getTargetRequest().openStream(); 164 sourceStream = getSourceStream(); 165 xcid = Cache.getCache().putInCache(getRequestKey(),sourceStream); 166 Admin.notifyUser("putting in cache: " + getRequestKey()); 167 sourceStream = Cache.getCache().getFromCache(getRequestKey()); 168 } else { 169 Admin.notifyUser("reading from cache: " + getRequestKey()); 170 } 171 172 173 174 } else { 175 Admin.notifyUser("reading from cache: " + getRequestKey()); 176 } 177 174 178 if (format.equals("xml")) { 175 179 resultStream = sourceStream; -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/MDTransformer.java
r501 r582 114 114 Transformer transformer = tfactory.newTransformer( 115 115 getXSLStreamSource(transkey)); 116 117 transformer.setParameter("format", transkey); 118 119 if (srcFile!=null) { 116 120 117 transformer.setParameter("format", transkey);118 119 if (srcFile!=null) {120 121 File f = new File(srcFile.getPath()); 121 122 122 123 //Admin.notifyUser("src:" + srcFile.getFile()); 123 124 //Admin.notifyUser("fpath:" + f.getAbsolutePath()); … … 138 139 StreamSource src =new StreamSource(); 139 140 src.setInputStream(in); 140 141 141 // Transform the source XML to out-stream 142 142 transformer.transform(src, stream );
Note: See TracChangeset
for help on using the changeset viewer.