Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

svn commit: r344088 - /lenya/trunk/src/java/org/apache/lenya/cms/publicatio: msg#00044

cms.lenya.cvs

Subject: svn commit: r344088 - /lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourceTypeImpl.java

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>
Google Custom Search

Recently Viewed:
qplus.devel/200...    network.jabber....    debian.qa-packa...    encryption.gpg....    python.dabo.dev...    uclinux.devel/2...    science.mathema...    recreation.pesc...    kernel.ck/2004-...    mozilla.devel.e...    tex.latex.prosp...    ietf.multi6/200...    bbc.cvs/2002-11...    xfree86.newbie/...    jakarta.taglibs...    altlinux.hardwa...    comedi/2002-05/...    horde.bugs/2004...    games.diplomacy...    finance.e-gold....    web.dom.test-su...    lang.ruby.rails...    os.netbsd.devel...    video.gstreamer...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive 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

Navigation