Changeset 1613 for MDService2


Ignore:
Timestamp:
11/05/11 17:38:57 (13 years ago)
Author:
vronk
Message:

various small changes, clean up code

Location:
MDService2/branches/MDService_simple3
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • MDService2/branches/MDService_simple3/WebContent/static/queries2.xml

    r1575 r1613  
    2828                        <dd>
    2929                                <ul>
    30                                         <li><a class="query" href="?q=clarin.eu:ws-registry&amp;repository=localhost-mirror">WS registry</a></li>
     30                                        <li><a class="query" href="?query=clarin.eu:ws-registry&amp;repository=localhost-mirror">WS registry</a></li>
    3131                                </ul>
    3232                        </dd>
  • MDService2/branches/MDService_simple3/WebContent/static/test2.xml

    r1531 r1613  
    2525                 
    2626                 <a class="request count" href="/model/xml?repository=clarin.at-mirror&amp;q=teiHeader">model teiHeader</a>
    27                 <a class="request count" href="/terms/xml/?repository=localhost-mirror&amp;q=all">terms localhost</a>
    28                 <a class="query count" href="?squery=syntax">squery=syntax</a>
     27                <a class="request count" href="/terms/xml?repository=localhost-mirror&amp;q=all">terms localhost</a>
     28                <a class="query count" href="?query=syntax">squery=syntax</a>
    2929                <!-- <a class="query" href="/terms/htmldetail/?repository=localhost-mirror&amp;q=all">terms localhost</a>  -->
    3030                               
  • MDService2/branches/MDService_simple3/build.properties

    r1516 r1613  
    2020source.home=./src
    2121lib.home=./WebContent/WEB-INF/lib
     22smc.home=C:/Users/m/3lingua/clarin/CMDI/_repo2/SMC/dist
    2223#used for Jar files that are needed for compiling
    2324#but should not be part of the war file
  • MDService2/branches/MDService_simple3/build.xml

    r1516 r1613  
    55     Date:     January 2010
    66     
    7      Project:  Struts 2 Coding Actions
     7     Project:  MDService
    88     
    9      Author:   Bruce Phillips
     9     (based on Bruce Phillips Struts 2 Coding Actions)
    1010     ====================================================================== -->
    11 
    12 
    1311       
    14 <project name="Coding_Actions_Struts2_Ant" default="archive" basedir=".">
     12<project name="MDService" default="archive" basedir=".">
    1513       
    1614    <description>
    17            Example of using Struts 2 tags.
     15      Basic targets for building MDService webapp
    1816    </description>
    1917       
     
    7270                                <path>
    7371                                <fileset dir="${lib.home}" />
     72                                        <fileset dir="${smc.home}" />
    7473                                        <fileset dir="${lib.external}" />
    7574                            </path>
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/CompRegistryProxyAction.java

    r1540 r1613  
    1  package eu.clarin.cmdi.mdservice.action;
     1package eu.clarin.cmdi.mdservice.action;
    22
    33import java.io.InputStream;
     
    4848        }
    4949       
    50         public void setTargetProxy(){
    51                
    52                 setTargetProxy(new BasicProxy());
    53                
     50        public void setTargetProxy(){           
     51                setTargetProxy(new BasicProxy());               
    5452        }
    5553       
    56         @Override
    57         /*
    5854        public String getRequestKey() {
    59                 String key="";
    60                 if (getActionkey()!=null) {
    61                         key += getActionkey() + "//-" ;
    62                 }
    63                 if (getCompid()!=null) {
    64                         key += getCompid() + "//-" ;
    65                 }
    66                  
    67                 return key;
    68         }
    69 */
    70          public String getRequestKey() {
    7155                String key="";
    7256                if (getActionkey()!=null) {
     
    10791                        key +="//-" ;
    10892                }
    109                
    110                  
    11193                return key;
    11294        }
     
    11799        public void prepare()  {               
    118100               
    119                 try {
    120                
     101                try {           
    121102                        //log.debug("CRPA.prepare");
    122103                        if (!getActionkey().equals("elements")) {
     
    159140                                //              log.debug("CRPA-putting in cache: " + getRequestKey());
    160141                                                _sourceStream = Cache.getCache().getFromCache(getRequestKey());
    161                                 } /*else {
    162                                                 log.debug("CRPA-reading from cache: " + getRequestKey());
    163                                 }*/
    164                                         /*
    165                                 File file=new File(Cache.getCache().formPath(getRequestKey()));
    166                                 log.debug("File-absolutePath " + file.getAbsolutePath());
    167                                 URL url = null;
    168                                    try{
    169                                            url = file.toURL();
    170                                            log.debug("URL-tostring " + url.toString());
    171                                            }  catch (MalformedURLException me){
    172                                   }
    173                                  */
     142                                }
    174143                               
    175144                                if (getFormat().equals("xml")) {                       
     
    188157                                setSourceStream(_sourceStream);
    189158                                setResultStream(_resultStream);
    190 
    191                                 /*
    192                                 if (getFormat().equals("txt")) {
    193                                         File f=new File(Cache.getCache().formPath("terms_autocomplete.txt"));
    194                                     OutputStream out=new FileOutputStream(f);
    195                                     byte buf[]=new byte[1024];
    196                                     int len;
    197                                     while((len=getResultStream().read(buf))>0)
    198                                         out.write(buf,0,len);
    199                                     out.close();
    200         log.debug("terms_autocomplete.txt");
    201                                 }
    202                                 */
    203159                        }
    204160                } catch(Exception e){
    205161                       
    206162                }                       
    207 
    208163        }
    209 
    210164
    211165        /**
     
    226180                return paramstr;
    227181        }
     182
    228183        /*
    229184        public URL getTargetRequest() throws IOException {
     
    240195        return targetURL;
    241196        }
    242         */
    243 
    244        
     197        */     
    245198}
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/DCRProxyAction.java

    r1540 r1613  
    55import eu.clarin.cmdi.mdservice.model.Termset;
    66import eu.clarin.cmdi.mdservice.proxy.BasicProxy;
     7import eu.clarin.cmdi.mdservice.proxy.DCRProxy;
    78
    89/**
     
    7980        public void setTargetProxy(){
    8081               
    81                 setTargetProxy(new BasicProxy());
     82                setTargetProxy(new DCRProxy());
    8283               
    8384        }
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/GenericAction.java

    r1569 r1613  
    4343        private Diagnostics diagnostics;
    4444
    45         /**
    46          * Properties to be filled by Struts with according request-parameters
    47          */
    4845        private String actionkey = "generic";
    4946        private String q;
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/RepoAction.java

    r1540 r1613  
    3434                return getActionkey() + "2" + getFormat();
    3535        }
     36
    3637        /**
    3738         * Based on the repository type - we create a typed Proxy, that will do the work.
     
    6465                                getDiagnostics().Add(Diagnostic.SYSTEM_ERROR, "Error in workspaceprofile configuration", "repository=" + getRepository() );
    6566                        }
    66                        
    6767        }
    68        
    69 
    70         /**
    71          * Internal identification of the target-proxy
    72          * base for finding the right base_url in the properties
    73          * subclass has to override with its specific proxykey.
    74          *
    75          * @return the key identifying this type of proxy
    76          */
    77         public String getProxyKey() {
    78                 return "";
    79         }       
    8068
    8169}
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/TermsProxyAction.java

    r1540 r1613  
    55import java.net.MalformedURLException;
    66import java.net.URL;
    7 
    87import javax.xml.transform.TransformerException;
    9 
    108import org.apache.log4j.Logger;
    119
     
    2119 * 
    2220 * @author vronk
    23  *
    2421 */
    2522public class TermsProxyAction extends GenericProxyAction {
    2623
    27         public static Logger log = Logger.getLogger("TermsProxyAction");
     24        public static Logger log = Logger.getLogger("TermsProxyAction");       
     25        private static final long serialVersionUID = 1L;
    2826       
    29         private static final long serialVersionUID = 1L;
    30 
    31         public static String ALL = "all";
    32        
     27        public static String ALL = "all";       
    3328        private String proxy_key = "terms";
    3429       
     
    4338        }
    4439       
    45        
    46 /*      @Override
    47         public String getFullFormat() {         
    48                 return "terms2extract";
    49         }
    50         */
    51        
    52         /*
    53          @Override
    54          public String getRequestKey() {
    55                         String key="";
    56                         if (getActionkey()!=null) {
    57                                 key += getActionkey() + "//-" ;
    58                         }
    59                         if (getQ()!=null) {
    60                                 key += getQ() + "//-" ;
    61                         } else {
    62                                 key +="//-" ;
    63                         }
    64                         if (getCollection()!=null) {
    65                                 key += getCollection() + "//-";
    66                         } else {
    67                                 key +="//-" ;
    68                         }
    69                         if (getSquery()!=null) {
    70                                 key += getSquery() + "//-" ;
    71                         } else {
    72                                 key +="//-" ;
    73                         }
    74                         if (getStartRecord()!=null) {
    75                                 key += getStartRecord() + "//-";
    76                         }
    77                         if (getMaximumRecords()!=null) {
    78                                 key += getMaximumRecords();
    79                         }
    80                          
    81                         return key;
    82         }
    83          */
    8440        public Termset getTermset() {           
    8541                String ts_id="";
     
    10662                return base_url;
    10763        }
    108        
    109        
     64               
    11065         /**
    11166         * uses base_url + url_pattern (parametrized by actionkey) to form a url
     
    11570        public URL getTargetRequest() throws IOException {
    11671        // URL targetURL =new URL( base_url, compname + ".xml");
    117        
    11872               
    11973                URL targetURL = null;
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/internal/Utils.java

    r1540 r1613  
    103103                return config;
    104104        }
     105
     106        /**
     107         * convenience function to get a config property value
     108         * @param key
     109         * @return
     110         */
     111                public static String getConfig(String key) {
     112                                return getConfig().getProperty(key);           
     113                }
     114               
    105115       
    106116        /**
     
    185195                    DocumentBuilderFactory.newInstance();
    186196                    DocumentBuilder builder = factory.newDocumentBuilder();
    187                     document = builder.parse(path);                 
     197                    InputStream doc_is = load2Stream(path);
     198                    document = builder.parse(doc_is);               
     199                   
    188200                }
    189201                catch (FactoryConfigurationError e) {
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/model/Query.java

    r1588 r1613  
    4848       
    4949        private String type;
    50         /**
    51          * meant a target url/service, allowing querying different services on per query basis
    52          * not used yet
    53          */
    54         private String target; 
    55        
    56         private URL targetRequest;
     50       
    5751        private String syntax = "cql";  /* cql, cmdIndex, xpath */
    5852        private String query_string;
     
    429423        }
    430424       
    431        
    432425        /**
    433426         * provides a xml-version of the query (if parsed successfully)
     
    482475                               
    483476                 return xpath.replace(".", "//");
    484         }
    485 
    486        
     477        }       
    487478}
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/proxy/BasicProxy.java

    r1569 r1613  
    66import java.net.URL;
    77import java.net.URLConnection;
     8import java.util.Map;
     9
    810import org.apache.log4j.Logger;
    911import eu.clarin.cmdi.mdservice.action.GenericAction;
     
    1113import eu.clarin.cmdi.mdservice.internal.NoStylesheetException;
    1214import eu.clarin.cmdi.mdservice.internal.Utils;
    13 import eu.clarin.cmdi.mdservice.model.Termset;
     15
    1416
    1517/**
     
    4446        }
    4547       
     48        public Map<String,String[]> getParams() {
     49                return getSourceAction().getParams();
     50        }
     51       
    4652        /**
    4753         * Convenience function to access the request-parameters in the Action 
     
    5662                // required Params     
    5763        }
    58        
    5964       
    6065        /**
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/proxy/RepoProxy.java

    r1569 r1613  
    11package eu.clarin.cmdi.mdservice.proxy;
    22
    3 import java.io.File;
    43import java.io.IOException;
    54import java.io.InputStream;
    6 import java.io.StringReader;
    7 import java.io.StringWriter;
    85import java.net.MalformedURLException;
    9 import java.net.URISyntaxException;
    106import java.net.URL;
    11 import java.util.HashMap;
    127import java.util.Map;
    13 import java.io.ByteArrayInputStream;
    14 
    15 import javax.xml.parsers.DocumentBuilder;
    16 import javax.xml.parsers.DocumentBuilderFactory;
    17 import javax.xml.transform.OutputKeys;
    18 import javax.xml.transform.Transformer;
    19 import javax.xml.transform.TransformerException;
    20 import javax.xml.transform.TransformerFactory;
    21 import javax.xml.transform.dom.DOMSource;
    22 import javax.xml.transform.stream.StreamResult;
    238
    249import org.apache.log4j.Logger;
    25 import org.w3c.dom.Document;
    26 import org.w3c.dom.Node;
    27 import org.w3c.dom.NodeList;
    28 import org.xml.sax.InputSource;
    2910
    3011import eu.clarin.cmdi.mdservice.action.GenericAction;
    31 import eu.clarin.cmdi.mdservice.action.RepoAction;
    3212import eu.clarin.cmdi.mdservice.internal.CQLParseException;
    3313import eu.clarin.cmdi.mdservice.internal.NoStylesheetException;
    3414import eu.clarin.cmdi.mdservice.model.Diagnostic;
    35 import eu.clarin.cmdi.mdservice.model.Query;
    3615import eu.clarin.cmdi.mdservice.model.WorkspaceProfile;
    3716
     
    7857         * @return
    7958         */
    80         public String getParam(String key) {
     59        /* This is already defined in BasicProxy! ?
     60         public String getParam(String key) {
     61         
    8162                return getSourceAction().getParam(key);
    8263        }
     64        */
    8365       
    84         public Map<String,String[]> getParams() {
    85                 return getSourceAction().getParams();
    86         }
    8766       
    8867        public void checkParams() {
  • MDService2/branches/MDService_simple3/src/mdservice.properties

    r1559 r1613  
    1414
    1515//?? dcregistry.uri = http://www.isocat.org/rest/
    16 compregistry.uri = http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/
    17 components.uri = http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/
    18 profiles.uri = http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/
     16//moving to SMC
     17//compregistry.uri = http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/
     18//components.uri = http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/
     19//profiles.uri = http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/
    1920virtualcollection.uri = http://clarin.ids-mannheim.de/vcr/service/virtualcollection
    2021
     
    2223//cache.path = /srv/tomcat6/webapps/MDService2_cache/
    2324//workspaceprofile.path = /srv/tomcat6/webapps/MDService2_profiles/
    24 //cache.path = C:/apps/apache-tomcat/webapps/MDService2_cache/
    25 //workspaceprofile.path = C:/apps/apache-tomcat/webapps/MDService2_profiles/
    26 cache.path = C:/apache-tomcat-6.0.26/webapps/MDService2_cache/
    27 workspaceprofile.path = C:/apache-tomcat-6.0.26/webapps/MDService2_profiles/
     25cache.path = C:/apps/apache-tomcat/webapps/MDService2_cache/
     26workspaceprofile.path = C:/apps/apache-tomcat/webapps/MDService2_profiles/
     27//cache.path = C:/apache-tomcat-6.0.26/webapps/MDService2_cache/
     28//workspaceprofile.path = C:/apache-tomcat-6.0.26/webapps/MDService2_profiles/
    2829workspace.file = WorkspaceProfile.xml
    2930
    3031cacheindex.file = cache_index.xml
    3132xml.comp =
     33
     34
    3235xsl.profile2VC = profile2VC.xsl
    3336xsl.XCQL2XPATH = XCQL2Xpath.xsl
     
    7376
    7477xsl.datcat-all2terms = datcat_all2terms.xsl
    75 xsl.dcr-rdf2terms = datcat_rdf2terms.xsl
     78//xsl.dcr-rdf2terms = datcat_rdf2terms.xsl
    7679xsl.rr-rdf2terms = datcat_rdf2terms.xsl
    7780xsl.dcr-dcif2terms = datcat_dcif2terms.xsl
  • MDService2/branches/MDService_simple3/src/struts.xml

    r1558 r1613  
    140140                </action>
    141141               
    142 <!-- REGISTRY PROXY ACTIONS -->         
     142<!-- REGISTRY PROXY ACTIONS -->
     143<!-- SMCAction replaces all registry actions -->
     144                <action name="smc/list/*" class="eu.clarin.cmdi.mdservice.action.SMCAction" method="execute">
     145                                <param name="context">{1}</param>
     146                                <param name="actionkey">list</param>
     147                            <result type="stream">             
     148                                <param name="contentType">${getActionContentType()}</param>                             
     149                                <param name="inputName">resultStream</param>
     150                            </result>
     151                </action>
     152
     153                <action name="smc/map/*" class="eu.clarin.cmdi.mdservice.action.SMCAction" method="execute">
     154                                <param name="term">{1}</param>
     155                                <param name="actionkey">map</param>
     156                            <result type="stream">             
     157                                <param name="contentType">${getActionContentType()}</param>                             
     158                                <param name="inputName">resultStream</param>
     159                            </result>
     160                </action>
     161
     162               
    143163                <action name="comp/*" class="eu.clarin.cmdi.mdservice.action.CompRegistryProxyAction" method="execute">
    144164                                <param name="compid">{1}</param>
  • MDService2/branches/MDService_simple3/src/xsl/mdinst2view.xsl

    r1495 r1613  
    9292                                                <xsl:if test="count(ResourceProxy) &gt; $resourceref_limit" >
    9393                                                        <span class="label" >showing first </span> <xsl:value-of select="$resourceref_limit" /> <span class="label" > references. </span>
    94                                                         <s><a href="{concat($default_prefix, my:encodePID(./ancestor::CMD/Header/MdSelfLink))}">see more</a></s>                                                       
     94                                                        <!--   <s><a href="{concat($default_prefix, my:encodePID(./ancestor::CMD/Header/MdSelfLink))}">see more</a></s> -->
     95                                                        <s><a href="{my:formURL('record', 'htmlpage', my:encodePID(./ancestor::CMD/Header/MdSelfLink))}">see more</a></s>
     96                                                                                                               
    9597                                                </xsl:if>
    9698                                                <xsl:apply-templates select="ResourceProxy[position() &lt; $resourceref_limit]" />
     
    115117                                        </xsl:when>
    116118                                        <xsl:otherwise>
    117                                                         <xsl:value-of select="concat($default_prefix, my:encodePID(ResourceRef))" />
     119                                                        <xsl:value-of select="my:formURL('record', 'htmlpage', my:encodePID(ResourceRef))" />
    118120                                        </xsl:otherwise>
    119121                                </xsl:choose>                           
Note: See TracChangeset for help on using the changeset viewer.