Changeset 1852
- Timestamp:
- 04/04/12 08:38:32 (12 years ago)
- Location:
- MDService2/branches/MDService_simple3
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
MDService2/branches/MDService_simple3/WebContent/scripts/mdservice_ui_load.js
r1681 r1852 56 56 57 57 // server profile first - options needed 58 jQuery.getJSON("/MDService2/workspaceprofile/ json/server",function(sdata){58 jQuery.getJSON("/MDService2/workspaceprofile/server?format=json",function(sdata){ 59 59 //notifyUser(sdata['WorkspaceProfile'],'debug'); 60 60 var json = preprocessJSON(sdata); … … 70 70 71 71 // USER WORKSPACEPROFILE 72 jQuery.getJSON("/MDService2/workspaceprofile/ json/user",function(data){72 jQuery.getJSON("/MDService2/workspaceprofile/user?format=json",function(data){ 73 73 notifyUser(data['WorkspaceProfile'],'debug'); 74 74 workspace.user_json = preprocessJSON(data); -
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/FCSAction.java
r1835 r1852 51 51 * Properties to be filled by Struts with according request-parameters 52 52 */ 53 /* 54 private String q; 55 private String version; 56 private String operation; 57 private String query; 58 private String scanClause; 59 private int startRecord; 60 private int maximumRecords; 61 private String recordPacking; 62 private String recordSchema; 63 private String recordXPath; 64 private int resultSetTTL; 65 private String sortKeys; 66 private String stylesheet; 67 private String x_cmd_repository; 68 private String x_cmd_collections; 69 private Set paramSet; 70 */ 53 71 54 private String x_content; 72 55 private Map<String,String[]> fcsparams; … … 78 61 79 62 //TODO cache after analysis ? 63 /* 80 64 @Override 81 65 public String getCache() { 82 66 return Cache.SKIP; 83 67 } 84 68 */ 85 69 86 70 @Override … … 180 164 } 181 165 if (params.get("cache") == null){ 182 addParam("cache",Cache. SKIP);166 addParam("cache",Cache.USE); 183 167 } 184 168 -
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/GenericAction.java
r1832 r1852 82 82 } 83 83 84 public String getOperation() { 85 return getParam("operation"); 86 } 87 84 88 /** 85 89 * Empty implementation, subclasses have to decide themselves, which proxy to take. … … 464 468 */ 465 469 466 public String getRequestKey() { 467 String key=""; 468 if (getActionkey()!=null) { 469 key += getActionkey() + "//-" ; 470 }else { 471 key +="//-" ; 472 } 473 if (getQuery()!=null) { 474 key += getQuery() + "//-" ; 475 } else { 476 key +="//-" ; 477 } 478 if (getCollections()!=null) { 479 key += getCollections() + "//-"; 480 } else { 481 key +="//-" ; 482 } 483 if (this.getStartRecord()!=null) { 484 key += getStartRecord() + "//-"; 485 } 486 else{ 487 key +="//-" ; 488 } 489 if (getMaximumRecords()!=null) { 490 key += getMaximumRecords() + "//-"; 491 } 492 else{ 493 key +="//-" ; 494 } 495 496 key += getRepository() + "//-"; 497 key += getMaxdepth() + "//-"; 498 499 if (getLang()!=null) { 500 key += getLang() + "//-"; 501 }else{ 502 key +="//-" ; 503 } 504 505 return key; 506 } 470 public String getRequestKey() { 471 String key=""; 472 if (getActionkey()!=null) { 473 key += getActionkey() + "//-" ; 474 }else { 475 key +="//-" ; 476 } 477 if (!getQuery().equals("")) { 478 key += getQuery() + "//-" ; 479 } else { 480 key += getScanClause() + "//-" ; 481 } 482 key += getOperation() + "//-"; 483 484 key += getCollections() + "//-"; 485 486 key += getStartRecord() + "//-"; 487 488 key += getMaximumRecords() + "//-"; 489 490 key += getRepository() + "//-"; 491 key += getMaxdepth() + "//-"; 492 493 key += getLang() + "//-"; 494 495 return key; 496 } 507 497 508 498 -
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/SRUAction.java
r1832 r1852 41 41 * Properties to be filled by Struts with according request-parameters 42 42 */ 43 /*44 private String q;45 private String version;46 private String operation;47 private String query;48 private String scanClause;49 private int startRecord;50 private int maximumRecords;51 private String recordPacking;52 private String recordSchema;53 private String recordXPath;54 private int resultSetTTL;55 private String sortKeys;56 private String stylesheet;57 private String x_cmd_repository;58 private String x_cmd_collections;59 private Set paramSet;60 */61 43 62 44 private static int OP_SEARCHRETRIEVE = 1; … … 66 48 67 49 //TODO cache after analysis ? 50 /* 68 51 @Override 69 52 public String getCache() { 70 53 return Cache.SKIP; 71 54 } 55 */ 72 56 73 57 @Override … … 90 74 } 91 75 76 /* 92 77 public String getOperation() { 93 78 if (getParams().get("operation") == null){ … … 96 81 return getParam("operation"); 97 82 } 98 83 */ 99 84 protected final static HashMap<String,Integer> operation_code = new HashMap<String,Integer>(); 100 85 static … … 114 99 return ""; 115 100 } 116 /*117 @Override118 protected void setDefaultParams() {119 // set defaults120 /* if ( params.get("version") == null){121 addParam("version","1.2");122 }123 if ( params.get("operation") == null){124 addParam("operation","searchRetrieve");125 }126 //q=query127 if (getQ() != null) {128 addParam("q",getQ());129 addParam("query",getQ());130 } else {131 addParam("q",this.getParam("query"));132 }133 134 if ( params.get("startRecord") == null){135 addParam("startRecord","1");136 }137 if ( params.get("maximumRecords") == null){138 addParam("maximumRecords","50");139 }140 141 if ( params.get("x-cmd-maxdepth") == null){142 if (params.get("maxdepth") == null){143 addParam("maxdepth","2");144 }145 } else {146 addParam("maxdepth",params.get("x-cmd-maxdepth")[0]);147 }148 149 if ( params.get("x-cmd-repository") == null){150 if (params.get("repository") == null){151 addParam("repository",WorkspaceProfile.getRepositoryByIndex(0));152 }153 } else {154 addParam("repository",params.get("x-cmd-repository")[0]);155 }156 157 if ( params.get("x-cmd-cache") == null){158 if (params.get("cache") == null){159 addParam("cache",Cache.SKIP);160 }161 } else {162 addParam("cache",params.get("x-cmd-cache")[0]);163 }164 165 if ( params.get("x-cmd-lang") == null){166 if (params.get("lang") == null){167 addParam("lang","en");168 }169 } else {170 addParam("lang",params.get("x-cmd-lang")[0]);171 }172 173 if ( params.get("x-cmd-format") == null){174 if (params.get("format") == null){175 if (this.format == null) {176 addParam("format","xml");177 } else if (this.format.equals("")){178 addParam("format","xml");179 } else {180 addParam("format",this.format);181 }182 }183 } else {184 addParam("format",params.get("x-cmd-format")[0]);185 }186 187 addParam("fullformat",getFullFormat());188 189 }190 */191 /*192 public void prepareOperation() throws UnsupportedEncodingException{193 194 mdrepoproxyaction = new MDRepoProxyAction();195 mdrepoproxyaction.setDiagnostics(diagnostics);196 mdrepoproxyaction.setActionkey(hash_operations.get(this.getOperation()));197 198 // set the SRU extern property in proxyaction199 if (this.getX_cmd_repository() != null ) {200 mdrepoproxyaction.setRepository(this.getX_cmd_repository());201 //TODO\202 if (mdrepoproxyaction.getBaseURI() == null) this.Diagnostics().Add(Diagnostic.UNSUPPORTED_PARAMETERVALUE, "Unknown repository." + getX_cmd_repository());203 }204 205 if (operation.equals("searchRetrieve")){206 207 //query208 mdrepoproxyaction.setSquery("");209 if (this.query == null) {210 this.Diagnostics().Add(Diagnostic.MANDATORY_NOTSUPPLIED, "query");211 //return -1;212 }213 mdrepoproxyaction.setQ(getQuery());214 mdrepoproxyaction.setFormat("xml");215 216 if ((this.startRecord < 0 ) ||((getServletRequest().getParameter("startRecord") != null)&&(getServletRequest().getParameter("startRecord").equals("0")))) {217 this.Diagnostics().Add(new Diagnostic(Diagnostic.UNSUPPORTED_PARAMETERVALUE, "startRecord must by grater than 0."));//,Diagnostic.NONFATALNONSURORGATE));218 //mdrepoproxyaction.setStartItem("1");219 } else {220 mdrepoproxyaction.setStartItem(Integer.toString(getStartRecord()));221 }222 223 if ((this.maximumRecords < 0 ) ||((getServletRequest().getParameter("maximumRecords") != null) && (getServletRequest().getParameter("maximumRecords").equals("0")))){224 this.Diagnostics().Add(new Diagnostic(Diagnostic.UNSUPPORTED_PARAMETERVALUE,225 "maximumRecords must by greater than 0."));226 } else {227 mdrepoproxyaction.setMaximumItems(Integer.toString(this.getMaximumRecords()));228 }229 230 if (this.getX_cmd_repository() != null ) {231 mdrepoproxyaction.setRepository(this.getX_cmd_repository());232 //TODO\233 if (mdrepoproxyaction.getBaseURI() == null) this.Diagnostics().Add(Diagnostic.UNSUPPORTED_PARAMETERVALUE, "Unknown repository." + getX_cmd_repository());234 }235 if (this.getX_cmd_collections() != null ) {236 mdrepoproxyaction.setCollection(this.getX_cmd_collections());237 }238 239 } else {240 if (operation.equals("explain") || operation == null){241 log.debug("explaining", "debug");242 }else {243 if (operation.equals("scan")){244 if (this.scanClause == null) {245 this.Diagnostics().Add(Diagnostic.MANDATORY_NOTSUPPLIED, "scanClause");246 //return -1;247 } else{248 if (this.scanClause.equals("cmd.Collections")){249 250 } else {251 if (this.scanClause.equals("cmd.Repository")){252 XMLSerializer xmlserializer = new XMLSerializer();253 String xml = xmlserializer.write( WorkspaceProfile.getRepositories());//mdrepoproxyaction.getRepositories() );254 this.setResultStream(new ByteArrayInputStream(xml.getBytes("UTF-8")));255 256 } else {257 258 }259 }260 }261 }else {262 this.Diagnostics().Add(Diagnostic.UNSUPPOERTED_OPERATION, "Only searchRetrieve,explain scan supported."); }263 }264 }265 }266 101 267 public void sru2MD() throws UnsupportedEncodingException{268 // special handling of parameter setting, x-cmd-... not alowed in java269 this.setX_cmd_collections(getServletRequest().getParameter("x-cmd-collections"));270 // root call own SRU SERVER271 //operation272 if (operation.equals("explain") || operation == null){273 // TODO: version param is mandatory for explain as well, but for root-request not!274 //explain275 termsproxyaction = new TermsProxyAction();276 termsproxyaction.setDiagnostics(diagnostics);277 termsproxyaction.setActionkey("terms");278 279 termsproxyaction.setQ("all");280 termsproxyaction.setFormat("sru-explain");281 282 //return -1;283 } else {284 //version285 if (this.version == null) {286 this.Diagnostics().Add(Diagnostic.MANDATORY_NOTSUPPLIED, "version");287 //return -1;288 } else {289 if (!version.equals("1.2")) {290 this.Diagnostics().Add(Diagnostic.UNSUPPORTED_VERSION, "Version 1.2 supported.");291 //return -1;292 }293 }294 295 prepareOperation();296 }297 298 }299 102 300 public void prepareMD() throws Exception{301 sru2MD();302 if (Diagnostics().Accepted()){303 // root-explain304 if (this.termsproxyaction != null) {305 if (this.termsproxyaction.execute() == SUCCESS){306 this.setResultStream(this.termsproxyaction.getResultStream());307 //return SUCCESS;308 }309 } else {310 //TODO diagnostic311 if (this.mdrepoproxyaction.getTargetRequest() == null) {312 Diagnostics().Add(Diagnostic.QUERYSYNTAXERROR);313 //return ERROR;314 }315 if (this.mdrepoproxyaction.execute() == SUCCESS){316 this.setResultStream(this.mdrepoproxyaction.getResultStream());317 postprocess();318 //return SUCCESS;319 }320 }321 }322 //return ERROR;323 }324 */325 /** TODO: move to Utils326 *327 * @param stream328 * @return329 * @throws IOException330 */331 /*332 public static String inputStreamAsString(InputStream stream)333 throws IOException {334 BufferedReader br = new BufferedReader(new InputStreamReader(stream));335 StringBuilder sb = new StringBuilder();336 String line = null;337 338 while ((line = br.readLine()) != null) {339 sb.append(line + "\n");340 }341 342 br.close();343 return sb.toString();344 }345 346 347 348 public void postprocess() throws TransformerConfigurationException, UnsupportedEncodingException, ParserConfigurationException, TransformerException, TransformerFactoryConfigurationError{349 //recordPacking350 if (this.getRecordPacking() != null){351 if (this.getRecordPacking().toLowerCase().equals("string")){352 353 try {354 // FIXME: Which package is IOUTils from?355 this.setResultStream(IOUtils.toInputStream(StringEscapeUtils.escapeXml(inputStreamAsString(this.getResultStream()))));356 } catch (IOException e) {357 // TODO Auto-generated catch block358 e.printStackTrace();359 }360 361 }362 }363 364 // add diagnostics365 if (getDiagnostics().Exists()){366 Document doc = Utils.stream2Document(getResultStream());367 Node r_element= doc.getElementsByTagName("searchRetrieveResponse").item(0);368 Document ddoc = getDiagnostics().buildXMLDocument();369 Node d_element= ddoc.getElementsByTagName("diagnostics").item(0);370 doc.adoptNode(d_element);371 r_element.appendChild(d_element);372 DOMSource source = new DOMSource(doc);373 StringWriter xmlAsWriter = new StringWriter();374 StreamResult result = new StreamResult(xmlAsWriter);375 TransformerFactory.newInstance().newTransformer().transform(source, result);376 this.setResultStream(new ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8")));377 }378 }379 380 //TODO create query + query.toURLParams ?381 public String createURLParams(){382 String params = "";383 384 //TODO params385 /*386 if (paramSet == null){387 if (!(operation == null)){388 params = params + "operation=" + operation;389 }390 if (!(version == null)){391 params = params + "&version=" + version;392 }393 if (!(query == null)){394 params = params + "&query=" + query;395 }396 if (getStartRecord() > 0){397 params = params + "&startRecord=" + String.valueOf(getStartRecord());398 }399 if (getMaximumRecords()> 0){400 params = params + "&numRecords=" + String.valueOf(getMaximumRecords());401 }402 } else {403 Iterator i = paramSet.iterator();404 params = "";405 while(i.hasNext()){406 Map.Entry me = (Map.Entry)i.next();407 if (!(me.getKey().equals("x-cmd-repository") || me.getKey().equals("x-cmd-collections"))){408 params = params + "&" + me.getKey() + "=" + ((String[])me.getValue())[0];409 }410 }411 params = params.substring(1);412 413 }414 415 return params;416 }417 */418 419 /*420 @Override421 public void prepare() throws Exception{422 //this.setX_cmd_repository(getServletRequest().getParameter("x-cmd-repository"));423 //this.setRepository(this.getX_cmd_repository());424 //TODO xsl usage according particular repositories ?425 //this.setActionkey("sru");426 //this.setFormat("xml");427 428 //extern SRU repository429 if (WorkspaceProfile.isSRURepository(getRepository()) || this.getBaseURI() == null){430 super.prepare();431 }432 else {433 prepareMD();434 }435 436 }437 */438 103 @Override 439 104 public void setTargetProxy(){ -
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/internal/Cache.java
r1654 r1852 150 150 } 151 151 if (key_array.length > 2){ 152 e.setAttribute("collection", key_array[2]); 152 e.setAttribute("operation", key_array[2]); 153 }else{ 154 e.setAttribute("operation", ""); 155 } 156 if (key_array.length > 3){ 157 e.setAttribute("collection", key_array[3]); 153 158 }else{ 154 159 e.setAttribute("collection", ""); 155 160 } 156 if (key_array.length > 3){157 e.setAttribute("startItem", key_array[ 3]);161 if (key_array.length > 4){ 162 e.setAttribute("startItem", key_array[4]); 158 163 }else{ 159 164 e.setAttribute("startItem", ""); 160 165 } 161 if (key_array.length > 4){162 e.setAttribute("maximumItems", key_array[ 4]);166 if (key_array.length > 5){ 167 e.setAttribute("maximumItems", key_array[5]); 163 168 }else{ 164 169 e.setAttribute("maximumItems", ""); 165 170 } 166 171 167 if (key_array.length > 5){168 e.setAttribute("repository", key_array[ 5]);172 if (key_array.length > 6){ 173 e.setAttribute("repository", key_array[6]); 169 174 }else{ 170 175 e.setAttribute("repository", ""); 171 176 } 172 if (key_array.length > 6){173 e.setAttribute("maxDepth", key_array[ 6]);177 if (key_array.length > 7){ 178 e.setAttribute("maxDepth", key_array[7]); 174 179 }else{ 175 180 e.setAttribute("maxDepth", ""); 176 181 } 177 if (key_array.length > 7){178 e.setAttribute("lang", key_array[ 7]);182 if (key_array.length > 8){ 183 e.setAttribute("lang", key_array[8]); 179 184 }else{ 180 185 e.setAttribute("lang", ""); 181 186 } 182 if (key_array.length > 8){183 e.setAttribute("duration", key_array[ 8]);187 if (key_array.length > 9){ 188 e.setAttribute("duration", key_array[9]); 184 189 }else{ 185 190 e.setAttribute("duration", ""); … … 270 275 271 276 if (key_array.length > 2){ 272 xpath_expr = xpath_expr + "and @collection='"+key_array[2]+"'"; 277 xpath_expr = xpath_expr + "and @operation='"+key_array[2]+"'"; 278 }else{ 279 xpath_expr = xpath_expr + " and @operation=''"; 280 } 281 282 if (key_array.length > 3){ 283 xpath_expr = xpath_expr + "and @collection='"+key_array[3]+"'"; 273 284 }else{ 274 285 xpath_expr = xpath_expr + " and @collection=''"; 275 286 } 276 if (key_array.length > 3){277 xpath_expr = xpath_expr + "and @startItem='"+key_array[ 3]+"'";287 if (key_array.length > 4){ 288 xpath_expr = xpath_expr + "and @startItem='"+key_array[4]+"'"; 278 289 }else{ 279 290 xpath_expr = xpath_expr + " and @startItem=''"; 280 291 } 281 if (key_array.length > 4){282 xpath_expr = xpath_expr + "and @maximumItems='"+key_array[ 4]+"'";292 if (key_array.length > 5){ 293 xpath_expr = xpath_expr + "and @maximumItems='"+key_array[5]+"'"; 283 294 }else{ 284 295 xpath_expr = xpath_expr + " and @maximumItems=''"; 285 296 } 286 297 287 if (key_array.length > 5){288 xpath_expr = xpath_expr + "and @repository='"+key_array[ 5]+"'";298 if (key_array.length > 6){ 299 xpath_expr = xpath_expr + "and @repository='"+key_array[6]+"'"; 289 300 }else{ 290 301 xpath_expr = xpath_expr + " and @repository=''"; 291 302 } 292 if (key_array.length > 6){293 xpath_expr = xpath_expr + "and @maxDepth='"+key_array[ 6]+"'";303 if (key_array.length > 7){ 304 xpath_expr = xpath_expr + "and @maxDepth='"+key_array[7]+"'"; 294 305 }else{ 295 306 xpath_expr = xpath_expr + " and @maxDepth=''"; 296 307 } 297 if (key_array.length > 7){298 xpath_expr = xpath_expr + "and @lang='"+key_array[ 7]+"']";308 if (key_array.length > 8){ 309 xpath_expr = xpath_expr + "and @lang='"+key_array[8]+"']"; 299 310 }else{ 300 311 xpath_expr = xpath_expr + " and @lang='']"; -
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/model/Repositories.java
r1842 r1852 214 214 public Boolean repositoryExists(String repository_name){ 215 215 216 217 for(int i=0;i<repositories_nodelist.getLength();i++){ 218 if (repositories_nodelist.item(i).getChildNodes().item(1).getNodeValue().equals(repository_name)){ 219 return true; 220 } 221 } 216 NodeList chlist = repositories_nodelist.item(0).getChildNodes(); 217 for(int i=0;i<chlist.getLength();i++){ 218 Node node = chlist.item(i); 219 if (node.getNodeName().equals("item")){ 220 for(int j=0;j<node.getChildNodes().getLength();j++){ 221 if (node.getChildNodes().item(j).getNodeName().equals("name") && node.getChildNodes().item(j).getTextContent().equals(repository_name)){ 222 return true; 223 } 224 } 225 } 226 } 227 222 228 223 229 return false;
Note: See TracChangeset
for help on using the changeset viewer.