Ignore:
Timestamp:
04/25/11 21:01:01 (13 years ago)
Author:
vronk
Message:

adding jsdocs
added sru_explain.xsl in mdservice.properties
added termsproxyaction in SRUProxyAction for explain()-operation (based on terms)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/SRUProxyAction.java

    r1215 r1236  
    7878
    7979        private MDRepoProxyAction mdrepoproxyaction;
     80        private TermsProxyAction termsproxyaction;
    8081        private InputStream resultStream;
    8182        private HttpServletRequest request;
     
    8990         {       
    9091                 hash_operations.put("searchRetrieve", "recordset");
     92                 hash_operations.put("explain", "model"); /* could be terms*/
     93                 hash_operations.put("scan", "values");
    9194         }
    9295         
     
    9598         {       
    9699                 operation_code.put("searchRetrieve", OP_SEARCHRETRIEVE);
    97                  operation_code.put("searchRetrieve", OP_EXPLAIN);
    98                  operation_code.put("searchRetrieve", OP_SCAN);
     100                 operation_code.put("explain", OP_EXPLAIN);
     101                 operation_code.put("scan", OP_SCAN);
    99102         }
    100103         
     
    304307                        if ((this.maximumRecords < 0 ) ||((getServletRequest().getParameter("maximumRecords") != null) && (getServletRequest().getParameter("maximumRecords").equals("0")))){
    305308                                   this.Diagnostics().Add(new Diagnostic(Diagnostic.UNSUPPORTED_PARAMETERVALUE,
    306                                                    "maximumRecords must by grater than 0."));
     309                                                   "maximumRecords must by greater than 0."));
    307310                        } else {
    308311                                mdrepoproxyaction.setMaximumItems(Integer.toString(this.getMaximumRecords())); 
     
    319322
    320323                } else {
    321                         if (operation.equals("explain")){
    322                                
     324                        if (operation.equals("explain") || operation == null){
     325                                Admin.notifyUser("explaining", "debug");
    323326                        }else {
    324327                                if (operation.equals("scan")){
     
    345348                }
    346349        }
     350       
    347351        public void prepare() throws UnsupportedEncodingException{
    348352                // special handling of parameter setting, x-cmd-... not alowed in java
    349353                this.setX_cmd_repository(getServletRequest().getParameter("x-cmd-repository"));
    350354                this.setX_cmd_collections(getServletRequest().getParameter("x-cmd-collections"));
    351 
    352                
    353                 //version
    354                 if (this.version == null) {
    355                         this.Diagnostics().Add(Diagnostic.MANDATORY_NOTSUPPLIED, "version");
     355               
     356                // root call
     357                //operation
     358                if (operation.equals("explain") || operation == null){
     359                        // TODO: version param is mandatory for explain as well, but for root-request not!
     360                        //explain
     361                        termsproxyaction = new TermsProxyAction();
     362                        termsproxyaction.setDiagnostics(diagnostics);
     363                        termsproxyaction.setActionkey("terms");
     364                       
     365                        termsproxyaction.setQ("all");                   
     366                        termsproxyaction.setFormat("sru-explain");                     
     367                       
    356368                        //return -1;
    357                 } else {
    358                         if (!version.equals("1.2")) {
    359                                 this.Diagnostics().Add(Diagnostic.UNSUPPORTED_VERSION, "Version 1.2 supported.");
     369                } else {                               
     370                        //version               
     371                        if (this.version == null) {
     372                                this.Diagnostics().Add(Diagnostic.MANDATORY_NOTSUPPLIED, "version");
    360373                                //return -1;
    361                         }
    362                 }
    363                 //operation
    364                 if (this.operation == null) {
    365                         this.Diagnostics().Add(Diagnostic.MANDATORY_NOTSUPPLIED, "operation");
    366                         //return -1;
    367                 } else {
     374                        } else {
     375                                if (!version.equals("1.2")) {
     376                                        this.Diagnostics().Add(Diagnostic.UNSUPPORTED_VERSION, "Version 1.2 supported.");
     377                                        //return -1;
     378                                }
     379                        }
     380                       
    368381                        prepareOperation();
    369382                }
     
    444457                prepare();
    445458                if (Diagnostics().Accepted()){
    446                         //TODO diagnostic
    447                         if (this.mdrepoproxyaction.getTargetRequest() == null) {
    448                                 Diagnostics().Add(Diagnostic.QUERYSYNTAXERROR);
    449                                 return ERROR;
    450                         }
    451                         if (this.mdrepoproxyaction.execute() == SUCCESS){
    452                                 resultStream = this.mdrepoproxyaction.getResultStream();
    453                                 postprocess();
    454                                 return SUCCESS;
     459                        // root-explain
     460                        if (this.termsproxyaction != null) {                   
     461                                if (this.termsproxyaction.execute() == SUCCESS){
     462                                        resultStream = this.termsproxyaction.getResultStream();
     463                                        return SUCCESS;
     464                                }
     465                        } else {
     466                                //TODO diagnostic                       
     467                                if (this.mdrepoproxyaction.getTargetRequest() == null) {
     468                                        Diagnostics().Add(Diagnostic.QUERYSYNTAXERROR);
     469                                        return ERROR;
     470                                }
     471                                if (this.mdrepoproxyaction.execute() == SUCCESS){
     472                                        resultStream = this.mdrepoproxyaction.getResultStream();
     473                                        postprocess();
     474                                        return SUCCESS;
     475                                }
    455476                        }
    456477                }
Note: See TracChangeset for help on using the changeset viewer.