[jboss-svn-commits] JBL Code SVN: r26949 - labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/files.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jun 12 08:42:00 EDT 2009
Author: Rikkola
Date: 2009-06-12 08:42:00 -0400 (Fri, 12 Jun 2009)
New Revision: 26949
Modified:
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/files/AssetFileServlet.java
Log:
GUVNOR-360 : "Upload model" button works even when no file is chosen
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/files/AssetFileServlet.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/files/AssetFileServlet.java 2009-06-12 12:16:52 UTC (rev 26948)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/files/AssetFileServlet.java 2009-06-12 12:42:00 UTC (rev 26949)
@@ -1,4 +1,5 @@
package org.drools.guvnor.server.files;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -15,8 +16,6 @@
* limitations under the License.
*/
-
-
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -25,6 +24,7 @@
import javax.servlet.http.HttpServletResponse;
import org.drools.guvnor.client.common.HTMLFileManagerFields;
+import org.drools.guvnor.client.rpc.DetailedSerializableException;
import org.drools.guvnor.server.util.FormData;
/**
@@ -37,7 +37,6 @@
private static final long serialVersionUID = 400L;
-
/**
* Posting accepts content of various types -
* may be an attachement for an asset, or perhaps a repository import to process.
@@ -51,7 +50,7 @@
if ( uploadItem.getFile() != null && uploadItem.getUuid() != null ) {
//attaching to an asset.
- response.getWriter().write( processAttachFileToAsset(uploadItem) );
+ response.getWriter().write( processAttachFileToAsset( uploadItem ) );
return;
}
@@ -69,35 +68,40 @@
String uuid = req.getParameter( HTMLFileManagerFields.FORM_FIELD_UUID );
if ( uuid != null ) {
- processAttachmentDownload( uuid, res );
+ processAttachmentDownload( uuid,
+ res );
} else {
res.sendError( HttpServletResponse.SC_BAD_REQUEST );
}
}
-
- private void processAttachmentDownload(String uuid, HttpServletResponse response) throws IOException {
+ private void processAttachmentDownload(String uuid,
+ HttpServletResponse response) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
- String filename = getFileManager().loadFileAttachmentByUUID( uuid, output );
+ String filename = getFileManager().loadFileAttachmentByUUID( uuid,
+ output );
-
response.setContentType( "application/x-download" );
response.setHeader( "Content-Disposition",
- "attachment; filename=" + filename + ";");
+ "attachment; filename=" + filename + ";" );
response.setContentLength( output.size() );
response.getOutputStream().write( output.toByteArray() );
response.getOutputStream().flush();
}
-
private String processAttachFileToAsset(FormData uploadItem) throws IOException {
FileManagerUtils manager = getFileManager();
+
+ // If the file it doesn't exist.
+ if ( "".equals( uploadItem.getFile().getName() ) ) {
+ throw new IOException( "No file selected.");
+ }
+
manager.attachFile( uploadItem );
uploadItem.getFile().getInputStream().close();
return "OK";
}
-
}
\ No newline at end of file
More information about the jboss-svn-commits
mailing list