|
|
Choosing A Webhost: |
svn commit: r344088 - /lenya/trunk/src/java/org/apache/lenya/cms/publicatio: msg#00044cms.lenya.cvs
Author: andreas Date: Mon Nov 14 01:16:23 2005 New Revision: 344088 URL: http://svn.apache.org/viewcvs?rev=344088&view=rev Log: Throw comprehensible exception when a resource type does not support a particular format. Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourceTypeImpl.java Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourceTypeImpl.java URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourceTypeImpl.java?rev=344088&r1=344087&r2=344088&view=diff ============================================================================== --- lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourceTypeImpl.java (original) +++ lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourceTypeImpl.java Mon Nov 14 01:16:23 2005 @@ -91,13 +91,14 @@ // determine the sample content locations. if (creatorConf != null) { Configuration[] samplesConf = creatorConf.getChildren(SAMPLE_NAME); - for(int i=0; i<samplesConf.length; i++) { - if (samplesConf[i].getAttributeNames().length > 0) - this.sampleUris.put(samplesConf[i].getAttribute(SAMPLE_NAME_ATTRIBUTE),samplesConf[i].getValue()); - else { //default sample doesn't have name attribute - this.sampleUri = samplesConf[i].getValue(); - this.defaultSampleUri = samplesConf[i].getValue(); - } + for (int i = 0; i < samplesConf.length; i++) { + if (samplesConf[i].getAttributeNames().length > 0) + this.sampleUris.put(samplesConf[i].getAttribute(SAMPLE_NAME_ATTRIBUTE), + samplesConf[i].getValue()); + else { // default sample doesn't have name attribute + this.sampleUri = samplesConf[i].getValue(); + this.defaultSampleUri = samplesConf[i].getValue(); + } } } @@ -108,14 +109,14 @@ xPaths.add(xPath); } this.linkAttributeXPaths = (String[]) xPaths.toArray(new String[xPaths.size()]); - + Configuration[] formatConfigs = config.getChildren(ELEMENT_FORMAT); for (int i = 0; i < formatConfigs.length; i++) { String name = formatConfigs[i].getAttribute(ATTRIBUTE_NAME); String uri = formatConfigs[i].getAttribute(ATTRIBUTE_URI); this.formats.put(name, new Format(uri)); } - + } catch (Exception e) { throw new ConfigurationException("Configuring resource type failed: ", e); } @@ -140,22 +141,22 @@ } public String[] getSampleNames() { - String[] names = new String[this.sampleUris.size()]; - Iterator it = this.sampleUris.keySet().iterator(); - int count=0; - while (it.hasNext()) { + String[] names = new String[this.sampleUris.size()]; + Iterator it = this.sampleUris.keySet().iterator(); + int count = 0; + while (it.hasNext()) { names[count++] = (String) it.next(); } - return names; + return names; } - + public void setSampleURI(String name) { - if (name.length() > 0 && this.sampleUris.containsKey(name)) - this.sampleUri = (String) this.sampleUris.get(name); + if (name.length() > 0 && this.sampleUris.containsKey(name)) + this.sampleUri = (String) this.sampleUris.get(name); else - this.sampleUri = new String(this.defaultSampleUri); + this.sampleUri = new String(this.defaultSampleUri); } - + public String getSampleURI() { return this.sampleUri; } @@ -173,7 +174,7 @@ public String getName() { return this.name; } - + private Map formats = new HashMap(); public String[] getFormats() { @@ -182,16 +183,22 @@ } public String getFormatURI(String format) { + + if (!this.formats.containsKey(format)) { + throw new RuntimeException("The resource type [" + getName() + + "] does not support the format [" + format + "]."); + } + return ((Format) this.formats.get(format)).getURI(); } - + /** * A format. */ public static class Format { - + private String uri; - + /** * Ctor. * @param uri The uri. @@ -199,14 +206,14 @@ public Format(String uri) { this.uri = uri; } - + /** * @return The uri. */ public String getURI() { return this.uri; } - + } }
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | svn commit: r344087 - in /lenya/trunk/src: java/org/apache/lenya/cms/ac/ java/org/apache/lenya/cms/cocoon/components/context/ webapp/WEB-INF/, andreas |
|---|---|
| Next by Date: | svn commit: r344089 - /lenya/trunk/src/modules/search/config/module.xconf, andreas |
| Previous by Thread: | svn commit: r344087 - in /lenya/trunk/src: java/org/apache/lenya/cms/ac/ java/org/apache/lenya/cms/cocoon/components/context/ webapp/WEB-INF/, andreas |
| Next by Thread: | svn commit: r344089 - /lenya/trunk/src/modules/search/config/module.xconf, andreas |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |