Author: scottbw
Date: Wed Nov 18 17:02:48 2009
New Revision: 881835
URL: http://svn.apache.org/viewvc?rev=881835&view=rev
Log:
Added more specific exception types (and messages) for common manifest problems
with start files and content types
Added:
incubator/wookie/trunk/src/org/apache/wookie/exceptions/InvalidContentTypeException.java
incubator/wookie/trunk/src/org/apache/wookie/exceptions/InvalidStartFileException.java
Modified:
incubator/wookie/trunk/src/org/apache/wookie/WidgetAdminServlet.java
incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ContentEntity.java
incubator/wookie/trunk/src/org/apache/wookie/messages.properties
incubator/wookie/trunk/src/org/apache/wookie/messages_nl.properties
incubator/wookie/trunk/src/org/apache/wookie/util/WidgetPackageUtils.java
Modified: incubator/wookie/trunk/src/org/apache/wookie/WidgetAdminServlet.java
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/WidgetAdminServlet.java?rev=881835&r1=881834&r2=881835&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/WidgetAdminServlet.java
(original)
+++ incubator/wookie/trunk/src/org/apache/wookie/WidgetAdminServlet.java Wed
Nov 18 17:02:48 2009
@@ -36,6 +36,8 @@
import org.apache.wookie.beans.WidgetService;
import org.apache.wookie.exceptions.BadManifestException;
import org.apache.wookie.exceptions.BadWidgetZipFileException;
+import org.apache.wookie.exceptions.InvalidContentTypeException;
+import org.apache.wookie.exceptions.InvalidStartFileException;
import org.apache.wookie.helpers.WidgetKeyManager;
import org.apache.wookie.manager.IWidgetAdminManager;
import org.apache.wookie.manager.impl.WidgetAdminManager;
@@ -523,11 +525,16 @@
catch (IOException ex) {
_logger.error(ex);
session.setAttribute("error_value",
localizedMessages.getString("WidgetAdminServlet.25") + "\n" + ex.getMessage());
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
+ }
+ catch (InvalidStartFileException ex){
+ _logger.error(ex);
+ session.setAttribute("error_value",
localizedMessages.getString("WidgetAdminServlet.27") + "\n" + ex.getMessage());
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
catch (BadManifestException ex) {
_logger.error(ex);
String message = ex.getMessage();
- if (ex.getMessage() == null ||
ex.getMessage().equals("")) message =
localizedMessages.getString("WidgetAdminServlet.27"); //$NON-NLS-1$
+ if (ex.getMessage() == null ||
ex.getMessage().equals("")) message =
localizedMessages.getString("WidgetAdminServlet.28"); //$NON-NLS-1$
+ if (ex instanceof InvalidContentTypeException) message
= localizedMessages.getString("WidgetAdminServlet.30");//$NON-NLS-1$
session.setAttribute("error_value", message);
//$NON-NLS-1$
}
catch (BadWidgetZipFileException ex) {
Added:
incubator/wookie/trunk/src/org/apache/wookie/exceptions/InvalidContentTypeException.java
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/exceptions/InvalidContentTypeException.java?rev=881835&view=auto
==============================================================================
---
incubator/wookie/trunk/src/org/apache/wookie/exceptions/InvalidContentTypeException.java
(added)
+++
incubator/wookie/trunk/src/org/apache/wookie/exceptions/InvalidContentTypeException.java
Wed Nov 18 17:02:48 2009
@@ -0,0 +1,31 @@
+/**
+ *
+ */
+package org.apache.wookie.exceptions;
+
+/**
+ * Thrown when a widget manifest sets an invalid content type
+ * @author scott
+ *
+ */
+public class InvalidContentTypeException extends BadManifestException {
+
+ private static final long serialVersionUID = 1L;
+
+ public InvalidContentTypeException() {
+ super();
+ }
+
+ public InvalidContentTypeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidContentTypeException(String message) {
+ super(message);
+ }
+
+ public InvalidContentTypeException(Throwable cause) {
+ super(cause);
+ }
+
+}
Added:
incubator/wookie/trunk/src/org/apache/wookie/exceptions/InvalidStartFileException.java
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/exceptions/InvalidStartFileException.java?rev=881835&view=auto
==============================================================================
---
incubator/wookie/trunk/src/org/apache/wookie/exceptions/InvalidStartFileException.java
(added)
+++
incubator/wookie/trunk/src/org/apache/wookie/exceptions/InvalidStartFileException.java
Wed Nov 18 17:02:48 2009
@@ -0,0 +1,31 @@
+/**
+ *
+ */
+package org.apache.wookie.exceptions;
+
+/**
+ * Thrown when a widget has no valid start file
+ * @author scott
+ *
+ */
+public class InvalidStartFileException extends BadManifestException {
+
+ private static final long serialVersionUID = 1L;
+
+ public InvalidStartFileException() {
+ super();
+ }
+
+ public InvalidStartFileException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidStartFileException(String message) {
+ super(message);
+ }
+
+ public InvalidStartFileException(Throwable cause) {
+ super(cause);
+ }
+
+}
Modified:
incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ContentEntity.java
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ContentEntity.java?rev=881835&r1=881834&r2=881835&view=diff
==============================================================================
---
incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ContentEntity.java
(original)
+++
incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ContentEntity.java
Wed Nov 18 17:02:48 2009
@@ -17,6 +17,7 @@
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.apache.commons.lang.StringUtils;
import org.apache.wookie.exceptions.BadManifestException;
+import org.apache.wookie.exceptions.InvalidContentTypeException;
import org.apache.wookie.manifestmodel.IContentEntity;
import org.apache.wookie.manifestmodel.IW3CXMLConfiguration;
import org.apache.wookie.util.UnicodeUtils;
@@ -98,7 +99,7 @@
fType = IW3CXMLConfiguration.DEFAULT_MEDIA_TYPE;
} else {
// If a type attribute is specified, and is either
invalid or unsupported, we must treat it as an invalid widget
- if (!isSupportedContentType(fSrc)) throw new
BadManifestException();
+ if (!isSupportedContentType(fType)) throw new
InvalidContentTypeException();
}
}
Modified: incubator/wookie/trunk/src/org/apache/wookie/messages.properties
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/messages.properties?rev=881835&r1=881834&r2=881835&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/messages.properties (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/messages.properties Wed Nov 18
17:02:48 2009
@@ -25,9 +25,10 @@
WidgetAdminServlet.24=No file found uploaded to server
WidgetAdminServlet.25=Unable to parse the config.xml file
WidgetAdminServlet.26=test
-WidgetAdminServlet.27=Invalid Widget: No custom start file was specified, and
no default start file can be located
-WidgetAdminServlet.28=Invalid Widget: Root element of config.xml was not
"Widget"
+WidgetAdminServlet.27=Invalid Widget: No valid custom start file was
specified, and no valid default start file can be located
+WidgetAdminServlet.28=Invalid Widget: Config.xml is not a valid W3C Widgets
configuration document
WidgetAdminServlet.29=Invalid Widget: Bad zip file
+WidgetAdminServlet.30=Invalid Widget: Config.xml specifies an unsupported
content type
WidgetServiceServlet.0=No valid requestid was found.
WidgetServiceServlet.1=completed
Modified: incubator/wookie/trunk/src/org/apache/wookie/messages_nl.properties
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/messages_nl.properties?rev=881835&r1=881834&r2=881835&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/messages_nl.properties
(original)
+++ incubator/wookie/trunk/src/org/apache/wookie/messages_nl.properties Wed Nov
18 17:02:48 2009
@@ -25,9 +25,10 @@
WidgetAdminServlet.24=No file found uploaded to server(dutch)
WidgetAdminServlet.25=Unable to parse the config.xml file(dutch)
WidgetAdminServlet.26=Test
-WidgetAdminServlet.27=Invalid Widget: No custom start file was specified, and
no default start file can be located(dutch)
-WidgetAdminServlet.28=Invalid Widget: Root element of config.xml was not
"Widget"(dutch)
+WidgetAdminServlet.27=Invalid Widget: No valid custom start file was
specified, and no valid default start file can be located(dutch)
+WidgetAdminServlet.28=Invalid Widget: Config.xml is not a valid W3C Widgets
configuration document(dutch)
WidgetAdminServlet.29=Invalid Widget: Bad zip file(dutch)
+WidgetAdminServlet.30=Invalid Widget: Config.xml specifies an unsupported
content type (dutch)
WidgetServiceServlet.0=No valid requestid was found.(dutch)
WidgetServiceServlet.1=completed(dutch)
Modified:
incubator/wookie/trunk/src/org/apache/wookie/util/WidgetPackageUtils.java
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/util/WidgetPackageUtils.java?rev=881835&r1=881834&r2=881835&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/util/WidgetPackageUtils.java
(original)
+++ incubator/wookie/trunk/src/org/apache/wookie/util/WidgetPackageUtils.java
Wed Nov 18 17:02:48 2009
@@ -37,6 +37,7 @@
import org.apache.log4j.Logger;
import org.apache.wookie.exceptions.BadManifestException;
import org.apache.wookie.exceptions.BadWidgetZipFileException;
+import org.apache.wookie.exceptions.InvalidStartFileException;
import org.apache.wookie.manifestmodel.IManifestModel;
import org.apache.wookie.manifestmodel.IW3CXMLConfiguration;
@@ -57,7 +58,7 @@
* @throws BadWidgetZipFileException if a custom start file is
specified, but is not present
* @throws BadManifestException if no custom start file is found, and
no default start file can be located
*/
- public static String locateStartFile(IManifestModel widgetModel,
ZipFile zip) throws BadWidgetZipFileException, BadManifestException{
+ public static String locateStartFile(IManifestModel widgetModel,
ZipFile zip) throws BadWidgetZipFileException, InvalidStartFileException{
String startFile = null;
// Check for a custom start file
if (widgetModel.getContent() != null) {
@@ -74,7 +75,7 @@
}
// If no start file has been found, throw an exception
if (startFile == null)
- throw new BadManifestException(); //$NON-NLS-1$
+ throw new InvalidStartFileException(); //$NON-NLS-1$
return startFile;
}