Author: trong.tran
Date: 2011-09-16 05:06:42 -0400 (Fri, 16 Sep 2011)
New Revision: 7451
Modified:
portal/trunk/component/portal/src/main/java/conf/gatein-nodetypes.xml
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/importer/Imported.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/AbstractDataImportTest.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/AbstractImportTest.java
Log:
GTNPORTAL-2104 Use enum to present the data import status
Modified: portal/trunk/component/portal/src/main/java/conf/gatein-nodetypes.xml
===================================================================
--- portal/trunk/component/portal/src/main/java/conf/gatein-nodetypes.xml 2011-09-16
06:17:30 UTC (rev 7450)
+++ portal/trunk/component/portal/src/main/java/conf/gatein-nodetypes.xml 2011-09-16
09:06:42 UTC (rev 7451)
@@ -22,7 +22,7 @@
<supertypes>
</supertypes>
<propertyDefinitions>
- <propertyDefinition name="gtn:status" requiredType="String"
autoCreated="false" mandatory="false" onParentVersion="COPY"
protected="false" multiple="false">
+ <propertyDefinition name="gtn:status" requiredType="int"
autoCreated="false" mandatory="false" onParentVersion="COPY"
protected="false" multiple="false">
<valueConstraints/>
</propertyDefinition>
<propertyDefinition name="gtn:creationdate"
requiredType="Date" autoCreated="false" mandatory="false"
onParentVersion="COPY" protected="false"
multiple="false">
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java 2011-09-16
06:17:30 UTC (rev 7450)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java 2011-09-16
09:06:42 UTC (rev 7451)
@@ -31,6 +31,7 @@
import org.exoplatform.portal.config.model.NavigationFragment;
import org.exoplatform.portal.mop.importer.ImportMode;
import org.exoplatform.portal.mop.importer.Imported;
+import org.exoplatform.portal.mop.importer.Imported.Status;
import org.exoplatform.portal.mop.importer.NavigationImporter;
import org.exoplatform.portal.mop.importer.PageImporter;
import org.exoplatform.portal.mop.importer.PortalConfigImporter;
@@ -194,7 +195,7 @@
Workspace workspace = session.getWorkspace();
Imported imported = workspace.adapt(Imported.class);
imported.setLastModificationDate(new Date());
- imported.setStatus(Imported.DONE);
+ imported.setStatus(Status.DONE.status());
session.save();
}
finally
@@ -236,7 +237,8 @@
else
{
Imported imported = workspace.adapt(Imported.class);
- perform = Imported.WANT_REIMPORT.equals(imported.getStatus());
+ Status status = Status.getStatus(imported.getStatus());
+ perform = (Status.WANT_REIMPORT == status);
}
if (overrideExistingData)
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/importer/Imported.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/importer/Imported.java 2011-09-16
06:17:30 UTC (rev 7450)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/importer/Imported.java 2011-09-16
09:06:42 UTC (rev 7451)
@@ -32,16 +32,46 @@
@MixinType(name = "gtn:imported")
public abstract class Imported
{
- final public static String FAILED = "failed";
+ public enum Status {
+
+ UNKNOWN(-1),
+
+ FAILED(0),
+
+ DONE(1),
+
+ WANT_REIMPORT(2);
+
+ private final int status;
+
+ Status(int status)
+ {
+ this.status = status;
+ }
+
+ public int status()
+ {
+ return this.status;
+ }
+
+ public static Status getStatus(int status)
+ {
+ for (Status type : Status.values())
+ {
+ if (type.status() == status)
+ {
+ return type;
+ }
+ }
+
+ return UNKNOWN;
+ }
+ }
- final public static String DONE = "done";
-
- final public static String WANT_REIMPORT = "want_reimport";
-
@Property(name = "gtn:status")
- public abstract String getStatus();
+ public abstract int getStatus();
- public abstract void setStatus(String status);
+ public abstract void setStatus(int status);
@Property(name = "gtn:creationdate")
public abstract Date getCreationDate();
Modified:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/AbstractDataImportTest.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/AbstractDataImportTest.java 2011-09-16
06:17:30 UTC (rev 7450)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/AbstractDataImportTest.java 2011-09-16
09:06:42 UTC (rev 7451)
@@ -26,6 +26,7 @@
import org.exoplatform.container.component.RequestLifeCycle;
import org.exoplatform.portal.mop.importer.ImportMode;
import org.exoplatform.portal.mop.importer.Imported;
+import org.exoplatform.portal.mop.importer.Imported.Status;
import org.exoplatform.portal.pom.config.POMSessionManager;
import org.gatein.mop.api.workspace.Workspace;
@@ -194,7 +195,7 @@
POMSessionManager mgr =
(POMSessionManager)container.getComponentInstanceOfType(POMSessionManager.class);
Workspace workspace = mgr.getSession().getWorkspace();
assertTrue(workspace.isAdapted(Imported.class));
- workspace.adapt(Imported.class).setStatus(Imported.WANT_REIMPORT);
+ workspace.adapt(Imported.class).setStatus(Status.WANT_REIMPORT.status());
long creationTime1 = workspace.adapt(Imported.class).getCreationDate().getTime();
long lastModificationTime1 =
workspace.adapt(Imported.class).getLastModificationDate().getTime();
mgr.getSession().save();
Modified:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/AbstractImportTest.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/AbstractImportTest.java 2011-09-16
06:17:30 UTC (rev 7450)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/AbstractImportTest.java 2011-09-16
09:06:42 UTC (rev 7451)
@@ -27,6 +27,7 @@
import org.exoplatform.portal.mop.SiteKey;
import org.exoplatform.portal.mop.importer.ImportMode;
import org.exoplatform.portal.mop.importer.Imported;
+import org.exoplatform.portal.mop.importer.Imported.Status;
import org.exoplatform.portal.mop.navigation.NavigationContext;
import org.exoplatform.portal.mop.navigation.NavigationService;
import org.exoplatform.portal.mop.navigation.Node;
@@ -160,7 +161,7 @@
afterTwoPhaseNoOverrideReboot(root);
Workspace workspace = mgr.getSession().getWorkspace();
assertTrue(workspace.isAdapted(Imported.class));
- workspace.adapt(Imported.class).setStatus(Imported.WANT_REIMPORT);
+ workspace.adapt(Imported.class).setStatus(Status.WANT_REIMPORT.status());
mgr.getSession().save();
RequestLifeCycle.end();
bootstrap.dispose();