Changeset 1491


Ignore:
Timestamp:
08/22/11 12:35:53 (13 years ago)
Author:
gaba
Message:

workspaceprofile options

Location:
MDService2/trunk/MDService2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • MDService2/trunk/MDService2/WorkspaceProfile.xml

    r1476 r1491  
    104104         <Querysets>null</Querysets>
    105105         <Bookmarksets>null</Bookmarksets>
     106         
    106107                <created>a</created>
    107108                <lastchanged>a</lastchanged>
    108109                <profilename>a</profilename>
    109110                <username>a</username>
     111                <Options>
     112                        <pazpartimeout>10</pazpartimeout>
     113                </Options>
    110114      </WorkspaceProfile>
    111115     
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/GenericProxyAction.java

    r1488 r1491  
    4646       
    4747        private static JSONArray repositories = null;
     48        private static JSONObject wp_options = null;
    4849       
    4950        private Diagnostics diagnostics;
     
    326327        }
    327328       
     329        public JSONObject getWPOptions(){
     330                return wp_options;
     331        }
     332       
     333        public void setWPOptions(JSONObject op){
     334                GenericProxyAction.wp_options = op;
     335        }
     336       
    328337        protected URL base_url ;
    329338       
     
    484493        }
    485494       
     495        public static JSONObject createWPOptions() throws IOException, InterruptedException, TransformerException, NoStylesheetException{
     496                String path = Admin.getConfig().getProperty("workspaceprofile.path") + WorkspaceAction.WORKSPACE_FILENAME;//PROFILENAME_SERVER;
     497                File file=new File(path);
     498                InputStream in  = new BufferedInputStream( new FileInputStream(path));;
     499               
     500                MDTransformer transformer = new MDTransformer();
     501                transformer.setSrcFile(file.toURI().toURL());
     502                transformer.setParams(MDTransformer.createParamsMap("xml2json"));
     503                InputStream jsonstream = transformer.transformXML(in);
     504               
     505                JSONObject json = JSONObject.fromObject(convertStreamToString(jsonstream));
     506                JSONArray wparray = json.getJSONObject("Profiles").getJSONArray("WorkspaceProfiles");
     507                JSONObject obj = null;
     508                for (int i = 0; i < wparray.size(); ++i) {     
     509                        JSONObject wp = wparray.getJSONObject(i);
     510                        if (wp.get("Options") != null){
     511                                obj = wp.getJSONObject("Options");
     512                                break;
     513                        }
     514                }       
     515               
     516                // options as static variable
     517                return obj;
     518       
     519        }
     520       
     521        public String getWPOption(String opt_key){
     522                String option_val = null;
     523               
     524               
     525                if (wp_options == null ) {
     526                        try {
     527                                setWPOptions(GenericProxyAction.createWPOptions());
     528                        } catch (IOException e) {
     529                                // TODO Auto-generated catch block
     530                                e.printStackTrace();
     531                        } catch (InterruptedException e) {
     532                                // TODO Auto-generated catch block
     533                                e.printStackTrace();
     534                        } catch (TransformerException e) {
     535                                // TODO Auto-generated catch block
     536                                e.printStackTrace();
     537                        } catch (NoStylesheetException e) {
     538                                // TODO Auto-generated catch block
     539                                e.printStackTrace();
     540                        }
     541                }
     542                // static options
     543                if (wp_options != null){
     544                        net.sf.json.JSONObject json = getWPOptions();
     545                        option_val = json.getString(opt_key);
     546                }
     547               
     548               
     549                return option_val;
     550               
     551        }
    486552       
    487553        public String getRepositoryPath(){
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/Pz2ProxyAction.java

    r1488 r1491  
    189189               
    190190                InputStream is = null;
    191                
     191                // TODO param settings
    192192                //init
    193193                setCommand("init");
     
    203203                setSort("relevance");
    204204                setBlock("1");
     205                //TODO timeout  settings
     206                long startMillis = System.currentTimeMillis();
     207                long timeout = 0;
     208                if (this.getWPOption("pazpartimeout") == null){
     209                        timeout = 1000;
     210                } else {
     211                        timeout = Integer.parseInt(this.getWPOption("pazpartimeout"));
     212                }
    205213                while (Integer.parseInt(activeclients) > 0){
    206214                        //activeclients = getDocumentData(this.getSourceStream(), "//show/activeclients");
    207215                        is = this.getSourceStream();
    208216                        activeclients = getDocumentData(is, "//show/activeclients");
    209                        
     217                        Thread.sleep(1000);
     218                        Admin.notifyUser("ActiveClients: " + activeclients, Admin.DEBUG);
     219                        if ((System.currentTimeMillis() - startMillis) > timeout) {
     220                                break;
     221                        }
    210222                }
    211223                is = this.getSourceStream();
Note: See TracChangeset for help on using the changeset viewer.