Changeset 1536 for MDService2


Ignore:
Timestamp:
09/14/11 11:01:58 (13 years ago)
Author:
gaba
Message:

ComRegistryProxyAction?, DCRAction derivation changed

Location:
MDService2/branches/MDService_simple3/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/CompRegistryProxyAction.java

    r1532 r1536  
    88import eu.clarin.cmdi.mdservice.internal.Cache;
    99import eu.clarin.cmdi.mdservice.internal.MDTransformer;
     10import eu.clarin.cmdi.mdservice.model.Diagnostic;
     11import eu.clarin.cmdi.mdservice.model.WorkspaceProfile;
     12import eu.clarin.cmdi.mdservice.proxy.BasicProxy;
     13import eu.clarin.cmdi.mdservice.proxy.MDRepoProxy;
     14import eu.clarin.cmdi.mdservice.proxy.Pz2Proxy;
     15import eu.clarin.cmdi.mdservice.proxy.SRUProxy;
    1016
    1117/**
     
    1824 *
    1925 */
    20 public class CompRegistryProxyAction extends GenericProxyAction {
     26public class CompRegistryProxyAction extends GenericAction {
    2127
    2228        private static final long serialVersionUID = 1L;
     
    4652        }
    4753       
    48         @Override
     54        //@Override
    4955        public String getProxyKey() {
    5056                return proxy_key;
     57        }
     58       
     59        public void setTargetProxy(){
     60               
     61                setTargetProxy(new BasicProxy());
     62               
    5163        }
    5264       
     
    8395                key +="//-" ;
    8496               
    85                 if (getStartItem()!=null) {
    86                         key += getStartItem() + "//-";
     97                if (getStartRecord()!=null) {
     98                        key += getStartRecord() + "//-";
    8799                }
    88100                        else{
    89101                                key +="//-" ;
    90102                }
    91                 if (getMaximumItems()!=null) {
    92                         key += getMaximumItems() + "//-";
     103                if (getMaximumRecords()!=null) {
     104                        key += getMaximumRecords() + "//-";
    93105                }
    94106                else{
     
    120132                                super.prepare();
    121133                        } else  {
     134                                loadParams();
     135                                setTargetProxy();
     136                                getTargetProxy().checkParams();
     137                               
    122138//                              Admin.notifyUser("CRPA.prepareSourceStream - elements");
    123139                                String xcid;
     
    143159                                        //      Admin.notifyUser("CCCRPA." + getFullFormat());
    144160                                                MDTransformer transformer = new MDTransformer();
    145                                                 transformer.setSrcFile(getTargetRequest());
     161                                                transformer.setSrcFile(getTargetProxy().getTargetRequest());
    146162                                                //transformer.setParams(createTransformerParams());
    147163                                                _sourceStream = transformer.transformXML(__sourceStream);//, getFullFormat(),null,null,null,null,null,null);
     
    171187                                        // set URL as srcFile (for MDTransformer to pass to xsl-scripts)
    172188                                        MDTransformer transformer = new MDTransformer();
    173                                         transformer.setSrcFile(getTargetRequest());
     189                                        transformer.setSrcFile(getTargetProxy().getTargetRequest());
    174190                                        //transformer.setParams(MDTransformer.createParamsMap(getFullFormat()));
    175191                                        _resultStream = transformer.transformXML(_sourceStream);//, getFullFormat());
     
    208224         * @throws Exception
    209225         */
     226        @Override
     227        public String getTargetRequestParams(){
     228                String paramstr = "";
     229               
     230                if (compid==null || compid.equals("")) {
     231                        paramstr =  getActionkey() ;
     232                } else {
     233                        paramstr = getActionkey() + "/clarin.eu:cr1:" + compid;
     234                }
     235                return paramstr;
     236        }
     237        /*
    210238        public URL getTargetRequest() throws IOException {
    211239        // URL targetURL =new URL( base_url, compname + ".xml");
    212240                URL targetURL = null;
    213241                if (compid==null || compid.equals("")) {
    214                         targetURL =new URL( getBaseURL(), getActionkey() );
    215                 } else {
    216                         targetURL =new URL( getBaseURL(), getActionkey() + "/clarin.eu:cr1:" + compid);
     242                        targetURL =new URL( this.getTargetProxy().getBaseURL(), getActionkey() );
     243                } else {
     244                        targetURL =new URL( getTargetProxy().getBaseURL(), getActionkey() + "/clarin.eu:cr1:" + compid);
    217245                }
    218246//              Admin.notifyUser("CompReg.targetURL:" + targetURL);             
     
    221249        return targetURL;
    222250        }
     251        */
    223252
    224253       
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/DCRProxyAction.java

    r1512 r1536  
    2222import eu.clarin.cmdi.mdservice.internal.Admin;
    2323import eu.clarin.cmdi.mdservice.model.Termset;
     24import eu.clarin.cmdi.mdservice.proxy.BasicProxy;
    2425
    2526/**
     
    3233 */
    3334
    34 public class DCRProxyAction extends GenericProxyAction {
     35public class DCRProxyAction extends GenericAction {
    3536
    3637        private String proxy_key = "dcregistry";
     
    7475                 return val;
    7576        }
    76        
     77        /*
    7778        @Override
    7879        public String getProxyKey() {
    7980                return proxy_key;
    8081        }
    81          
     82         */
     83       
    8284        public String getFullFormat() {
    8385                Termset dcr = getDCR();
     
    9395        }
    9496       
     97        public void setTargetProxy(){
     98               
     99                setTargetProxy(new BasicProxy());
     100               
     101        }
     102
     103       
     104        /*
    95105        public URL getBaseURL() throws MalformedURLException {
    96106               
     
    101111                return base_url;
    102112        }
    103        
     113        */
    104114        public String getBaseURI() {           
    105115                return getDCRAttr("url");
     
    112122         * @throws Exception
    113123         */
     124        @Override
     125        public String getTargetRequestParams(){
     126                String paramstr = "";
     127               
     128                if ((getQ()!=null && !getQ().equals(""))) {
     129                        paramstr =  "?dcif-mode=all&workingLanguage=" + getLang() ;
     130                } else {
     131                        //TODO diagnostic or error
     132                }
     133                return paramstr;
     134        }
     135        @Override
     136        public void setRequestProperties(URLConnection urlConnection){
     137                /* need to set Request-Property: Accept to xml
     138                 * for to get dcif/xml from DCR-server by means of content negotiation */
     139
     140                if (getDCRAttr("format").equals("dcif")) {             
     141                        urlConnection.setRequestProperty("Accept", "application/dcif+xml");
     142                        log.debug("setting header Accept:" + urlConnection.getRequestProperty("Accept"));
     143                }
     144               
     145        }
     146        /*
    114147        public URL getTargetRequest() throws IOException {
    115148
     
    121154                        targetURL =new URL(getBaseURI() + "?dcif-mode=all&workingLanguage=" + getLang()) ;
    122155                }
    123                 /*
    124                         if (getQ()==null || getQ().equals("")) {                       
    125                                         // get all available datcat-sets from terms_setup.xml
    126                                
    127                                 targetURL =getBaseURL();
    128                         } else {
    129                                 targetURL =new URL( getBaseURL(), "/" + getQ());
    130                         }
    131                         */
     156               
    132157//              Admin.notifyUser("DCRProxy.targetURL:" + targetURL);
    133158
    134159            return targetURL;
    135160        }
    136        
     161        */
     162        /*
    137163        public InputStream getSourceStream() throws IOException {
    138164
     
    140166                // if no arguments  - get the local-config file
    141167                // FIXME: although this should be competence of TermsProxyAction
     168                //TODO NOT integrated in PROXY
    142169                if ((getQ().equals(ALL) || getQ()==null || getQ().equals("")) && (getActionkey().equals(DATCATS))) {
    143170                        log.debug("serving terms.file:" + Admin.getConfig().getProperty("terms.file"));
     
    146173               
    147174                /* need to set Request-Property: Accept to xml
    148                  * for to get dcif/xml from DCR-server by means of content negotiation */
    149                 URLConnection urlConnection = getTargetRequest().openConnection();
     175                 * for to get dcif/xml from DCR-server by means of content negotiation
     176                URLConnection urlConnection = getTargetProxy().getTargetRequest().openConnection();
    150177               
    151178                if (getDCRAttr("format").equals("dcif")) {             
     
    161188   
    162189        }
    163 
     190*/
    164191}
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/GenericAction.java

    r1532 r1536  
    55import java.io.InputStream;
    66import java.io.StringWriter;
     7import java.net.URLConnection;
    78import java.util.HashMap;
    89import java.util.Map;
     
    421422        }
    422423       
    423         /*
    424         private static final Map<String, String> xsl_map;
    425     static {
    426         Map<String, String> aMap = new HashMap<String,String>();
    427         aMap.put("fullformat","format");
    428         //aMap.put("format","fullformat");
    429         aMap.put("columns", "cols");
    430         aMap.put("maximumItems","maximumItems");
    431         aMap.put("startItem", "startItem");
    432         aMap.put("lang","lang");
    433         aMap.put("q", "q");
    434         aMap.put("repository","repository_name");
    435         //aMap.put("repository_type", "repository_type");
    436         xsl_map = Collections.unmodifiableMap(aMap);
    437     }
    438    
    439         public Map<String,String> createTransformerParams(){
    440                
    441                 Map<String, String> map = new HashMap<String, String>();
    442 
    443                 Set<Entry<String, String[]>> set = getParams().entrySet();
    444                 Iterator<Entry<String, String[]>> i = set.iterator();
    445 
    446             while(i.hasNext()){
    447               Map.Entry<String,String[]> e = (Map.Entry<String,String[]>)i.next();
    448               if (xsl_map.containsKey((String)e.getKey())) {
    449                   map.put(xsl_map.get((String)e.getKey()), (String)e.getValue()[0]);
    450               }
    451              
    452             }
    453             return map;
    454         }
    455        
    456         public Map<String,String> createTransformerParams(){
    457                
    458                 HashMap<String,String> hm = new HashMap<String,String>();
    459                
    460             if (getFullFormat() != null){
    461                         hm.put("format", getFullFormat());
    462             }
    463            
    464                 if (getColumns() != null){
    465                         hm.put("cols", getColumns());
    466                 } else {
    467                         hm.put("cols", "");
    468                 }
    469                 if (getStartItem() != null){
    470                         hm.put("startItem", getStartItem());
    471                 }
    472                 if (getMaximumItems() != null){
    473                         hm.put("maximumItems", getMaximumItems());     
    474                 }
    475                 if (getLang() != null){
    476                         hm.put("lang", getLang());
    477                 }
    478                 if (getQ() != null){
    479                         hm.put("q", getQ());
    480                 }
    481                 //if (getRepository() != null){
    482                 hm.put("repository_name", String.valueOf(getRepository()));
    483                 hm.put("repository_type", WorkspaceProfile.getRepositoryType(this.getRepository()));
    484                 //}
    485      
    486                 return hm;             
    487         }
    488           */
    489424       
    490425        /**
     
    498433         * @throws Exception  This is handled by struts (is mapped to some result in struts.xml based on the Exception-Class)
    499434         */
    500        
     435        public String getTargetRequestParams(){
     436                return "";
     437        }
     438       
     439        public void setRequestProperties(URLConnection urlConnection){
     440               
     441        }
     442
    501443        public void prepare()  {
    502444                       
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/proxy/BasicProxy.java

    r1522 r1536  
    99import java.net.URISyntaxException;
    1010import java.net.URL;
     11import java.net.URLConnection;
    1112import java.util.HashMap;
    1213import java.io.ByteArrayInputStream;
     
    117118        public URL getTargetRequest() throws IOException {
    118119                 
    119                 URL targetURL =getBaseURL();
     120                URL targetURL =new URL(getBaseURI() + this.getSourceAction().getTargetRequestParams());
    120121               
    121122                log.debug("getTargetRequest().targetURL:" + targetURL);
     
    125126
    126127        public InputStream getSourceStream() throws IOException, NoStylesheetException {
    127                 return getTargetRequest().openStream();         
     128                URLConnection urlConnection = getTargetRequest().openConnection();
     129                getSourceAction().setRequestProperties(urlConnection);
     130                return urlConnection.getInputStream();//.openStream();         
    128131        }
    129132
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/proxy/ProxyInterface.java

    r1515 r1536  
    33import java.io.IOException;
    44import java.io.InputStream;
     5import java.net.MalformedURLException;
    56import java.net.URL;
    67
  • MDService2/branches/MDService_simple3/src/mdservice.properties

    r1522 r1536  
    1515//?? dcregistry.uri = http://www.isocat.org/rest/
    1616compregistry.uri = http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/
     17components.uri = http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/
     18profiles.uri = http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/
    1719virtualcollection.uri = http://clarin.ids-mannheim.de/vcr/service/virtualcollection
    1820
     
    2022//cache.path = /srv/tomcat6/webapps/MDService2_cache/
    2123//workspaceprofile.path = /srv/tomcat6/webapps/MDService2_profiles/
    22 cache.path = C:/apps/apache-tomcat/webapps/MDService2_cache/
    23 workspaceprofile.path = C:/apps/apache-tomcat/webapps/MDService2_profiles/
    24 //cache.path = C:/apache-tomcat-6.0.26/webapps/MDService2_cache/
    25 //workspaceprofile.path = C:/apache-tomcat-6.0.26/webapps/MDService2_profiles/
     24//cache.path = C:/apps/apache-tomcat/webapps/MDService2_cache/
     25//workspaceprofile.path = C:/apps/apache-tomcat/webapps/MDService2_profiles/
     26cache.path = C:/apache-tomcat-6.0.26/webapps/MDService2_cache/
     27workspaceprofile.path = C:/apache-tomcat-6.0.26/webapps/MDService2_profiles/
    2628workspace.file = WorkspaceProfile.xml
    2729
Note: See TracChangeset for help on using the changeset viewer.