JBoss Portal SVN: r12419 - in branches/JBoss_Portal_Branch_2_6: cms/src/main/org/jboss/portal/cms/impl/jcr/command and 2 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2008-12-31 16:48:00 -0500 (Wed, 31 Dec 2008)
New Revision: 12419
Modified:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CMSException.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/AsyncStoreArchiveCommand.java
branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-war/WEB-INF/classes/Resource.properties
Log:
JBPORTAL-2157 - User not notified when uploading nonexisting / wrong type archive in CMS
Modified: branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CMSException.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CMSException.java 2008-12-31 21:06:30 UTC (rev 12418)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CMSException.java 2008-12-31 21:48:00 UTC (rev 12419)
@@ -30,6 +30,10 @@
{
/** The serialVersionUID */
private static final long serialVersionUID = 3646107693814633408L;
+
+ public static final int INVALID_ARCHIVE = 1;
+
+ private int errorCode = 0;
public CMSException()
{
@@ -50,6 +54,11 @@
super(cause);
}
+ public CMSException(int errorCode)
+ {
+ this.errorCode = errorCode;
+ }
+
public boolean hasPathFormatFailure()
{
boolean pathFormatFailure = false;
@@ -61,4 +70,22 @@
return pathFormatFailure;
}
+
+ public String getMessageKey()
+ {
+ String key = "";
+
+ switch(this.errorCode)
+ {
+ case INVALID_ARCHIVE:
+ key = "INVALID_ARCHIVE_MESSAGE";
+ break;
+
+ default:
+ key = "";
+ break;
+ }
+
+ return key;
+ }
}
Modified: branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/AsyncStoreArchiveCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/AsyncStoreArchiveCommand.java 2008-12-31 21:06:30 UTC (rev 12418)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/AsyncStoreArchiveCommand.java 2008-12-31 21:48:00 UTC (rev 12419)
@@ -22,10 +22,14 @@
******************************************************************************/
package org.jboss.portal.cms.impl.jcr.command;
+import java.io.File;
+import java.io.FileOutputStream;
+
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.apache.log4j.Logger;
+import org.apache.tools.zip.ZipFile;
import org.jboss.mx.util.MBeanProxy;
import org.jboss.mx.util.MBeanServerLocator;
@@ -79,16 +83,58 @@
this.user = context.getAttribute(JCRCommandContext.scope, "user");
this.approvePublishWorkflow = context.getAttribute(JCRCommandContext.scope, "approvePublishWorkflow");
+ //Validate the archive being uploaded
+ this.validateArchive();
+
Thread t = new Thread(new AsyncProcessor());
t.start();
return null;
+ }
+ catch(Exception e)
+ {
+ if(e instanceof CMSException)
+ {
+ throw (CMSException)e;
+ }
+ else
+ {
+ throw new CMSException(e);
+ }
}
+ }
+
+ private void validateArchive() throws CMSException
+ {
+ try
+ {
+ File tmpFile = this.getZipFile();
+ ZipFile zipFile = new ZipFile(tmpFile);
+ }
catch(Exception e)
{
- throw new CMSException(e);
+ throw new CMSException(CMSException.INVALID_ARCHIVE);
}
}
+
+ private File getZipFile() throws Exception
+ {
+ File zipFile = null;
+
+ zipFile = File.createTempFile("jbportal_", "_cmsimport.zip");
+ FileOutputStream fos = new FileOutputStream(zipFile.getCanonicalPath());
+ try
+ {
+ fos.write(this.archiveBytes);
+ fos.close();
+ }
+ finally
+ {
+ fos.close();
+ }
+
+ return zipFile;
+ }
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
/**
*
Modified: branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2008-12-31 21:06:30 UTC (rev 12418)
+++ branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2008-12-31 21:48:00 UTC (rev 12419)
@@ -1079,12 +1079,26 @@
if (!item.isFormField())
{
byte[] archiveBytes = item.get();
-
+
Command storearchiveCMD = CMSService.getCommandFactory().createAsyncStoreArchiveCommand(sPath, archiveBytes, sLanguage);
- CMSService.execute(storearchiveCMD);
List messages = new ArrayList();
- messages.add(this.resources.getObject("CMS_MSG_UPLOADARCHIVE_ASYNC"));
+
+ try
+ {
+ CMSService.execute(storearchiveCMD);
+ messages.add(this.resources.getObject("CMS_MSG_UPLOADARCHIVE_ASYNC"));
+ }
+ catch(CMSException cme)
+ {
+ String messageKey = cme.getMessageKey();
+ if(messageKey != null && messageKey.trim().length() > 0)
+ {
+ messages.add(this.resources.getObject(messageKey));
+ }
+ }
+
+
aReq.getPortletSession().setAttribute("messages", messages);
aRes.setRenderParameter("path", FileUtil.cleanDoubleSlashes(sPath));
Modified: branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-war/WEB-INF/classes/Resource.properties
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-war/WEB-INF/classes/Resource.properties 2008-12-31 21:06:30 UTC (rev 12418)
+++ branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-war/WEB-INF/classes/Resource.properties 2008-12-31 21:48:00 UTC (rev 12419)
@@ -149,4 +149,6 @@
CMS_DATE_PATTERN=MM/dd/yy HH:mm
+INVALID_ARCHIVE_MESSAGE=The archive being uploaded is not a valid archive file
+
15 years, 3 months
JBoss Portal SVN: r12418 - in branches/JBoss_Portal_Branch_2_7: core-cms/src/main/org/jboss/portal/core/cms/ui/admin and 1 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2008-12-31 16:06:30 -0500 (Wed, 31 Dec 2008)
New Revision: 12418
Modified:
branches/JBoss_Portal_Branch_2_7/build/build-thirdparty.xml
branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-war/WEB-INF/classes/Resource.properties
Log:
JBPORTAL-2157 - User not notified when uploading nonexisting / wrong type archive in CMS
Modified: branches/JBoss_Portal_Branch_2_7/build/build-thirdparty.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/build/build-thirdparty.xml 2008-12-31 21:05:25 UTC (rev 12417)
+++ branches/JBoss_Portal_Branch_2_7/build/build-thirdparty.xml 2008-12-31 21:06:30 UTC (rev 12418)
@@ -46,7 +46,7 @@
<componentref name="jboss-portal/modules/test" version="1.0.3"/>
<componentref name="jboss-portal/modules/portlet" version="2.0.4"/>
<componentref name="jboss-portal/modules/identity" version="1.0.5"/>
- <componentref name="jboss-portal/modules/cms" version="1.2.1"/>
+ <componentref name="jboss-portal/modules/cms" version="1.2.2"/>
<componentref name="antlr" version="2.7.6-brew"/>
<componentref name="apache-ant" version="1.6.5"/>
<componentref name="jackrabbit" version="1.4"/>
Modified: branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2008-12-31 21:05:25 UTC (rev 12417)
+++ branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2008-12-31 21:06:30 UTC (rev 12418)
@@ -1079,12 +1079,26 @@
if (!item.isFormField())
{
byte[] archiveBytes = item.get();
-
+
Command storearchiveCMD = CMSService.getCommandFactory().createAsyncStoreArchiveCommand(sPath, archiveBytes, sLanguage);
- CMSService.execute(storearchiveCMD);
List messages = new ArrayList();
- messages.add(this.resources.getObject("CMS_MSG_UPLOADARCHIVE_ASYNC"));
+
+ try
+ {
+ CMSService.execute(storearchiveCMD);
+ messages.add(this.resources.getObject("CMS_MSG_UPLOADARCHIVE_ASYNC"));
+ }
+ catch(CMSException cme)
+ {
+ String messageKey = cme.getMessageKey();
+ if(messageKey != null && messageKey.trim().length() > 0)
+ {
+ messages.add(this.resources.getObject(messageKey));
+ }
+ }
+
+
aReq.getPortletSession().setAttribute("messages", messages);
aRes.setRenderParameter("path", FileUtil.cleanDoubleSlashes(sPath));
Modified: branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-war/WEB-INF/classes/Resource.properties
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-war/WEB-INF/classes/Resource.properties 2008-12-31 21:05:25 UTC (rev 12417)
+++ branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-war/WEB-INF/classes/Resource.properties 2008-12-31 21:06:30 UTC (rev 12418)
@@ -149,4 +149,6 @@
CMS_DATE_PATTERN=MM/dd/yy HH:mm
+INVALID_ARCHIVE_MESSAGE=The archive being uploaded is not a valid archive file
+
15 years, 3 months
JBoss Portal SVN: r12417 - in modules/cms/trunk/cms-jackrabbit/src: main/java/org/jboss/portal/cms/impl/jcr/command and 1 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2008-12-31 16:05:25 -0500 (Wed, 31 Dec 2008)
New Revision: 12417
Modified:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/CMSException.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/command/AsyncStoreArchiveCommand.java
modules/cms/trunk/cms-jackrabbit/src/test/resources/jboss-unit.xml
Log:
JBPORTAL-2157 - User not notified when uploading nonexisting / wrong type archive in CMS
Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/CMSException.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/CMSException.java 2008-12-22 16:52:59 UTC (rev 12416)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/CMSException.java 2008-12-31 21:05:25 UTC (rev 12417)
@@ -30,6 +30,10 @@
{
/** The serialVersionUID */
private static final long serialVersionUID = 3646107693814633408L;
+
+ public static final int INVALID_ARCHIVE = 1;
+
+ private int errorCode = 0;
public CMSException()
{
@@ -50,6 +54,11 @@
super(cause);
}
+ public CMSException(int errorCode)
+ {
+ this.errorCode = errorCode;
+ }
+
public boolean hasPathFormatFailure()
{
boolean pathFormatFailure = false;
@@ -61,4 +70,22 @@
return pathFormatFailure;
}
+
+ public String getMessageKey()
+ {
+ String key = "";
+
+ switch(this.errorCode)
+ {
+ case INVALID_ARCHIVE:
+ key = "INVALID_ARCHIVE_MESSAGE";
+ break;
+
+ default:
+ key = "";
+ break;
+ }
+
+ return key;
+ }
}
Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/command/AsyncStoreArchiveCommand.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/command/AsyncStoreArchiveCommand.java 2008-12-22 16:52:59 UTC (rev 12416)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/command/AsyncStoreArchiveCommand.java 2008-12-31 21:05:25 UTC (rev 12417)
@@ -22,10 +22,14 @@
******************************************************************************/
package org.jboss.portal.cms.impl.jcr.command;
+import java.io.File;
+import java.io.FileOutputStream;
+
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.apache.log4j.Logger;
+import org.apache.tools.zip.ZipFile;
import org.jboss.mx.util.MBeanProxy;
import org.jboss.mx.util.MBeanServerLocator;
@@ -79,16 +83,58 @@
this.user = context.getAttribute(JCRCommandContext.scope, "user");
this.approvePublishWorkflow = context.getAttribute(JCRCommandContext.scope, "approvePublishWorkflow");
+ //Validate the archive being uploaded
+ this.validateArchive();
+
Thread t = new Thread(new AsyncProcessor());
t.start();
return null;
+ }
+ catch(Exception e)
+ {
+ if(e instanceof CMSException)
+ {
+ throw (CMSException)e;
+ }
+ else
+ {
+ throw new CMSException(e);
+ }
}
+ }
+
+ private void validateArchive() throws CMSException
+ {
+ try
+ {
+ File tmpFile = this.getZipFile();
+ ZipFile zipFile = new ZipFile(tmpFile);
+ }
catch(Exception e)
{
- throw new CMSException(e);
+ throw new CMSException(CMSException.INVALID_ARCHIVE);
}
}
+
+ private File getZipFile() throws Exception
+ {
+ File zipFile = null;
+
+ zipFile = File.createTempFile("jbportal_", "_cmsimport.zip");
+ FileOutputStream fos = new FileOutputStream(zipFile.getCanonicalPath());
+ try
+ {
+ fos.write(this.archiveBytes);
+ fos.close();
+ }
+ finally
+ {
+ fos.close();
+ }
+
+ return zipFile;
+ }
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
/**
*
Modified: modules/cms/trunk/cms-jackrabbit/src/test/resources/jboss-unit.xml
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/test/resources/jboss-unit.xml 2008-12-22 16:52:59 UTC (rev 12416)
+++ modules/cms/trunk/cms-jackrabbit/src/test/resources/jboss-unit.xml 2008-12-31 21:05:25 UTC (rev 12417)
@@ -3,9 +3,15 @@
xmlns="urn:jboss:jboss-unit:1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
- <pojo>
+ <pojo>
<parameter name="datasources" value="datasources.xml"/>
- <parameter name="dataSourceName" value="hsqldb"/>
+ <parameter name="dataSourceName">
+ <value>hsqldb</value>
+ <!--
+ <value>mysql5</value>
+ <value>postgresql8</value>
+ -->
+ </parameter>
<parameter name="hibernateConfig" value="hibernates.xml"/>
<test >
<class name="org.jboss.portal.cms.test.TestJackrabbit"/>
@@ -71,7 +77,13 @@
<pojo>
<parameter name="datasources" value="datasources.xml"/>
- <parameter name="dataSourceName" value="hsqldb"/>
+ <parameter name="dataSourceName">
+ <value>hsqldb</value>
+ <!--
+ <value>mysql5</value>
+ <value>postgresql8</value>
+ -->
+ </parameter>
<parameter name="hibernateConfig" value="hibernates.xml"/>
<parameter name="standardIdentityConfig" value="standardidentity-config.xml"/>
<parameter name="identityConfig" value="db-config.xml"/>
@@ -91,7 +103,13 @@
<pojo>
<parameter name="datasources" value="datasources.xml"/>
- <parameter name="dataSourceName" value="hsqldb"/>
+ <parameter name="dataSourceName">
+ <value>hsqldb</value>
+ <!--
+ <value>mysql5</value>
+ <value>postgresql8</value>
+ -->
+ </parameter>
<parameter name="hibernateConfig" value="hibernates.xml"/>
<parameter name="standardIdentityConfig" value="standardidentity-config.xml"/>
<parameter name="identityConfig" value="db-config.xml"/>
15 years, 3 months