Ignore:
Timestamp:
08/25/11 20:21:23 (13 years ago)
Author:
vronk
Message:

started cleaning up code, adding inline-documentation;
also changes to output method in xsl (xhtml)

File:
1 edited

Legend:

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

    r1234 r1495  
    2929
    3030/**
    31  * Main Struts 2 controller
    32  * responds to requests (collections, model, recordset)
     31 * Proxy to the Metadata Repository.
     32 * Responds to requests (collections, model, recordset)
    3333 * by dispatching the requests to appropriate internal methods and filling the inputStream with the result
    3434 *
     
    4444        private String proxy_key = "mdrepository";
    4545       
    46         @Override
     46        /**
     47         * Override of the basic method provided by the super-class
     48         */     
     49        @Override       
    4750        public String getBaseURI() {           
    48                 Admin.notifyUser("MDREPO-property:" + Admin.getConfig().getProperty(getProxyKey() + ".uri"));
    49                 Admin.notifyUser("MDREPO-profile:" + getRepositoryPath());
    50                 String uri = getRepositoryPath();//Admin.getConfig().getProperty(getProxyKey() + ".uri");               
     51                String uri = getRepositoryPath();               
    5152                return uri;
    5253        }
     
    5657                super.setFormat(format);               
    5758        }
     59       
    5860        @Override
    5961        public String getProxyKey() {
     
    6163        }
    6264       
    63        
     65        /**
     66         * A mapping between the actionkeys in the request and the operation-parameter expected by the MDRepository
     67         */
    6468        private final static HashMap<String,String> urls = new HashMap<String,String>();
    6569         static
     
    7074                 urls.put("record", "?operation=searchRetrieve&query=");
    7175         }
    72         /*
    73          @Override
    74          public URL getBaseURL() throws MalformedURLException {         
    75                         if (base_url == null) {
    76                                 base_url = new URL(Admin.getConfig().getProperty(getProxyKey() + ".uri"));
    77                                 try {
    78                                         Admin.notifyUser("TEST-URLold:" + base_url.toURI());
    79                                 } catch (URISyntaxException e) {
    80                                         // TODO Auto-generated catch block
    81                                         e.printStackTrace();
    82                                 }
    83                                 base_url = new URL(getRepository());
    84                                 try {
    85                                         Admin.notifyUser("TEST-URLnew:" + base_url.toURI());
    86                                 } catch (URISyntaxException e) {
    87                                         // TODO Auto-generated catch block
    88                                         e.printStackTrace();
    89                                 }
    90                         }
    91                         return base_url;
    92                 }
    93          */
    94          
     76 
    9577        /**
    9678         * uses base_url + url_pattern (parametrized by actionkey) to form a url
     
    10284               
    10385                Admin.notifyUser("MDRPA.getQ:" + getSquery() + " and (" +  getQ() + ")");
    104                 Admin.notifyUser("MDRPA.getActionkey:" + getActionkey());
    105                 Admin.notifyUser("MDRPA.getMaxdepth:" + getMaxdepth());
     86                Admin.notifyUser("MDRPA.getActionkey:" + getActionkey());               
    10687               
    10788                Query query = new Query(getSquery(), getQ(),getActionkey());
     89
     90        // check if the query could get parsed
    10891                if (query.isStatus(Query.PARSEERROR)) {
    10992                        Admin.notifyUser("MDRPA.query.PARSEERROR:" + query.getMsg());
     
    119102                        query.setOptions(getOptions());
    120103                        query.setSort(getSort());
    121                         //Admin.notifyUser("MDRPA.records:" + query.getStartRecord());
    122                         //Admin.notifyUser("MDRPA.records:" + query.getMaximumRecords());
    123                         URL targetURL = null;           
    124                        
     104               
     105                        URL targetURL = null;
    125106                        targetURL =new URL( getBaseURL(), urls.get(getActionkey()) + query.toURLParam() );
    126107                        Admin.notifyUser("MDRPA.targetURL.query.toURLParam:" + query.toURLParam());
     
    130111        }
    131112
    132        
    133 /*
    134  * FOLLOWING ARE OBSOLETE METHODS
    135  * for processing the requests and serving the results
    136  * they stay here for reference (as bad examples) temporarily
    137  * and can/shall be removed in the near future.
    138  */
    139        
    140 /**
    141  * serves the collections, passes the Request to MDRepositoryProxy
    142  * @return
    143  * @throws Exception
    144  */
    145         /*
    146         public String collections() throws Exception {
    147        
    148                 Query query = new Query(getQ(),Query.COLLECTIONS);
    149                
    150 //               inputStream = getMDRepo().getCollections(query);
    151                  
    152                 return SUCCESS;
    153         }
    154 */
    155         /**
    156          * serves the model/terms, via Query.execute() and .getResult()
    157          * @return
    158          * @throws Exception
    159          */
    160 /*
    161         public String model() throws Exception {
    162                
    163                 Query query = new Query(getQ(), Query.MODEL, getCollection());
    164                         Admin.notifyUser(query.getTargetRequest().toString());
    165                         query.setMaxdepth(getMaxdepth());
    166                 query.execute();                               
    167                        
    168                 //inputStream = query.getResult().getResultStream(format);
    169                 return SUCCESS;
    170         }
    171 */
    172         /**
    173          * the method for actual querying of MDRepository
    174          * and getting back the MD-recordset
    175          * using Query-object (not asking MDRepository yet)
    176          *   
    177          * @return
    178          * @throws Exception
    179          * @throws Exception
    180          */     
    181         /*
    182         public String recordset() throws Exception {
    183                
    184                 Query query = new Query(getQ(), Query.RECORDSET, getCollection());
    185                        
    186                         Admin.notifyUser("recordset_target_uri:" + query.getTargetRequest().toString());               
    187                         query.execute();                               
    188113
    189 //              String str =query.getResult().getHeader();             
    190                  
    191 //              inputStream = new ByteArrayInputStream(str.getBytes());
    192 
    193 //              inputStream = query.getResult().getResultStream(format);
    194                 return SUCCESS;
    195                  
    196         }
    197         */
    198        
    199114        @Override
    200115        public void prepare() throws Exception{
Note: See TracChangeset for help on using the changeset viewer.