Changeset 1536 for MDService2
- Timestamp:
- 09/14/11 11:01:58 (13 years ago)
- 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 8 8 import eu.clarin.cmdi.mdservice.internal.Cache; 9 9 import eu.clarin.cmdi.mdservice.internal.MDTransformer; 10 import eu.clarin.cmdi.mdservice.model.Diagnostic; 11 import eu.clarin.cmdi.mdservice.model.WorkspaceProfile; 12 import eu.clarin.cmdi.mdservice.proxy.BasicProxy; 13 import eu.clarin.cmdi.mdservice.proxy.MDRepoProxy; 14 import eu.clarin.cmdi.mdservice.proxy.Pz2Proxy; 15 import eu.clarin.cmdi.mdservice.proxy.SRUProxy; 10 16 11 17 /** … … 18 24 * 19 25 */ 20 public class CompRegistryProxyAction extends Generic ProxyAction {26 public class CompRegistryProxyAction extends GenericAction { 21 27 22 28 private static final long serialVersionUID = 1L; … … 46 52 } 47 53 48 @Override54 //@Override 49 55 public String getProxyKey() { 50 56 return proxy_key; 57 } 58 59 public void setTargetProxy(){ 60 61 setTargetProxy(new BasicProxy()); 62 51 63 } 52 64 … … 83 95 key +="//-" ; 84 96 85 if (getStart Item()!=null) {86 key += getStart Item() + "//-";97 if (getStartRecord()!=null) { 98 key += getStartRecord() + "//-"; 87 99 } 88 100 else{ 89 101 key +="//-" ; 90 102 } 91 if (getMaximum Items()!=null) {92 key += getMaximum Items() + "//-";103 if (getMaximumRecords()!=null) { 104 key += getMaximumRecords() + "//-"; 93 105 } 94 106 else{ … … 120 132 super.prepare(); 121 133 } else { 134 loadParams(); 135 setTargetProxy(); 136 getTargetProxy().checkParams(); 137 122 138 // Admin.notifyUser("CRPA.prepareSourceStream - elements"); 123 139 String xcid; … … 143 159 // Admin.notifyUser("CCCRPA." + getFullFormat()); 144 160 MDTransformer transformer = new MDTransformer(); 145 transformer.setSrcFile(getTarget Request());161 transformer.setSrcFile(getTargetProxy().getTargetRequest()); 146 162 //transformer.setParams(createTransformerParams()); 147 163 _sourceStream = transformer.transformXML(__sourceStream);//, getFullFormat(),null,null,null,null,null,null); … … 171 187 // set URL as srcFile (for MDTransformer to pass to xsl-scripts) 172 188 MDTransformer transformer = new MDTransformer(); 173 transformer.setSrcFile(getTarget Request());189 transformer.setSrcFile(getTargetProxy().getTargetRequest()); 174 190 //transformer.setParams(MDTransformer.createParamsMap(getFullFormat())); 175 191 _resultStream = transformer.transformXML(_sourceStream);//, getFullFormat()); … … 208 224 * @throws Exception 209 225 */ 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 /* 210 238 public URL getTargetRequest() throws IOException { 211 239 // URL targetURL =new URL( base_url, compname + ".xml"); 212 240 URL targetURL = null; 213 241 if (compid==null || compid.equals("")) { 214 targetURL =new URL( getBaseURL(), getActionkey() );215 } else { 216 targetURL =new URL( get BaseURL(), 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); 217 245 } 218 246 // Admin.notifyUser("CompReg.targetURL:" + targetURL); … … 221 249 return targetURL; 222 250 } 251 */ 223 252 224 253 -
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/DCRProxyAction.java
r1512 r1536 22 22 import eu.clarin.cmdi.mdservice.internal.Admin; 23 23 import eu.clarin.cmdi.mdservice.model.Termset; 24 import eu.clarin.cmdi.mdservice.proxy.BasicProxy; 24 25 25 26 /** … … 32 33 */ 33 34 34 public class DCRProxyAction extends Generic ProxyAction {35 public class DCRProxyAction extends GenericAction { 35 36 36 37 private String proxy_key = "dcregistry"; … … 74 75 return val; 75 76 } 76 77 /* 77 78 @Override 78 79 public String getProxyKey() { 79 80 return proxy_key; 80 81 } 81 82 */ 83 82 84 public String getFullFormat() { 83 85 Termset dcr = getDCR(); … … 93 95 } 94 96 97 public void setTargetProxy(){ 98 99 setTargetProxy(new BasicProxy()); 100 101 } 102 103 104 /* 95 105 public URL getBaseURL() throws MalformedURLException { 96 106 … … 101 111 return base_url; 102 112 } 103 113 */ 104 114 public String getBaseURI() { 105 115 return getDCRAttr("url"); … … 112 122 * @throws Exception 113 123 */ 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 /* 114 147 public URL getTargetRequest() throws IOException { 115 148 … … 121 154 targetURL =new URL(getBaseURI() + "?dcif-mode=all&workingLanguage=" + getLang()) ; 122 155 } 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 132 157 // Admin.notifyUser("DCRProxy.targetURL:" + targetURL); 133 158 134 159 return targetURL; 135 160 } 136 161 */ 162 /* 137 163 public InputStream getSourceStream() throws IOException { 138 164 … … 140 166 // if no arguments - get the local-config file 141 167 // FIXME: although this should be competence of TermsProxyAction 168 //TODO NOT integrated in PROXY 142 169 if ((getQ().equals(ALL) || getQ()==null || getQ().equals("")) && (getActionkey().equals(DATCATS))) { 143 170 log.debug("serving terms.file:" + Admin.getConfig().getProperty("terms.file")); … … 146 173 147 174 /* 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 = getTarget Request().openConnection();175 * for to get dcif/xml from DCR-server by means of content negotiation 176 URLConnection urlConnection = getTargetProxy().getTargetRequest().openConnection(); 150 177 151 178 if (getDCRAttr("format").equals("dcif")) { … … 161 188 162 189 } 163 190 */ 164 191 } -
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/GenericAction.java
r1532 r1536 5 5 import java.io.InputStream; 6 6 import java.io.StringWriter; 7 import java.net.URLConnection; 7 8 import java.util.HashMap; 8 9 import java.util.Map; … … 421 422 } 422 423 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 */489 424 490 425 /** … … 498 433 * @throws Exception This is handled by struts (is mapped to some result in struts.xml based on the Exception-Class) 499 434 */ 500 435 public String getTargetRequestParams(){ 436 return ""; 437 } 438 439 public void setRequestProperties(URLConnection urlConnection){ 440 441 } 442 501 443 public void prepare() { 502 444 -
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/proxy/BasicProxy.java
r1522 r1536 9 9 import java.net.URISyntaxException; 10 10 import java.net.URL; 11 import java.net.URLConnection; 11 12 import java.util.HashMap; 12 13 import java.io.ByteArrayInputStream; … … 117 118 public URL getTargetRequest() throws IOException { 118 119 119 URL targetURL = getBaseURL();120 URL targetURL =new URL(getBaseURI() + this.getSourceAction().getTargetRequestParams()); 120 121 121 122 log.debug("getTargetRequest().targetURL:" + targetURL); … … 125 126 126 127 public InputStream getSourceStream() throws IOException, NoStylesheetException { 127 return getTargetRequest().openStream(); 128 URLConnection urlConnection = getTargetRequest().openConnection(); 129 getSourceAction().setRequestProperties(urlConnection); 130 return urlConnection.getInputStream();//.openStream(); 128 131 } 129 132 -
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/proxy/ProxyInterface.java
r1515 r1536 3 3 import java.io.IOException; 4 4 import java.io.InputStream; 5 import java.net.MalformedURLException; 5 6 import java.net.URL; 6 7 -
MDService2/branches/MDService_simple3/src/mdservice.properties
r1522 r1536 15 15 //?? dcregistry.uri = http://www.isocat.org/rest/ 16 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/ 17 19 virtualcollection.uri = http://clarin.ids-mannheim.de/vcr/service/virtualcollection 18 20 … … 20 22 //cache.path = /srv/tomcat6/webapps/MDService2_cache/ 21 23 //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/ 26 cache.path = C:/apache-tomcat-6.0.26/webapps/MDService2_cache/ 27 workspaceprofile.path = C:/apache-tomcat-6.0.26/webapps/MDService2_profiles/ 26 28 workspace.file = WorkspaceProfile.xml 27 29
Note: See TracChangeset
for help on using the changeset viewer.