Changeset 1508 for MDService2


Ignore:
Timestamp:
09/02/11 19:28:46 (13 years ago)
Author:
vronk
Message:

intermediate consolidated version of the interface (struts.xml),
that should at least be able to search in md + basic static responses (index);
also added a separate catchall-response for unsupported requests.

Location:
MDService2/branches/MDService_simple
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • MDService2/branches/MDService_simple/src/eu/clarin/cmdi/mdservice/action/CollectionProxyAction.java

    r1496 r1508  
    3939                URL targetURL = null;
    4040                //targetURL =new URL( getBaseURL(), getActionkey());
    41                 //FIXME: get maxdepth-constant out of here !!
     41               
    4242                String params = "";
    4343                params = "&maxdepth=" + getMaxdepth();
  • MDService2/branches/MDService_simple/src/eu/clarin/cmdi/mdservice/action/GenericProxyAction.java

    r1503 r1508  
    5959        private String lang="en";
    6060        private int maxdepth;   
    61         private String format;
     61        private String format="xml"; // default no transformation
    6262        private String options;
    6363        private String actionContentType;
  • MDService2/branches/MDService_simple/src/eu/clarin/cmdi/mdservice/action/RepoProxyAction.java

    r1496 r1508  
    3939 *
    4040 */
    41 public class RepoProxyAction extends MDRepoProxyAction {
     41public class RepoProxyAction extends GenericProxyAction {
    4242
    4343        private static final long serialVersionUID = 1L;
     
    4949                return proxy_key;
    5050        }
     51
     52        /**
     53         * Override of the basic method provided by the super-class
     54         * Reading the repository-uri from the WorkspaceProfile based on the repository-parameter
     55         */     
     56        @Override       
     57        public String getBaseURI() {           
     58                String uri = WorkspaceProfile.getRepositoryPath(getRepository());               
     59                return uri;
     60        }
     61       
     62        /**
     63         * A mapping between the actionkeys in the request and the operation-parameter expected by the MD!Repository
     64         * FIXME: This is taken from MDRepoProxyAction - so it will not work for SRU and Pazpar2
     65         */
     66        private final static HashMap<String,String> urls = new HashMap<String,String>();
     67         static
     68         {       urls.put("collection", "?operation=getCollections&collection=");
     69                 urls.put("model", "?operation=queryModel&q=");
     70                 urls.put("values", "?operation=scanIndex&q=");
     71                 urls.put("search", "?operation=searchRetrieve&query=");
     72                 urls.put("record", "?operation=searchRetrieve&query=");
     73         }
     74
    5175       
    5276        //TODO remove - just for tests
     
    161185               
    162186        }
    163        
    164         @Override
     187 
     188         public String fullQueryString(){
     189                String full_query_string= this.getQ();
     190                       
     191                if (!getSquery().equals("") && !this.getQ().equals("")){
     192                                full_query_string = "(" + this.getSquery() + " ) and (" + this.getQ() + ")";
     193                        } else if (!this.getSquery().equals("")) {
     194                                full_query_string = this.getSquery();
     195                        } else if (!this.getQ().equals("")){
     196                                full_query_string = this.getQ();
     197                        } else {
     198                                full_query_string = "";
     199                        }
     200               
     201                return full_query_string;
     202         }
     203         
     204
     205        /**
     206         * uses base_url + url_pattern (parametrized by actionkey) to form a url
     207         * @return the URL to the component-file
     208         * @throws Exception
     209         */
     210         @Override
    165211        public URL getTargetRequest() throws IOException {
     212        // URL targetURL =new URL( base_url, compname + ".xml");
     213               
     214                Admin.notifyUser("RPA.getQ:" + getSquery() + " and (" +  getQ() + ")");
     215                Admin.notifyUser("RPA.getActionkey:" + getActionkey());         
     216               
     217                Query query = new Query(getSquery(), getQ(),getActionkey());
     218
     219        // check if the query could get parsed
     220                if (query.isStatus(Query.PARSEERROR)) {
     221                        Admin.notifyUser("RPA.query.PARSEERROR:" + query.getMsg());
     222                        // pass this bad news to the client
     223                        setUserMsg(query.getMsg());
     224                        return null;
     225                } else {
     226                        query.setMaxdepth(getMaxdepth());               
     227                        query.setCollection(getCollection());
     228                        query.setColumns(getColumns());
     229                        query.setMaximumItems(getMaximumItems());
     230                        query.setStartItem(getStartItem());
     231                        query.setOptions(getOptions());
     232                        query.setSort(getSort());
     233               
     234                        URL targetURL = null;
     235                        targetURL =new URL( getBaseURL(), urls.get(getActionkey()) + query.toURLParam() );
     236                        Admin.notifyUser("RPA.targetURL.query.toURLParam:" + query.toURLParam());
     237                        Admin.notifyUser("RPA.targetURL:" + targetURL);
     238                return targetURL;
     239                }
     240        }
     241
     242
     243
     244/*      @Override
     245        public URL getTargetRequest() throws IOException {
     246 
    166247                switch (WorkspaceProfile.RepositoryType.toRepositoryType(WorkspaceProfile.getRepositoryType(getRepository())))
    167248                {
     
    181262                }
    182263        }
    183 }
     264        */
     265}       
  • MDService2/branches/MDService_simple/src/eu/clarin/cmdi/mdservice/model/Query.java

    r1489 r1508  
    3535        public static String MODEL = "model";
    3636        public static String VALUES = "values";
    37         public static String RECORDSET = "recordset";
     37        public static String RECORDSET = "search";
    3838        public static String RECORD = "record";
    3939        public static String SRUEXTERN = "sruextern";
  • MDService2/branches/MDService_simple/src/struts.xml

    r1506 r1508  
    1212        <package name="basicstruts2" extends="struts-default">
    1313
    14                 <default-action-ref name="index" />
     14                <default-action-ref name="catchall" />
    1515                               
    1616                <global-results>
     
    4848                </action>
    4949-->
    50                 <action name="/?*" class="eu.clarin.cmdi.mdservice.action.StaticAction" method="execute">
     50        <!--    <action name="/?*" class="eu.clarin.cmdi.mdservice.action.StaticAction" method="execute">
    5151                           <param name="actionkey">static</param>
    5252                           <param name="format">htmlpage</param>
     
    5757                            </result>
    5858                </action>
    59                
     59                -->
    6060                <action name="index" class="eu.clarin.cmdi.mdservice.action.StaticAction" method="execute">
    6161                           <param name="actionkey">static</param>
     
    6868                </action>
    6969
     70                <action name="catchall" class="eu.clarin.cmdi.mdservice.action.StaticAction" method="execute">
     71                           <param name="actionkey">static</param>
     72                           <param name="format">htmlpage</param>
     73                           <param name="q">catchall</param>                       
     74                           <param name="userMsg">Invalid request!</param>
     75                            <result type="stream">                         
     76                                <param name="contentType">${getActionContentType()}</param>
     77                                <param name="inputName">resultStream</param>                           
     78                            </result>
     79                </action>
    7080        <action name="static/*" class="eu.clarin.cmdi.mdservice.action.StaticAction" method="execute">
    7181                           <param name="format">htmlpage</param>
     
    212222                </action>
    213223               
    214                 <action name="search/*" class="eu.clarin.cmdi.mdservice.action.RepoProxyAction" method="execute">
    215                            <param name="actionkey">search</param>
    216                            <param name="q">{1}</param>
    217                             <result type="stream">                         
    218                                 <param name="contentType">${getActionContentType()}</param>
    219                                 <param name="inputName">resultStream</param>                           
    220                             </result>
    221                 </action>
    222                         </package>
     224                <action name="model/*" class="eu.clarin.cmdi.mdservice.action.RepoProxyAction" method="execute">
     225                        <param name="q">{1}</param>
     226                           <param name="actionkey">model</param>                           
     227                            <result type="stream">                         
     228                                <param name="contentType">${getActionContentType()}</param>
     229                                <param name="inputName">resultStream</param>                           
     230                            </result>
     231                </action>
     232
     233                <action name="search/*" class="eu.clarin.cmdi.mdservice.action.RepoProxyAction" method="execute">
     234                           <param name="q">{*}</param>
     235                           <param name="actionkey">search</param>                         
     236                            <result type="stream">                         
     237                                <param name="contentType">${getActionContentType()}</param>
     238                                <param name="inputName">resultStream</param>                           
     239                            </result>
     240                </action>
     241               
     242                <action name="record/*" class="eu.clarin.cmdi.mdservice.action.RepoProxyAction" method="execute">
     243                           <param name="q">{1}</param>
     244                           <param name="actionkey">record</param>                         
     245                            <result type="stream">                         
     246                                <param name="contentType">${getActionContentType()}</param>
     247                                <param name="inputName">resultStream</param>                           
     248                            </result>
     249                </action>
     250
     251               
     252        </package>
    223253
    224254</struts>
  • MDService2/branches/MDService_simple/src/xsl/cmd_functions.xsl

    r1503 r1508  
    189189                        </xsl:when>
    190190                        <xsl:when test="$q=''">
    191                                 <xsl:value-of select="concat($base_dir, '/',$action, '/', $format, '/')" />
     191                                <xsl:value-of select="concat($base_dir, '/',$action, '/?format=', $format)" />
    192192                        </xsl:when>                     
    193193                        <xsl:otherwise>
    194                                 <xsl:value-of select="concat($base_dir, '/',$action, '/', $format, '/?q=', $q, '&amp;repository=', $repository_name)" />
     194                                <xsl:value-of select="concat($base_dir, '/',$action, '/?format=', $format, '&amp;', $q, '&amp;repository=', $repository_name)" />
    195195                        </xsl:otherwise>
    196196                </xsl:choose>
  • MDService2/branches/MDService_simple/src/xsl/html_snippets.xsl

    r1504 r1508  
    5656                                                        </xsl:otherwise>
    5757                                                </xsl:choose>                                                                                                   
    58                                                 <a target="_blank" href="docs/htmlpage/info" > docs</a>
     58                                                <a target="_blank" href="static/info" > docs</a>
    5959                                </div>
    6060                                <div id="notify" class="cmds-elem-plus note" >
Note: See TracChangeset for help on using the changeset viewer.