Changeset 1524 for MDService2
- Timestamp:
- 09/08/11 10:32:36 (13 years ago)
- Location:
- MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/CompRegistryProxyAction.java
r1512 r1524 127 127 if (_sourceStream == null) { 128 128 // Admin.notifyUser("CRPA.prepareSourceStream- profiles"); 129 setActionkey("profiles");130 setFormat("xmlresolved");129 //setActionkey("profiles"); 130 //setFormat("xmlresolved"); 131 131 __sourceStream = Cache.getCache().getFromCache(getRequestKey()); 132 132 if (__sourceStream == null) { … … 142 142 MDTransformer transformer = new MDTransformer(); 143 143 transformer.setSrcFile(getTargetRequest()); 144 transformer.setParams(createTransformerParams());144 //transformer.setParams(createTransformerParams()); 145 145 _sourceStream = transformer.transformXML(__sourceStream);//, getFullFormat(),null,null,null,null,null,null); 146 146 // Admin.notifyUser("CRPA.- elements"); 147 setActionkey("elements");148 setFormat("htmllist");147 //setActionkey("elements"); 148 //setFormat("htmllist"); 149 149 xcid = Cache.getCache().putInCache(getRequestKey(),_sourceStream); 150 150 // Admin.notifyUser("CRPA-putting in cache: " + getRequestKey()); … … 170 170 MDTransformer transformer = new MDTransformer(); 171 171 transformer.setSrcFile(getTargetRequest()); 172 transformer.setParams(MDTransformer.createParamsMap(getFullFormat()));172 //transformer.setParams(MDTransformer.createParamsMap(getFullFormat())); 173 173 _resultStream = transformer.transformXML(_sourceStream);//, getFullFormat()); 174 174 -
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/GenericAction.java
r1523 r1524 53 53 /** 54 54 * Properties to be filled by Struts with according request-parameters 55 */ 55 */ 56 56 private String actionkey = "generic"; 57 private String cache = Cache.SKIP;58 private String lang="en";59 57 private String q; 60 private String format="xml"; // default no transformation58 61 59 private String actionContentType; 62 60 private String userMsg; 63 61 private HttpServletRequest request; 64 62 private long duration = 0; 65 private String repository;66 63 private InputStream resultStream; 67 64 private InputStream sourceStream; 68 65 69 66 private Map<String,String[]> params; 70 71 // protected URL base_url ;72 67 73 68 private ProxyInterface target_proxy; … … 87 82 */ 88 83 public void setTargetProxy() { 89 }84 } 90 85 91 86 public Diagnostics getDiagnostics(){ … … 100 95 } 101 96 97 public String getQ() { 98 /* 99 if (q == null) { 100 return ""; 101 } else { 102 return q; 103 } 104 */ 105 return q; 106 } 107 108 public void setQ(String q) { 109 //if (q == null) q=""; 110 this.q = q; 111 } 112 113 public String getActionkey() { 114 return actionkey; 115 } 116 117 public void setActionkey(String actionKey) { 118 actionkey = actionKey; 119 } 120 121 public String getRecordPacking() { 122 return getParam("recordPacking"); 123 } 124 public String getFormat() { 125 return getParam("x-cmd-format"); 126 } 102 127 public String getCache() { 103 return cache; 104 } 105 106 public void setCache(String cache) { 107 this.cache = cache; 108 } 109 110 public String getFormat() { 111 return format; 112 } 113 114 public void setFormat(String format) { 115 this.format = format; 116 } 128 return getParam("x-cmd-cache"); 129 } 130 public String getRepository() { 131 return getParam("x-cmd-repository"); 132 } 133 public String getLang() { 134 return getParam("x-cmd-lang"); 135 } 136 public String getCollections() { 137 return getParam("x-cmd-collections"); 138 } 139 public String getColumns() { 140 return getParam("x-cmd-columns"); 141 } 142 public String getQuery() { 143 return getParam("query"); 144 } 145 public String getStartRecord() { 146 return getParam("startRecord"); 147 } 148 public String getMaximumRecords() { 149 return getParam("maximumRecords"); 150 } 151 public String getMaxdepth() { 152 return getParam("x-cmd-maxdepth"); 153 } 117 154 118 119 public String getQ() {120 if (q == null) {121 return "";122 } else {123 return q;124 }125 }126 127 public void setQ(String pq) {128 if (pq == null) pq="";129 /*130 if (q != null){131 if (q.trim().length() == 0){132 q = null;133 }134 }135 */136 this.q = pq;137 }138 139 140 public void setRepository(String repository) {141 this.repository = repository;142 }143 144 public String getRepository() {145 //default repository = 1 (set on init)146 return repository;147 }148 155 149 156 /** … … 152 159 */ 153 160 public String getActionContentType() { 154 if ( format.toLowerCase().startsWith("html")) {161 if (this.getFormat().toLowerCase().startsWith("html")) { 155 162 this.actionContentType = "text/html"; 156 163 //this.actionContentType = "application/xhtml+xml"; … … 165 172 this.actionContentType = actionContentType; 166 173 } 167 168 public String getActionkey() { 169 return actionkey; 170 } 171 172 public void setActionkey(String actionKey) { 173 actionkey = actionKey; 174 } 175 176 public String getLang() { 177 return lang; 178 } 179 180 public void setLang(String lang) { 181 this.lang = lang; 182 } 174 183 175 184 176 public String getFullFormat() { 185 return actionkey + "2" + format;177 return actionkey + "2" + getFormat(); 186 178 } 187 179 … … 246 238 * at the cost of circumventing the Struts-way. 247 239 */ 240 public void addParam(String key, String value){ 241 String[] sarr = new String[1]; 242 sarr[0] = value; 243 params.put(key, sarr); 244 } 245 246 /* 247 * sru params 248 * /* 249 * version 250 * operation 251 * query 252 * scanClause 253 * startRecord 254 * maximumRecords 255 * recordPacking 256 * recordSchema 257 * recordXPath 258 * resultSetTTL 259 * sortKeys 260 * stylesheet 261 * x-cmd-repository 262 * x-cmd-collections 263 * x-cmd-columns 264 * x-cmd-lang 265 * x-cmd-format 266 * x-cmd-cache 267 * x-cmd-maxdepth 268 */ 248 269 @SuppressWarnings("unchecked") 249 270 protected void loadParams() { 250 271 params = new HashMap(getServletRequest().getParameterMap()); 251 272 252 if (!getQ().equals("")) { 253 String[] sarr = new String[1]; 254 sarr[0] = getQ(); 255 params.put("q", sarr); 273 if (getQ() != null) { 274 addParam("q",getQ()); 256 275 } 257 if (!params.containsKey("repository")){ 258 String[] sarr = new String[1]; 259 sarr[0] = getRepository(); 260 params.put("repository", sarr); 261 } 262 String[] sarr2 = new String[1]; 263 sarr2[0] =getFullFormat(); 264 params.put("fullformat", sarr2); 265 } 266 276 277 // set defaults 278 if ( params.get("version") == null){ 279 addParam("version","1.2"); 280 } 281 if ( params.get("operation") == null){ 282 addParam("operation","searchRetrieve"); 283 } 284 if ( params.get("query") == null){ 285 addParam("query",getParam("q")); 286 } 287 if ( params.get("startRecord") == null){ 288 addParam("startRecord","1"); 289 } 290 if ( params.get("maximumRecords") == null){ 291 addParam("maximumRecords","50"); 292 } 293 if ( params.get("x-cmd-maxdepth") == null){ 294 addParam("x-cmd-maxdepth","2"); 295 } 296 if ( params.get("x-cmd-repository") == null){ 297 //addParam("x-cmd-repository","1"); 298 } 299 if ( params.get("x-cmd-cache") == null){ 300 addParam("x-cmd-cache",Cache.SKIP); 301 } 302 if ( params.get("x-cmd-lang") == null){ 303 addParam("x-cmd-lang","en"); 304 } 305 } 267 306 268 307 public Map<String,String[]> getParams() { … … 303 342 key +="//-" ; 304 343 } 305 /*if (getQ()!=null) {306 key += getQ () + "//-" ;344 if (getQuery()!=null) { 345 key += getQuery() + "//-" ; 307 346 } else { 308 347 key +="//-" ; 309 348 } 310 if (getCollection ()!=null) {311 key += getCollection () + "//-";349 if (getCollections()!=null) { 350 key += getCollections() + "//-"; 312 351 } else { 313 352 key +="//-" ; 314 353 } 315 if (getSquery()!=null) { 316 key += getSquery() + "//-" ; 317 } else { 318 key +="//-" ; 319 } 320 if (getStartItem()!=null) { 321 key += getStartItem() + "//-"; 354 if (this.getStartRecord()!=null) { 355 key += getStartRecord() + "//-"; 322 356 } 323 357 else{ 324 358 key +="//-" ; 325 359 } 326 if (getMaximum Items()!=null) {327 key += getMaximum Items() + "//-";360 if (getMaximumRecords()!=null) { 361 key += getMaximumRecords() + "//-"; 328 362 } 329 363 else{ … … 339 373 key +="//-" ; 340 374 } 341 */ 375 342 376 return key; 343 377 } … … 355 389 } 356 390 391 /* 357 392 private static final Map<String, String> xsl_map; 358 393 static { … … 386 421 return map; 387 422 } 388 /*423 389 424 public Map<String,String> createTransformerParams(){ 390 425 … … 505 540 // TODO: WHY?? 506 541 transformer.setSrcFile(getTargetProxy().getTargetRequest()); 507 transformer.setParams(createTransformerParams()); 542 //transformer.setParams(createTransformerParams()); 543 transformer.setParams(getParams()); 508 544 // here the transformation is invoked 509 545 resultStream = transformer.transformXML(sourceStream); -
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/GenericProxyAction.java
r1521 r1524 79 79 } 80 80 81 81 /* 82 82 public Diagnostics getDiagnostics(){ 83 83 return this.diagnostics; … … 105 105 } 106 106 } 107 */107 108 108 this.q = pq; 109 109 } … … 137 137 public String getColumns() { 138 138 String cols = columns; 139 /*if (columns == null){140 cols = "Id,Name,Title";141 }142 */143 139 return cols; 144 140 } … … 171 167 this.options = options; 172 168 } 173 169 */ 174 170 /** 175 171 * is used in struts.xml to dynamically set the mime-type of the result, depending on the format-parameter … … 343 339 public String getRequestKey() { 344 340 String key=""; 341 /* 345 342 if (getActionkey()!=null) { 346 343 key += getActionkey() + "//-" ; … … 384 381 key +="//-" ; 385 382 } 386 383 */ 387 384 return key; 388 385 } … … 494 491 // TODO: WHY?? 495 492 transformer.setSrcFile(getTargetRequest()); 496 transformer.setParams(createTransformerParams());493 //transformer.setParams(createTransformerParams()); 497 494 // here the transformation is invoked 498 495 resultStream = transformer.transformXML(sourceStream); -
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/GenericWorkspaceAction.java
r1512 r1524 175 175 transformer.setSrcFile(getURL()); 176 176 //InputStream tmp_s = MDTransformer.getMDTransformer().transformXML(sourceStream, "attr2elements"); 177 transformer.setParams(MDTransformer.createParamsMap(getFullFormat()));177 //transformer.setParams(MDTransformer.createParamsMap(getFullFormat())); 178 178 InputStream s = transformer.transformXML(sourceStream);//, getFullFormat()); 179 179 resultStream = getPart(s); -
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/RepoAction.java
r1523 r1524 91 91 public void setTargetProxy(){ 92 92 93 if (getRepository()==null) setRepository("clarin.at-mirror");93 //if (getRepository()==null) setRepository("clarin.at-mirror"); 94 94 95 95 switch (WorkspaceProfile.RepositoryType.toRepositoryType(WorkspaceProfile.getRepositoryType(getRepository()))) … … 109 109 110 110 } 111 111 /* 112 112 public String getSquery() { 113 113 return squery; … … 130 130 public String getColumns() { 131 131 String cols = columns; 132 /*if (columns == null){133 cols = "Id,Name,Title";134 }135 */136 132 return cols; 137 133 } … … 156 152 this.format = format; 157 153 } 158 */ 154 159 155 public String getOptions() { 160 156 return options; … … 199 195 this.sort = sort; 200 196 } 201 197 */ 202 198 203 199 /** … … 216 212 * @return key unambiguously encoding the request 217 213 */ 218 214 /* 219 215 public String getRequestKey() { 220 216 String key=""; … … 263 259 return key; 264 260 } 265 261 */ 266 262 /* 267 263 @Override -
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/SRUAction.java
r1521 r1524 42 42 * Properties to be filled by Struts with according request-parameters 43 43 */ 44 /* 44 45 private String q; 45 46 private String version; … … 58 59 private String x_cmd_collections; 59 60 private Set paramSet; 60 61 */ 61 62 62 63 private static int OP_SEARCHRETRIEVE = 1; … … 94 95 protected void initialize(){ 95 96 //repository = 1; 96 this.startRecord = 1;97 this.maximumRecords = 50;98 97 //this.startRecord = 1; 98 //this.maximumRecords = 50; 99 /* 99 100 if (getServletRequest() != null){ 100 101 this.setX_cmd_repository(getServletRequest().getParameter("x-cmd-repository")); 101 102 //this.setRepository(this.getX_cmd_repository()); 102 paramSet = getServletRequest().getParameterMap().entrySet();103 //paramSet = getServletRequest().getParameterMap().entrySet(); 103 104 } 105 */ 104 106 105 107 } 106 108 /* 107 109 public String getQ() { 108 110 return q; … … 226 228 } 227 229 228 230 */ 229 231 public String getDiagnosticStreamName() throws TransformerConfigurationException, UnsupportedEncodingException, ParserConfigurationException, TransformerException, TransformerFactoryConfigurationError{ 230 232 this.setResultStream(getDiagnostics().buildXMLStream()); 231 233 return "resultStream"; 232 234 } 235 233 236 /** 234 237 * primitive identification of the target-proxy … … 442 445 443 446 //TODO params 447 /* 444 448 if (paramSet == null){ 445 449 if (!(operation == null)){ … … 470 474 471 475 } 472 476 */ 473 477 return params; 474 478 } -
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/TermsProxyAction.java
r1512 r1524 138 138 this.setProxyKey("terms.dcr"); 139 139 MDTransformer transformer = new MDTransformer(); 140 transformer.setParams(createTransformerParams());140 //transformer.setParams(createTransformerParams()); 141 141 /* IMPORTANT! change the format for the second phase: 142 142 * (but preserve the original format for the third phase. */ 143 transformer.getParams().put("format","terms2extract");143 //transformer.getParams().put("format","terms2extract"); 144 144 145 145 Admin.notifyUser("TPA.getSourceStream.transformer.effectiveTranskey: " + transformer.getTranskey() + ", for Termset:" + getTSAttr("name") + '#' + getTSAttr("id")); -
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/VirtualCollectionProxyAction.java
r1512 r1524 38 38 } 39 39 */ 40 @Override40 //@Override 41 41 protected void initialize(){ 42 setFormat("VC");42 //setFormat("VC"); 43 43 } 44 44 … … 57 57 return uri; 58 58 } 59 59 /* 60 60 @Override 61 61 public HashMap<String,String> createTransformerParams(){ … … 73 73 74 74 } 75 */ 75 76 public String publish() throws Exception { 76 77 … … 80 81 //xslt transform to request data 81 82 MDTransformer transformer = new MDTransformer(); 82 transformer.setSrcFile(getTargetRequest()); 83 transformer.setParams(createTransformerParams()); 83 transformer.setSrcFile(this.getTargetProxy().getTargetRequest()); 84 transformer.setParams(getParams()); 85 //transformer.setParams(createTransformerParams()); 84 86 InputStream requestStream = transformer.transformXML(is); 85 87 -
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/WorkspaceAction.java
r1512 r1524 59 59 * 60 60 */ 61 public class WorkspaceAction extends Generic ProxyAction61 public class WorkspaceAction extends GenericAction 62 62 //implements ServletRequestAware 63 63 { … … 199 199 200 200 201 @Override201 //@Override 202 202 public URL getBaseURL() { 203 203 File file=new File(getPath()); … … 208 208 } catch (MalformedURLException e){ 209 209 log.error("getBaseURL: JSON exception has been caught;\n getPath=" + getPath() ); 210 Diagnostics().Add(Diagnostic.SYSTEM_ERROR, "WorkspaceAction.getBaseURL()", "JSON exception has been caught;\n getPath=" + getPath() );210 getDiagnostics().Add(Diagnostic.SYSTEM_ERROR, "WorkspaceAction.getBaseURL()", "JSON exception has been caught;\n getPath=" + getPath() ); 211 211 } 212 212 … … 505 505 else { 506 506 // edit existing query 507 NodeList wsnodelist = (NodeList) get Query();507 NodeList wsnodelist = (NodeList) getWorkspaceQuery(); 508 508 // remove 509 509 //childeNode … … 542 542 else { 543 543 // edit existing query 544 NodeList wsnodelist = (NodeList) get Query();544 NodeList wsnodelist = (NodeList) getWorkspaceQuery(); 545 545 // remove 546 546 //childeNode … … 827 827 } 828 828 829 public Object get Query() throws XPathExpressionException{829 public Object getWorkspaceQuery() throws XPathExpressionException{ 830 830 831 831 XPathFactory factory = XPathFactory.newInstance(); … … 980 980 MDTransformer transformer = new MDTransformer(); 981 981 transformer.setSrcFile(getURL()); 982 transformer.setParams(MDTransformer.createParamsMap(getFullFormat())); 982 transformer.setParams(getParams()); 983 //transformer.setParams(MDTransformer.createParamsMap(getFullFormat())); 983 984 setResultStream(transformer.transformXML(is));//, getFullFormat())); 984 985 //setSessionData(getResultStream()); -
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/internal/MDTransformer.java
r1521 r1524 53 53 54 54 private URL srcFile ; 55 private Map<String, String > params;55 private Map<String, String[]> params; 56 56 57 57 // don't use singleton!! Bad things happen … … 78 78 * @return 79 79 */ 80 public void setParams(Map<String, String > map){80 public void setParams(Map<String, String[]> map){ 81 81 this.params = map; 82 82 } 83 83 84 84 85 public Map<String,String > getParams(){85 public Map<String,String[]> getParams(){ 86 86 return this.params; 87 87 } … … 131 131 132 132 public String getTranskey(){ 133 return params.get(" format");133 return params.get("x-cmd-format")[0]; 134 134 } 135 135 … … 141 141 public void SetTransformerParameters(Transformer transformer){ 142 142 143 Set<Entry<String, String >> set = params.entrySet();144 Iterator<Entry<String, String >> i = set.iterator();143 Set<Entry<String, String[]>> set = params.entrySet(); 144 Iterator<Entry<String, String[]>> i = set.iterator(); 145 145 146 146 while(i.hasNext()){ 147 Map.Entry<String,String > e = (Map.Entry<String,String>)i.next();148 transformer.setParameter((String)e.getKey(), (String)e.getValue() );147 Map.Entry<String,String[]> e = (Map.Entry<String,String[]>)i.next(); 148 transformer.setParameter((String)e.getKey(), (String)e.getValue()[0]); 149 149 } 150 150 } … … 322 322 } 323 323 324 public static HashMap<String,String> createParamsMap(String transkey){ 325 HashMap<String,String> hm = new HashMap<String,String>(); 326 327 if (transkey != null){ 328 hm.put("format", transkey); 324 public static HashMap<String,String[]> createParamsMap(String key){ 325 HashMap<String,String[]> hm = new HashMap<String,String[]>(); 326 327 if (key != null){ 328 String[] arrkey = new String[1]; 329 arrkey[0] = key; 330 hm.put("x-cmd-format", arrkey); 329 331 } 330 332 return hm; 331 333 } 334 332 335 }
Note: See TracChangeset
for help on using the changeset viewer.