Author: nscavell
Date: 2011-07-29 22:53:38 -0400 (Fri, 29 Jul 2011)
New Revision: 6960
Added:
portal/trunk/component/common/src/main/java/org/gatein/
portal/trunk/component/common/src/main/java/org/gatein/common/
portal/trunk/component/common/src/main/java/org/gatein/common/xml/
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/Exceptions.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/StaxNavUtils.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/StaxNavBuilder.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/StaxNavBuilderImpl.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriter.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriterImpl.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriterUtils.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/WritableValueType.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/WritableValueTypes.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxFormatterBuilder.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxFormatterBuilderImpl.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxWriterBuilder.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxWriterBuilderImpl.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/NoOpFormatter.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/SimpleFormatter.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/XmlStreamingFormatter.java
portal/trunk/component/common/src/test/java/org/gatein/
portal/trunk/component/common/src/test/java/org/gatein/common/
portal/trunk/component/common/src/test/java/org/gatein/common/xml/
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/AbstractStaxWriterTest.java
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/LocalStaxWriterTest.java
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/QualifiedStaxWriterTest.java
portal/trunk/component/management/src/main/java/org/gatein/
portal/trunk/component/management/src/main/java/org/gatein/management/
portal/trunk/component/management/src/main/java/org/gatein/management/runtime/
portal/trunk/component/management/src/main/java/org/gatein/management/runtime/ManagementBootstrap.java
portal/trunk/component/management/src/main/java/org/gatein/management/runtime/RuntimeContextImpl.java
portal/trunk/component/management/src/main/resources/conf/
portal/trunk/component/management/src/main/resources/conf/portal/
portal/trunk/component/management/src/main/resources/conf/portal/configuration.xml
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/MopBindingProvider.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshaller.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/DelimitedValueType.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Element.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Namespace.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshaller.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshaller.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshaller.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Utils.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractExportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractImportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportStrategy.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationImportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/POMSessionExportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageExportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageImportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutExportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutImportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/AbstractMopOperationHandler.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopImportResource.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopReadResource.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/Utils.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/AbstractNavigationOperationHandler.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationKey.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadConfigAsXml.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationUtils.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageOperationHandler.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageExportResource.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageKey.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadConfigAsXml.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUtils.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/AbstractSiteOperationHandler.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutExportResource.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadConfigAsXml.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteTypeReadResource.java
portal/trunk/component/portal/src/main/resources/META-INF/services/org.gatein.management.spi.ManagementExtension
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshallerTest.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshallerTest.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshallerTest.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshallerTest.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/exportimport/
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/exportimport/PageImportTaskTest.java
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-empty.xml
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-extended.xml
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-fragment.xml
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation.xml
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-empty.xml
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-homepage.xml
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-loaded.xml
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/portal.xml
Removed:
portal/trunk/component/common/src/main/java/org/gatein/common/
portal/trunk/component/common/src/main/java/org/gatein/common/xml/
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/Exceptions.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/StaxNavUtils.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/StaxNavBuilder.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/StaxNavBuilderImpl.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriter.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriterImpl.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriterUtils.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/WritableValueType.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/WritableValueTypes.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxFormatterBuilder.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxFormatterBuilderImpl.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxWriterBuilder.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxWriterBuilderImpl.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/NoOpFormatter.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/SimpleFormatter.java
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/XmlStreamingFormatter.java
portal/trunk/component/common/src/test/java/org/gatein/common/
portal/trunk/component/common/src/test/java/org/gatein/common/xml/
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/AbstractStaxWriterTest.java
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/LocalStaxWriterTest.java
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/QualifiedStaxWriterTest.java
portal/trunk/component/management/src/main/java/org/gatein/management/
portal/trunk/component/management/src/main/java/org/gatein/management/runtime/
portal/trunk/component/management/src/main/java/org/gatein/management/runtime/ManagementBootstrap.java
portal/trunk/component/management/src/main/java/org/gatein/management/runtime/RuntimeContextImpl.java
portal/trunk/component/management/src/main/resources/conf/portal/
portal/trunk/component/management/src/main/resources/conf/portal/configuration.xml
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/MopBindingProvider.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshaller.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/DelimitedValueType.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Element.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Namespace.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshaller.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshaller.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshaller.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Utils.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractExportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractImportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportStrategy.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationImportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/POMSessionExportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageExportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageImportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutExportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutImportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/AbstractMopOperationHandler.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopImportResource.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopReadResource.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/Utils.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/AbstractNavigationOperationHandler.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationKey.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadConfigAsXml.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationUtils.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageOperationHandler.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageExportResource.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageKey.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadConfigAsXml.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUtils.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/AbstractSiteOperationHandler.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutExportResource.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadConfigAsXml.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteTypeReadResource.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshallerTest.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshallerTest.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshallerTest.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshallerTest.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/exportimport/
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/exportimport/PageImportTaskTest.java
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-empty.xml
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-extended.xml
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-fragment.xml
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation.xml
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-empty.xml
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-homepage.xml
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-loaded.xml
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/portal.xml
Modified:
portal/trunk/
portal/trunk/component/common/pom.xml
portal/trunk/component/management/pom.xml
portal/trunk/component/portal/pom.xml
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java
portal/trunk/packaging/jboss-as5/pkg/pom.xml
portal/trunk/packaging/jboss-as6/pkg/pom.xml
portal/trunk/packaging/jetty/pkg/pom.xml
portal/trunk/packaging/tomcat/pkg/pom.xml
portal/trunk/pom.xml
Log:
Merging gatein-management branch
Property changes on: portal/trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /epp/portal/branches/EPP_5_1_Branch:6841
/portal/branches/branch-GTNPORTAL-1790:5864-5919
/portal/branches/branch-GTNPORTAL-1822:5938-5991
/portal/branches/branch-GTNPORTAL-1832:5993-6105
/portal/branches/branch-GTNPORTAL-1872:6327-6594
/portal/branches/branch-GTNPORTAL-1921:6597-6803
/portal/branches/decoupled-webos:6214-6243
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/branches/wsrp-extraction:5828-6031
+ /epp/portal/branches/EPP_5_1_Branch:6841
/portal/branches/branch-GTNPORTAL-1790:5864-5919
/portal/branches/branch-GTNPORTAL-1822:5938-5991
/portal/branches/branch-GTNPORTAL-1832:5993-6105
/portal/branches/branch-GTNPORTAL-1872:6327-6594
/portal/branches/branch-GTNPORTAL-1921:6597-6803
/portal/branches/decoupled-webos:6214-6243
/portal/branches/gatein-management:6920-6958
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/branches/wsrp-extraction:5828-6031
Modified: portal/trunk/component/common/pom.xml
===================================================================
--- portal/trunk/component/common/pom.xml 2011-07-30 02:15:53 UTC (rev 6959)
+++ portal/trunk/component/common/pom.xml 2011-07-30 02:53:38 UTC (rev 6960)
@@ -67,6 +67,11 @@
<groupId>org.chromattic</groupId>
<artifactId>chromattic.spi</artifactId>
</dependency>
+ <!-- Staxnav -->
+ <dependency>
+ <groupId>org.staxnav</groupId>
+ <artifactId>staxnav.core</artifactId>
+ </dependency>
<dependency>
<groupId>org.exoplatform.portal</groupId>
@@ -86,6 +91,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>1.8.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.chromattic</groupId>
<artifactId>chromattic.core</artifactId>
<scope>test</scope>
Deleted:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/Exceptions.java
===================================================================
---
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/navigator/Exceptions.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/Exceptions.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.common.xml.stax.navigator;
-
-import org.staxnav.StaxNavException;
-import org.staxnav.StaxNavigator;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class Exceptions
-{
- public static <N> StaxNavException expectedElement(StaxNavigator<N>
navigator, N expected)
- {
- return expectedElement(navigator, navigator.getNaming().getLocalPart(expected));
- }
-
- public static StaxNavException expectedElement(StaxNavigator navigator, String
expected)
- {
- StringBuilder message = new StringBuilder().append("Expected
'").append(expected)
- .append("' but found
'").append(navigator.getLocalName()).append("' instead.");
-
- return new StaxNavException(navigator.getLocation(), message.toString());
- }
-
- public static StaxNavException unexpectedElement(StaxNavigator navigator)
- {
- return new StaxNavException(navigator.getLocation(), "Unexpected element
'" + navigator.getLocalName() + "'");
- }
-
- public static StaxNavException unknownElement(StaxNavigator navigator)
- {
- return new StaxNavException(navigator.getLocation(), "Unknown element
'" + navigator.getLocalName() + "'");
- }
-
- public static StaxNavException invalidSequence(StaxNavigator navigator)
- {
- return new StaxNavException(navigator.getLocation(), "Element '" +
navigator.getLocalName() + "' is out of sequence.");
- }
-
- public static StaxNavException contentRequired(StaxNavigator navigator)
- {
- return new StaxNavException(navigator.getLocation(), "Content for element
'" + navigator.getLocalName() + "' is required.");
- }
-
- public static StaxNavException invalidParent(StaxNavigator navigator)
- {
- return new StaxNavException(navigator.getLocation(), "Invalid parent for
element '" + navigator.getLocalName() + "'");
- }
-
- public static StaxNavException unexpectedEndOfFile(StaxNavigator navigator)
- {
- return new StaxNavException(navigator.getLocation(), "Unexpected end of
file.");
- }
-}
Copied:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/Exceptions.java
(from rev 6958,
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/navigator/Exceptions.java)
===================================================================
---
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/Exceptions.java
(rev 0)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/Exceptions.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.common.xml.stax.navigator;
+
+import org.staxnav.StaxNavException;
+import org.staxnav.StaxNavigator;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class Exceptions
+{
+ public static <N> StaxNavException expectedElement(StaxNavigator<N>
navigator, N expected)
+ {
+ return expectedElement(navigator, navigator.getNaming().getLocalPart(expected));
+ }
+
+ public static StaxNavException expectedElement(StaxNavigator navigator, String
expected)
+ {
+ StringBuilder message = new StringBuilder().append("Expected
'").append(expected)
+ .append("' but found
'").append(navigator.getLocalName()).append("' instead.");
+
+ return new StaxNavException(navigator.getLocation(), message.toString());
+ }
+
+ public static StaxNavException unexpectedElement(StaxNavigator navigator)
+ {
+ return new StaxNavException(navigator.getLocation(), "Unexpected element
'" + navigator.getLocalName() + "'");
+ }
+
+ public static StaxNavException unknownElement(StaxNavigator navigator)
+ {
+ return new StaxNavException(navigator.getLocation(), "Unknown element
'" + navigator.getLocalName() + "'");
+ }
+
+ public static StaxNavException invalidSequence(StaxNavigator navigator)
+ {
+ return new StaxNavException(navigator.getLocation(), "Element '" +
navigator.getLocalName() + "' is out of sequence.");
+ }
+
+ public static StaxNavException contentRequired(StaxNavigator navigator)
+ {
+ return new StaxNavException(navigator.getLocation(), "Content for element
'" + navigator.getLocalName() + "' is required.");
+ }
+
+ public static StaxNavException invalidParent(StaxNavigator navigator)
+ {
+ return new StaxNavException(navigator.getLocation(), "Invalid parent for
element '" + navigator.getLocalName() + "'");
+ }
+
+ public static StaxNavException unexpectedEndOfFile(StaxNavigator navigator)
+ {
+ return new StaxNavException(navigator.getLocation(), "Unexpected end of
file.");
+ }
+}
Deleted:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/StaxNavUtils.java
===================================================================
---
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/navigator/StaxNavUtils.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/StaxNavUtils.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,197 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.common.xml.stax.navigator;
-
-import org.gatein.common.xml.stax.navigator.builder.StaxNavBuilder;
-import org.gatein.common.xml.stax.navigator.builder.StaxNavBuilderImpl;
-import org.staxnav.EnumElement;
-import org.staxnav.Naming;
-import org.staxnav.StaxNavException;
-import org.staxnav.StaxNavigator;
-import org.staxnav.ValueType;
-
-import javax.xml.namespace.QName;
-import java.io.InputStream;
-import java.io.Reader;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.gatein.common.xml.stax.navigator.Exceptions.*;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class StaxNavUtils
-{
- public static <N> StaxNavigator<N> createNavigator(Naming<N> naming,
InputStream in) throws StaxNavException
- {
- return buildDefaultNavigator().withInputStream(in).build(naming);
- }
-
- public static StaxNavigator<String> createNavigator(InputStream in) throws
StaxNavException
- {
- return createNavigator(new Naming.Local(), in);
- }
-
- public static StaxNavigator<QName> createQualifiedNavigator(InputStream in)
throws StaxNavException
- {
- return createNavigator(new Naming.Qualified(), in);
- }
-
- public static <E extends Enum<E> & EnumElement<E>>
StaxNavigator<E> createNavigator(Class<E> enumeratedClass,
- E
noSuchElement, InputStream in) throws StaxNavException
- {
- Naming<E> naming;
- if (EnumElement.class.isAssignableFrom(enumeratedClass))
- {
- naming = new Naming.Enumerated.Mapped<E>(enumeratedClass, noSuchElement);
- }
- else
- {
- naming = new Naming.Enumerated.Simple<E>(enumeratedClass, noSuchElement);
- }
-
- return createNavigator(naming, in);
- }
-
- public static <N> StaxNavigator<N> createNavigator(Naming<N> naming,
Reader reader) throws StaxNavException
- {
- return buildDefaultNavigator().withReader(reader).build(naming);
- }
-
- public static StaxNavigator<String> createNavigator(Reader reader) throws
StaxNavException
- {
- return createNavigator(new Naming.Local(), reader);
- }
-
- public static StaxNavigator<QName> createQualifiedNavigator(Reader reader)
throws StaxNavException
- {
- return createNavigator(new Naming.Qualified(), reader);
- }
-
- public static <E extends Enum<E> & EnumElement<E>>
StaxNavigator<E> createNavigator(Class<E> enumeratedClass,
- E
noSuchElement, Reader reader) throws StaxNavException
- {
- Naming<E> naming;
- if (EnumElement.class.isAssignableFrom(enumeratedClass))
- {
- naming = new Naming.Enumerated.Mapped<E>(enumeratedClass, noSuchElement);
- }
- else
- {
- naming = new Naming.Enumerated.Simple<E>(enumeratedClass, noSuchElement);
- }
-
- return createNavigator(naming, reader);
- }
-
- public static <N> void requiresChild(StaxNavigator<N> navigator, N
element)
- {
- if (navigator.child() != element)
- {
- throw expectedElement(navigator, element);
- }
- }
-
- public static <N> void requiresSibling(StaxNavigator<N> navigator, N
element)
- {
- if (!navigator.sibling(element))
- {
- throw expectedElement(navigator, element);
- }
- }
-
- public static String getRequiredAttribute(StaxNavigator navigator, String
attributeName) throws StaxNavException
- {
- String value = navigator.getAttribute(attributeName);
- if (value == null)
- {
- throw new StaxNavException(navigator.getLocation(), "Attribute '"
+ attributeName + "' is required for element '" +
navigator.getLocalName() + "'");
- }
-
- return value;
- }
-
- public static <N> String getContent(StaxNavigator<N> navigator, boolean
trim)
- {
- boolean before = navigator.getTrimContent();
- try
- {
- navigator.setTrimContent(trim);
- return navigator.getContent();
- }
- finally
- {
- navigator.setTrimContent(before);
- }
- }
-
- public static <N> String getRequiredContent(StaxNavigator<N> navigator,
boolean trim)
- {
- String content = getContent(navigator, trim);
- if (content == null || content.length() == 0)
- {
- throw contentRequired(navigator);
- }
-
- return content;
- }
-
- public static <N, V> V parseContent(StaxNavigator<N> navigator,
ValueType<V> valueType, V defaultValue)
- {
- String content = getContent(navigator, true);
- if (content != null && content.length() != 0)
- {
- return navigator.parseContent(valueType);
- }
- else
- {
- return defaultValue;
- }
- }
-
- public static <N, V> V parseRequiredContent(StaxNavigator<N> navigator,
ValueType<V> valueType)
- {
- V value = parseContent(navigator, valueType, null);
- if (value == null)
- {
- throw contentRequired(navigator);
- }
-
- return value;
- }
-
- public static <N> Set<N> forNames(N...names)
- {
- return new HashSet<N>(Arrays.asList(names));
- }
-
- private static StaxNavBuilder buildDefaultNavigator()
- {
- return new StaxNavBuilderImpl();
- }
-
- private StaxNavUtils() {}
-}
Copied:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/StaxNavUtils.java
(from rev 6958,
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/navigator/StaxNavUtils.java)
===================================================================
---
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/StaxNavUtils.java
(rev 0)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/StaxNavUtils.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,197 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.common.xml.stax.navigator;
+
+import org.gatein.common.xml.stax.navigator.builder.StaxNavBuilder;
+import org.gatein.common.xml.stax.navigator.builder.StaxNavBuilderImpl;
+import org.staxnav.EnumElement;
+import org.staxnav.Naming;
+import org.staxnav.StaxNavException;
+import org.staxnav.StaxNavigator;
+import org.staxnav.ValueType;
+
+import javax.xml.namespace.QName;
+import java.io.InputStream;
+import java.io.Reader;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.gatein.common.xml.stax.navigator.Exceptions.*;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class StaxNavUtils
+{
+ public static <N> StaxNavigator<N> createNavigator(Naming<N> naming,
InputStream in) throws StaxNavException
+ {
+ return buildDefaultNavigator().withInputStream(in).build(naming);
+ }
+
+ public static StaxNavigator<String> createNavigator(InputStream in) throws
StaxNavException
+ {
+ return createNavigator(new Naming.Local(), in);
+ }
+
+ public static StaxNavigator<QName> createQualifiedNavigator(InputStream in)
throws StaxNavException
+ {
+ return createNavigator(new Naming.Qualified(), in);
+ }
+
+ public static <E extends Enum<E> & EnumElement<E>>
StaxNavigator<E> createNavigator(Class<E> enumeratedClass,
+ E
noSuchElement, InputStream in) throws StaxNavException
+ {
+ Naming<E> naming;
+ if (EnumElement.class.isAssignableFrom(enumeratedClass))
+ {
+ naming = new Naming.Enumerated.Mapped<E>(enumeratedClass, noSuchElement);
+ }
+ else
+ {
+ naming = new Naming.Enumerated.Simple<E>(enumeratedClass, noSuchElement);
+ }
+
+ return createNavigator(naming, in);
+ }
+
+ public static <N> StaxNavigator<N> createNavigator(Naming<N> naming,
Reader reader) throws StaxNavException
+ {
+ return buildDefaultNavigator().withReader(reader).build(naming);
+ }
+
+ public static StaxNavigator<String> createNavigator(Reader reader) throws
StaxNavException
+ {
+ return createNavigator(new Naming.Local(), reader);
+ }
+
+ public static StaxNavigator<QName> createQualifiedNavigator(Reader reader)
throws StaxNavException
+ {
+ return createNavigator(new Naming.Qualified(), reader);
+ }
+
+ public static <E extends Enum<E> & EnumElement<E>>
StaxNavigator<E> createNavigator(Class<E> enumeratedClass,
+ E
noSuchElement, Reader reader) throws StaxNavException
+ {
+ Naming<E> naming;
+ if (EnumElement.class.isAssignableFrom(enumeratedClass))
+ {
+ naming = new Naming.Enumerated.Mapped<E>(enumeratedClass, noSuchElement);
+ }
+ else
+ {
+ naming = new Naming.Enumerated.Simple<E>(enumeratedClass, noSuchElement);
+ }
+
+ return createNavigator(naming, reader);
+ }
+
+ public static <N> void requiresChild(StaxNavigator<N> navigator, N
element)
+ {
+ if (navigator.child() != element)
+ {
+ throw expectedElement(navigator, element);
+ }
+ }
+
+ public static <N> void requiresSibling(StaxNavigator<N> navigator, N
element)
+ {
+ if (!navigator.sibling(element))
+ {
+ throw expectedElement(navigator, element);
+ }
+ }
+
+ public static String getRequiredAttribute(StaxNavigator navigator, String
attributeName) throws StaxNavException
+ {
+ String value = navigator.getAttribute(attributeName);
+ if (value == null)
+ {
+ throw new StaxNavException(navigator.getLocation(), "Attribute '"
+ attributeName + "' is required for element '" +
navigator.getLocalName() + "'");
+ }
+
+ return value;
+ }
+
+ public static <N> String getContent(StaxNavigator<N> navigator, boolean
trim)
+ {
+ boolean before = navigator.getTrimContent();
+ try
+ {
+ navigator.setTrimContent(trim);
+ return navigator.getContent();
+ }
+ finally
+ {
+ navigator.setTrimContent(before);
+ }
+ }
+
+ public static <N> String getRequiredContent(StaxNavigator<N> navigator,
boolean trim)
+ {
+ String content = getContent(navigator, trim);
+ if (content == null || content.length() == 0)
+ {
+ throw contentRequired(navigator);
+ }
+
+ return content;
+ }
+
+ public static <N, V> V parseContent(StaxNavigator<N> navigator,
ValueType<V> valueType, V defaultValue)
+ {
+ String content = getContent(navigator, true);
+ if (content != null && content.length() != 0)
+ {
+ return navigator.parseContent(valueType);
+ }
+ else
+ {
+ return defaultValue;
+ }
+ }
+
+ public static <N, V> V parseRequiredContent(StaxNavigator<N> navigator,
ValueType<V> valueType)
+ {
+ V value = parseContent(navigator, valueType, null);
+ if (value == null)
+ {
+ throw contentRequired(navigator);
+ }
+
+ return value;
+ }
+
+ public static <N> Set<N> forNames(N...names)
+ {
+ return new HashSet<N>(Arrays.asList(names));
+ }
+
+ private static StaxNavBuilder buildDefaultNavigator()
+ {
+ return new StaxNavBuilderImpl();
+ }
+
+ private StaxNavUtils() {}
+}
Deleted:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/StaxNavBuilder.java
===================================================================
---
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/StaxNavBuilder.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/StaxNavBuilder.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.common.xml.stax.navigator.builder;
-
-import org.staxnav.Naming;
-import org.staxnav.StaxNavException;
-import org.staxnav.StaxNavigator;
-
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.Source;
-import java.io.InputStream;
-import java.io.Reader;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public interface StaxNavBuilder
-{
- StaxNavBuilder withProperty(String name, Object value);
-
- StaxNavBuilder withPropertyIfSupported(String name, Object value);
-
- StaxNavBuilder withInputStream(InputStream inputStream);
-
- StaxNavBuilder withInputStream(InputStream inputStream, String encoding);
-
- StaxNavBuilder withReader(Reader reader);
-
- StaxNavBuilder withSource(Source source);
-
- StaxNavBuilder withXmlStreamReader(XMLStreamReader reader);
-
- <N> StaxNavigator<N> build(Naming<N> naming) throws
StaxNavException, IllegalStateException;
-}
Copied:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/StaxNavBuilder.java
(from rev 6958,
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/StaxNavBuilder.java)
===================================================================
---
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/StaxNavBuilder.java
(rev 0)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/StaxNavBuilder.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.common.xml.stax.navigator.builder;
+
+import org.staxnav.Naming;
+import org.staxnav.StaxNavException;
+import org.staxnav.StaxNavigator;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Source;
+import java.io.InputStream;
+import java.io.Reader;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public interface StaxNavBuilder
+{
+ StaxNavBuilder withProperty(String name, Object value);
+
+ StaxNavBuilder withPropertyIfSupported(String name, Object value);
+
+ StaxNavBuilder withInputStream(InputStream inputStream);
+
+ StaxNavBuilder withInputStream(InputStream inputStream, String encoding);
+
+ StaxNavBuilder withReader(Reader reader);
+
+ StaxNavBuilder withSource(Source source);
+
+ StaxNavBuilder withXmlStreamReader(XMLStreamReader reader);
+
+ <N> StaxNavigator<N> build(Naming<N> naming) throws
StaxNavException, IllegalStateException;
+}
Deleted:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/StaxNavBuilderImpl.java
===================================================================
---
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/StaxNavBuilderImpl.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/StaxNavBuilderImpl.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,203 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.common.xml.stax.navigator.builder;
-
-import org.staxnav.Naming;
-import org.staxnav.StaxNavException;
-import org.staxnav.StaxNavigator;
-import org.staxnav.StaxNavigatorFactory;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.Source;
-import java.io.InputStream;
-import java.io.Reader;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class StaxNavBuilderImpl implements StaxNavBuilder
-{
- private Object input;
- private String inputEncoding;
- private XMLStreamReader reader;
-
- private Map<String, Object> properties = new HashMap<String, Object>();
- private Map<String, Object> supportedProperties = new HashMap<String,
Object>();
-
- @Override
- public StaxNavBuilder withProperty(String name, Object value)
- {
- if (name == null) throw new IllegalArgumentException("name is null");
- if (value == null) throw new IllegalArgumentException("value is null");
-
- properties.put(name, value);
- return this;
- }
-
- @Override
- public StaxNavBuilder withPropertyIfSupported(String name, Object value)
- {
- if (name == null) throw new IllegalArgumentException("name is null");
- if (value == null) throw new IllegalArgumentException("value is null");
-
- supportedProperties.put(name, value);
- return this;
- }
-
- @Override
- public StaxNavBuilder withInputStream(InputStream inputStream)
- {
- if (inputStream == null) throw new IllegalArgumentException("inputStream is
null");
-
- input = inputStream;
- return this;
- }
-
- @Override
- public StaxNavBuilder withInputStream(InputStream inputStream, String encoding)
- {
- if (inputStream == null) throw new IllegalArgumentException("inputStream is
null");
- if (encoding == null) throw new IllegalArgumentException("encoding is
null");
-
- input = inputStream;
- inputEncoding = encoding;
- return this;
- }
-
- @Override
- public StaxNavBuilder withReader(Reader reader)
- {
- if (reader == null) throw new IllegalArgumentException("reader is
null");
-
- this.input = reader;
- return this;
- }
-
- @Override
- public StaxNavBuilder withSource(Source source)
- {
- if (source == null) throw new IllegalArgumentException("source is
null");
-
- input = source;
- return this;
- }
-
- @Override
- public StaxNavBuilder withXmlStreamReader(XMLStreamReader reader)
- {
- if (reader == null) throw new IllegalArgumentException("reader is
null");
-
- this.reader = reader;
- return this;
- }
-
- @Override
- public <N> StaxNavigator<N> build(Naming<N> naming) throws
StaxNavException, IllegalStateException
- {
- if (naming == null) throw new IllegalArgumentException("naming is
null");
-
- if (reader == null && input == null)
- throw new IllegalStateException("Cannot build stax reader. Try calling
withInputStream/withReader or pass in own XMLStreamReader.");
-
- if (reader == null)
- {
- //TODO: Create solution to properly cache XMLInputFactory
- XMLInputFactory factory = XMLInputFactory.newInstance();
-
- // Set properties
- for (Map.Entry<String, Object> entry : properties.entrySet())
- {
- factory.setProperty(entry.getKey(), entry.getValue());
- }
-
- // Set properties if supported
- for (Map.Entry<String, Object> entry : supportedProperties.entrySet())
- {
- String name = entry.getKey();
- if (factory.isPropertySupported(name))
- {
- factory.setProperty(name, entry.getValue());
- }
- }
-
- if (input instanceof InputStream)
- {
- if (inputEncoding == null)
- {
- try
- {
- reader = factory.createXMLStreamReader((InputStream) input,
inputEncoding);
- }
- catch (XMLStreamException e)
- {
- throw new StaxNavException(e);
- }
- }
- else
- {
- try
- {
- reader = factory.createXMLStreamReader((InputStream) input);
- }
- catch (XMLStreamException e)
- {
- throw new StaxNavException(null, "Exception creating
XMLStreamReader with inputStream: " + input, e);
- }
- }
- }
- else if (input instanceof Reader)
- {
- try
- {
- reader = factory.createXMLStreamReader((Reader) input);
- }
- catch (XMLStreamException e)
- {
- throw new StaxNavException(null, "Exception creating XMLStreamReader
with reader: " + input, e);
- }
- }
- else if (input instanceof Source)
- {
- try
- {
- reader = factory.createXMLStreamReader((Source) input);
- }
- catch (XMLStreamException e)
- {
- throw new StaxNavException(null, "Exception creating XMLStreamReader
with Source: " + input, e);
- }
- }
- else
- {
- throw new IllegalStateException("Unknown input: " + input); //
should never happen...
- }
- }
-
- return StaxNavigatorFactory.create(naming, reader);
- }
-}
Copied:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/StaxNavBuilderImpl.java
(from rev 6958,
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/StaxNavBuilderImpl.java)
===================================================================
---
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/StaxNavBuilderImpl.java
(rev 0)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/navigator/builder/StaxNavBuilderImpl.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,203 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.common.xml.stax.navigator.builder;
+
+import org.staxnav.Naming;
+import org.staxnav.StaxNavException;
+import org.staxnav.StaxNavigator;
+import org.staxnav.StaxNavigatorFactory;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Source;
+import java.io.InputStream;
+import java.io.Reader;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class StaxNavBuilderImpl implements StaxNavBuilder
+{
+ private Object input;
+ private String inputEncoding;
+ private XMLStreamReader reader;
+
+ private Map<String, Object> properties = new HashMap<String, Object>();
+ private Map<String, Object> supportedProperties = new HashMap<String,
Object>();
+
+ @Override
+ public StaxNavBuilder withProperty(String name, Object value)
+ {
+ if (name == null) throw new IllegalArgumentException("name is null");
+ if (value == null) throw new IllegalArgumentException("value is null");
+
+ properties.put(name, value);
+ return this;
+ }
+
+ @Override
+ public StaxNavBuilder withPropertyIfSupported(String name, Object value)
+ {
+ if (name == null) throw new IllegalArgumentException("name is null");
+ if (value == null) throw new IllegalArgumentException("value is null");
+
+ supportedProperties.put(name, value);
+ return this;
+ }
+
+ @Override
+ public StaxNavBuilder withInputStream(InputStream inputStream)
+ {
+ if (inputStream == null) throw new IllegalArgumentException("inputStream is
null");
+
+ input = inputStream;
+ return this;
+ }
+
+ @Override
+ public StaxNavBuilder withInputStream(InputStream inputStream, String encoding)
+ {
+ if (inputStream == null) throw new IllegalArgumentException("inputStream is
null");
+ if (encoding == null) throw new IllegalArgumentException("encoding is
null");
+
+ input = inputStream;
+ inputEncoding = encoding;
+ return this;
+ }
+
+ @Override
+ public StaxNavBuilder withReader(Reader reader)
+ {
+ if (reader == null) throw new IllegalArgumentException("reader is
null");
+
+ this.input = reader;
+ return this;
+ }
+
+ @Override
+ public StaxNavBuilder withSource(Source source)
+ {
+ if (source == null) throw new IllegalArgumentException("source is
null");
+
+ input = source;
+ return this;
+ }
+
+ @Override
+ public StaxNavBuilder withXmlStreamReader(XMLStreamReader reader)
+ {
+ if (reader == null) throw new IllegalArgumentException("reader is
null");
+
+ this.reader = reader;
+ return this;
+ }
+
+ @Override
+ public <N> StaxNavigator<N> build(Naming<N> naming) throws
StaxNavException, IllegalStateException
+ {
+ if (naming == null) throw new IllegalArgumentException("naming is
null");
+
+ if (reader == null && input == null)
+ throw new IllegalStateException("Cannot build stax reader. Try calling
withInputStream/withReader or pass in own XMLStreamReader.");
+
+ if (reader == null)
+ {
+ //TODO: Create solution to properly cache XMLInputFactory
+ XMLInputFactory factory = XMLInputFactory.newInstance();
+
+ // Set properties
+ for (Map.Entry<String, Object> entry : properties.entrySet())
+ {
+ factory.setProperty(entry.getKey(), entry.getValue());
+ }
+
+ // Set properties if supported
+ for (Map.Entry<String, Object> entry : supportedProperties.entrySet())
+ {
+ String name = entry.getKey();
+ if (factory.isPropertySupported(name))
+ {
+ factory.setProperty(name, entry.getValue());
+ }
+ }
+
+ if (input instanceof InputStream)
+ {
+ if (inputEncoding == null)
+ {
+ try
+ {
+ reader = factory.createXMLStreamReader((InputStream) input,
inputEncoding);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new StaxNavException(e);
+ }
+ }
+ else
+ {
+ try
+ {
+ reader = factory.createXMLStreamReader((InputStream) input);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new StaxNavException(null, "Exception creating
XMLStreamReader with inputStream: " + input, e);
+ }
+ }
+ }
+ else if (input instanceof Reader)
+ {
+ try
+ {
+ reader = factory.createXMLStreamReader((Reader) input);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new StaxNavException(null, "Exception creating XMLStreamReader
with reader: " + input, e);
+ }
+ }
+ else if (input instanceof Source)
+ {
+ try
+ {
+ reader = factory.createXMLStreamReader((Source) input);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new StaxNavException(null, "Exception creating XMLStreamReader
with Source: " + input, e);
+ }
+ }
+ else
+ {
+ throw new IllegalStateException("Unknown input: " + input); //
should never happen...
+ }
+ }
+
+ return StaxNavigatorFactory.create(naming, reader);
+ }
+}
Deleted:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriter.java
===================================================================
---
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriter.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriter.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,152 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.common.xml.stax.writer;
-
-import org.staxnav.StaxNavException;
-
-import javax.xml.namespace.QName;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public interface StaxWriter<N>
-{
- /**
- * Writes the start tag of an xml element. Requires that an element has been started
first.
- *
- * @param element element to start
- * @return StaxWriter
- * @throws org.staxnav.StaxNavException if an exception occurs
- */
- StaxWriter<N> writeStartElement(N element) throws StaxNavException;
-
- /**
- * Writes an attribute for an xml element. Requires that an element has been started
first.
- *
- * @param name the name of the attribute
- * @param value the value of the attribute
- * @return StaxWriter
- * @throws org.staxnav.StaxNavException if an exception occurs
- */
- StaxWriter<N> writeAttribute(String name, String value) throws
StaxNavException;
-
- /**
- * Writes an attribute for an xml element. Requires that an element has been started
first.
- *
- * @param name QName object representing the name of the attribute
- * @param value the value of the attribute
- * @return StaxWriter
- * @throws org.staxnav.StaxNavException if an exception occurs
- */
- StaxWriter<N> writeAttribute(QName name, String value) throws StaxNavException;
-
- /**
- * Writes xml content. Requires an xml element has been started first.
- *
- * @param content content to be written
- * @return StaxWriter
- * @throws org.staxnav.StaxNavException if an exception occurs
- */
- StaxWriter<N> writeContent(String content) throws StaxNavException;
-
- /**
- * Writes xml content based on the ValueType responsible for converting the content to
string. Requires an xml element has been started first.
- *
- * @param valueType object responsible for writing content to string
- * @param content content to be written
- * @return StaxWriter
- * @throws org.staxnav.StaxNavException if an exception occurs
- */
- <V> StaxWriter<N> writeContent(WritableValueType<V> valueType, V
content) throws StaxNavException;
-
- /**
- * Writes an end tag for the previously started element. Requires that an element has
been started first.
- *
- * @return StaxWriter
- * @throws org.staxnav.StaxNavException if an exception occurs
- */
- StaxWriter<N> writeEndElement() throws StaxNavException;
-
- /**
- * Convenience method for calling <code>writeStartElement</code>,
<code>writeContent</code>, <code>writeEndElement</code>
- *
- * @param element element to write
- * @param content content to be written
- * @return StaxWriter
- * @throws org.staxnav.StaxNavException if an exception occurs
- */
- <V> StaxWriter<N> writeElement(N element, String content) throws
StaxNavException;
-
- /**
- * Convenience method for calling <code>writeStartElement</code>,
<code>writeContent</code>, <code>writeEndElement</code>
- *
- * @param element element to write
- * @param valueType object responsible for writing content to string
- * @param content content to be written
- * @return StaxWriter
- * @throws org.staxnav.StaxNavException if an exception occurs
- */
- <V> StaxWriter<N> writeElement(N element, WritableValueType<V>
valueType, V content) throws StaxNavException;
-
- /**
- * Writes the namespace. If prefix is an empty string, "xmlns", or null this
will delegate to writeDefaultNamespace
- * @param prefix the prefix to bind the namespace to
- * @param uri the uri to bind the prefix to
- * @return StaxWriter
- * @throws org.staxnav.StaxNavException if an exception occurs
- */
- StaxWriter<N> writeNamespace(String prefix, String uri) throws
StaxNavException;
-
- /**
- * Writes the default namespace
- * @param uri the uri to bind the default namespace to
- * @return StaxWriter
- * @throws org.staxnav.StaxNavException if an exception occurs
- */
- StaxWriter<N> writeDefaultNamespace(String uri) throws StaxNavException;
-
- /**
- * Writes an xml comment
- * @param comment the comment to write
- * @return StaxWriter
- * @throws org.staxnav.StaxNavException if an exception occurs
- */
- StaxWriter<N> writeComment(String comment) throws StaxNavException;
-
- /**
- * Writes a cdata section
- * @param cdata content of the cdata
- * @return StaxWriter
- * @throws org.staxnav.StaxNavException if an exception occurs
- */
- StaxWriter<N> writeCData(String cdata) throws StaxNavException;
-
- /**
- * Calling finish will flush and close the underlying stream. It will also call any
endElements for you
- * if they were never explicitly called.
- *
- * @throws org.staxnav.StaxNavException if an exception occurs
- */
- void finish() throws StaxNavException;
-}
\ No newline at end of file
Copied:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriter.java
(from rev 6958,
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriter.java)
===================================================================
---
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriter.java
(rev 0)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriter.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,152 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.common.xml.stax.writer;
+
+import org.staxnav.StaxNavException;
+
+import javax.xml.namespace.QName;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public interface StaxWriter<N>
+{
+ /**
+ * Writes the start tag of an xml element. Requires that an element has been started
first.
+ *
+ * @param element element to start
+ * @return StaxWriter
+ * @throws org.staxnav.StaxNavException if an exception occurs
+ */
+ StaxWriter<N> writeStartElement(N element) throws StaxNavException;
+
+ /**
+ * Writes an attribute for an xml element. Requires that an element has been started
first.
+ *
+ * @param name the name of the attribute
+ * @param value the value of the attribute
+ * @return StaxWriter
+ * @throws org.staxnav.StaxNavException if an exception occurs
+ */
+ StaxWriter<N> writeAttribute(String name, String value) throws
StaxNavException;
+
+ /**
+ * Writes an attribute for an xml element. Requires that an element has been started
first.
+ *
+ * @param name QName object representing the name of the attribute
+ * @param value the value of the attribute
+ * @return StaxWriter
+ * @throws org.staxnav.StaxNavException if an exception occurs
+ */
+ StaxWriter<N> writeAttribute(QName name, String value) throws StaxNavException;
+
+ /**
+ * Writes xml content. Requires an xml element has been started first.
+ *
+ * @param content content to be written
+ * @return StaxWriter
+ * @throws org.staxnav.StaxNavException if an exception occurs
+ */
+ StaxWriter<N> writeContent(String content) throws StaxNavException;
+
+ /**
+ * Writes xml content based on the ValueType responsible for converting the content to
string. Requires an xml element has been started first.
+ *
+ * @param valueType object responsible for writing content to string
+ * @param content content to be written
+ * @return StaxWriter
+ * @throws org.staxnav.StaxNavException if an exception occurs
+ */
+ <V> StaxWriter<N> writeContent(WritableValueType<V> valueType, V
content) throws StaxNavException;
+
+ /**
+ * Writes an end tag for the previously started element. Requires that an element has
been started first.
+ *
+ * @return StaxWriter
+ * @throws org.staxnav.StaxNavException if an exception occurs
+ */
+ StaxWriter<N> writeEndElement() throws StaxNavException;
+
+ /**
+ * Convenience method for calling <code>writeStartElement</code>,
<code>writeContent</code>, <code>writeEndElement</code>
+ *
+ * @param element element to write
+ * @param content content to be written
+ * @return StaxWriter
+ * @throws org.staxnav.StaxNavException if an exception occurs
+ */
+ <V> StaxWriter<N> writeElement(N element, String content) throws
StaxNavException;
+
+ /**
+ * Convenience method for calling <code>writeStartElement</code>,
<code>writeContent</code>, <code>writeEndElement</code>
+ *
+ * @param element element to write
+ * @param valueType object responsible for writing content to string
+ * @param content content to be written
+ * @return StaxWriter
+ * @throws org.staxnav.StaxNavException if an exception occurs
+ */
+ <V> StaxWriter<N> writeElement(N element, WritableValueType<V>
valueType, V content) throws StaxNavException;
+
+ /**
+ * Writes the namespace. If prefix is an empty string, "xmlns", or null this
will delegate to writeDefaultNamespace
+ * @param prefix the prefix to bind the namespace to
+ * @param uri the uri to bind the prefix to
+ * @return StaxWriter
+ * @throws org.staxnav.StaxNavException if an exception occurs
+ */
+ StaxWriter<N> writeNamespace(String prefix, String uri) throws
StaxNavException;
+
+ /**
+ * Writes the default namespace
+ * @param uri the uri to bind the default namespace to
+ * @return StaxWriter
+ * @throws org.staxnav.StaxNavException if an exception occurs
+ */
+ StaxWriter<N> writeDefaultNamespace(String uri) throws StaxNavException;
+
+ /**
+ * Writes an xml comment
+ * @param comment the comment to write
+ * @return StaxWriter
+ * @throws org.staxnav.StaxNavException if an exception occurs
+ */
+ StaxWriter<N> writeComment(String comment) throws StaxNavException;
+
+ /**
+ * Writes a cdata section
+ * @param cdata content of the cdata
+ * @return StaxWriter
+ * @throws org.staxnav.StaxNavException if an exception occurs
+ */
+ StaxWriter<N> writeCData(String cdata) throws StaxNavException;
+
+ /**
+ * Calling finish will flush and close the underlying stream. It will also call any
endElements for you
+ * if they were never explicitly called.
+ *
+ * @throws org.staxnav.StaxNavException if an exception occurs
+ */
+ void finish() throws StaxNavException;
+}
\ No newline at end of file
Deleted:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriterImpl.java
===================================================================
---
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriterImpl.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriterImpl.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,503 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.common.xml.stax.writer;
-
-
-import org.gatein.common.xml.stax.writer.formatting.NoOpFormatter;
-import org.gatein.common.xml.stax.writer.formatting.XmlStreamingFormatter;
-import org.staxnav.Naming;
-import org.staxnav.StaxNavException;
-
-import javax.xml.XMLConstants;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import java.util.ArrayDeque;
-import java.util.Deque;
-import java.util.List;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class StaxWriterImpl<N> implements StaxWriter<N>, XMLStreamConstants
-{
- private Naming<N> naming;
- private XMLStreamWriter writer;
- private XmlStreamingFormatter formatter;
-
- private Deque<Element> elementStack = new ArrayDeque<Element>();
-
- public StaxWriterImpl(Naming<N> naming, XMLStreamWriter writer)
- {
- this(naming, writer, null);
- }
-
- public StaxWriterImpl(Naming<N> naming, XMLStreamWriter writer,
XmlStreamingFormatter formatter)
- {
- this(naming, writer, formatter, null, null);
- }
-
- public StaxWriterImpl(Naming<N> naming, XMLStreamWriter writer,
XmlStreamingFormatter formatter, String encoding, String version)
- {
- this.naming = naming;
- this.writer = writer;
- if (formatter == null) formatter = new NoOpFormatter();
-
- this.formatter = formatter;
- elementStack.push(new RootElement(writer, formatter, encoding, version));
- }
-
- public StaxWriter<N> writeAttribute(String name, String value)
- {
- if (name == null) throw new IllegalArgumentException("name cannot be
null");
- if (value == null) throw new IllegalArgumentException("value cannot be
null");
-
- Element current = elementStack.peek();
- current.writeAttribute(name, value);
- return this;
- }
-
- public StaxWriter<N> writeAttribute(QName name, String value)
- {
- if (name == null) throw new IllegalArgumentException("name cannot be
null");
-
- Element current = elementStack.peek();
- current.writeAttribute(name, value);
- return this;
- }
-
- public StaxWriter<N> writeStartElement(N element) throws StaxNavException
- {
- Element current = elementStack.peek();
- if (current instanceof RootElement)
- {
- if (((RootElement) current).started)
- {
- current = new StreamElement(writer, formatter);
- elementStack.push(current);
- }
- }
- else
- {
- current = new StreamElement(writer, formatter);
- elementStack.push(current);
- }
-
- current.writeStartElement(naming, element);
- return this;
- }
-
- public StaxWriter<N> writeEndElement() throws StaxNavException
- {
- if (elementStack.isEmpty()) throw new StaxNavException(null, "No matching
startElement was found for this endElement");
-
- elementStack.pop().end();
-
- return this;
- }
-
- public StaxWriter<N> writeContent(String content) throws StaxNavException
- {
- return writeContent(WritableValueTypes.STRING, content);
- }
-
- public <V> StaxWriter<N> writeContent(WritableValueType<V>
valueType, V content) throws StaxNavException
- {
- if (valueType == null) throw new IllegalArgumentException("valueType cannot be
null.");
- if (content == null) throw new IllegalArgumentException("content cannot be
null.");
-
- Element current = elementStack.peek();
- current.writeContent(valueType.format(content));
-
- return this;
- }
-
- public <V> StaxWriter<N> writeElement(N element, String content) throws
StaxNavException
- {
- return writeElement(element, WritableValueTypes.STRING, content);
- }
-
- public <V> StaxWriter<N> writeElement(N element,
WritableValueType<V> valueType, V content) throws StaxNavException
- {
- writeStartElement(element).writeContent(valueType, content).writeEndElement();
- return this;
- }
-
- public StaxWriter<N> writeNamespace(String prefix, String uri) throws
StaxNavException
- {
- Element current = elementStack.peek();
- current.writeNamespace(prefix, uri);
- return this;
- }
-
- public StaxWriter<N> writeDefaultNamespace(String uri) throws StaxNavException
- {
- Element current = elementStack.peek();
- current.writeDefaultNamespace(uri);
- return this;
- }
-
- public StaxWriter<N> writeComment(final String comment) throws StaxNavException
- {
- Element current = elementStack.peek();
- current.writeComment(comment);
- return this;
- }
-
- public StaxWriter<N> writeCData(String cdata) throws StaxNavException
- {
- Element current = elementStack.peek();
- current.writeCData(cdata);
- return this;
- }
-
- public void finish() throws StaxNavException
- {
- while (!elementStack.isEmpty())
- {
- elementStack.pop().end();
- }
- }
-
- private static abstract class Element
- {
- abstract void writeAttribute(String name, String value) throws StaxNavException;
-
- abstract <N> void writeAttribute(QName name, String value) throws
StaxNavException;
-
- abstract <N> void writeStartElement(Naming<N> naming, N name) throws
StaxNavException;
-
- abstract void writeContent(String content) throws StaxNavException;
-
- abstract void writeNamespace(String prefix, String uri) throws StaxNavException;
-
- abstract void writeDefaultNamespace(String uri) throws StaxNavException;
-
- abstract void writeComment(String comment) throws StaxNavException;
-
- abstract void writeCData(String cdata) throws StaxNavException;
-
- abstract void end();
-
- XMLStreamWriter writer;
- XmlStreamingFormatter formatter;
- private List<StreamClosure> closures;
-
- Element(XMLStreamWriter writer, XmlStreamingFormatter formatter)
- {
- this(writer, formatter, null);
- }
-
- Element(XMLStreamWriter writer, XmlStreamingFormatter formatter,
List<StreamClosure> closures)
- {
- this.writer = writer;
- this.formatter = formatter;
- this.closures = closures;
- }
-
- void apply(int event, StreamClosure closure) throws StaxNavException
- {
- try
- {
- formatter.before(writer, event);
- closure.execute(writer);
- formatter.after(writer, event);
- }
- catch (XMLStreamException e)
- {
- throw new StaxNavException(e);
- }
- }
- }
-
- private static class RootElement extends Element
- {
- private String encoding;
- private String version;
- private Element element;
- private boolean started;
-
- RootElement(XMLStreamWriter writer, XmlStreamingFormatter formatter, String
encoding, String version)
- {
- super(writer, formatter);
- this.encoding = encoding;
- this.version = version;
- }
-
- public void writeAttribute(String name, String value) throws StaxNavException
- {
- get().writeAttribute(name, value);
- }
-
- public <N> void writeAttribute(QName name, String value) throws
StaxNavException
- {
- get().writeAttribute(name, value);
- }
-
- public <N> void writeStartElement(Naming<N> naming, N name) throws
StaxNavException
- {
- get().writeStartElement(naming, name);
- started = true;
- }
-
- public void writeContent(String content) throws StaxNavException
- {
- get().writeContent(content);
- }
-
- public void writeNamespace(String prefix, String uri) throws StaxNavException
- {
- get().writeNamespace(prefix, uri);
- }
-
- public void writeDefaultNamespace(String uri) throws StaxNavException
- {
- get().writeDefaultNamespace(uri);
- }
-
- public void writeComment(String comment) throws StaxNavException
- {
- get().writeComment(comment);
- }
-
- public void writeCData(String cdata) throws StaxNavException
- {
- get().writeCData(cdata);
- }
-
- public void end()
- {
- if (started)
- {
- get().end();
- }
- endDocument();
- }
-
- private Element get()
- {
- if (element == null)
- {
- startDocument();
- element = new StreamElement(writer, formatter);
- }
- return element;
- }
-
- private void startDocument() throws StaxNavException
- {
- apply(START_DOCUMENT, new StreamClosure()
- {
- public void execute(XMLStreamWriter writer) throws XMLStreamException
- {
- if (encoding == null && version == null)
- {
- writer.writeStartDocument();
- }
- else if (encoding == null)
- {
- writer.writeStartDocument(version);
- }
- else
- {
- writer.writeStartDocument(encoding, version);
- }
- }
- });
- }
-
- private void endDocument() throws StaxNavException
- {
- try
- {
- apply(END_DOCUMENT, new StreamClosure()
- {
- public void execute(XMLStreamWriter writer) throws XMLStreamException
- {
- writer.writeEndDocument();
- }
- });
-
- writer.flush();
- }
- catch (XMLStreamException e)
- {
- throw new StaxNavException(e);
- }
- finally
- {
- try
- {
- writer.close();
- }
- catch (XMLStreamException e)
- {
- }
- }
- }
- }
-
- private static class StreamElement extends Element
- {
- StreamElement(XMLStreamWriter writer, XmlStreamingFormatter formatter)
- {
- super(writer, formatter);
- }
-
- public void writeAttribute(final String name, final String value) throws
StaxNavException
- {
- apply(ATTRIBUTE, new StreamClosure()
- {
- public void execute(XMLStreamWriter writer) throws XMLStreamException
- {
- writer.writeAttribute(name, value);
- }
- });
- }
-
- public <N> void writeAttribute(QName name, final String value) throws
StaxNavException
- {
- final String prefix = name.getPrefix();
- final String uri = name.getNamespaceURI();
- final String localPart = name.getLocalPart();
-
- apply(ATTRIBUTE, new StreamClosure()
- {
- public void execute(XMLStreamWriter writer) throws XMLStreamException
- {
- if (uri == null || XMLConstants.NULL_NS_URI.equals(uri))
- {
- writer.writeAttribute(localPart, value);
- }
- else if (prefix == null || XMLConstants.DEFAULT_NS_PREFIX.equals(prefix))
- {
- writer.writeAttribute(uri, localPart, value);
- }
- else
- {
- writer.writeAttribute(prefix, uri, localPart, value);
- }
- }
- });
- }
-
- public <N> void writeStartElement(Naming<N> naming, N name) throws
StaxNavException
- {
- final String prefix = naming.getPrefix(name);
- final String uri = naming.getURI(name);
- final String localPart = naming.getLocalPart(name);
-
- apply(START_ELEMENT, new StreamClosure()
- {
- public void execute(XMLStreamWriter writer) throws XMLStreamException
- {
- if (uri == null || XMLConstants.NULL_NS_URI.equals(uri))
- {
- writer.writeStartElement(localPart);
- }
- else if (prefix == null || XMLConstants.DEFAULT_NS_PREFIX.equals(prefix))
- {
- writer.writeStartElement(uri, localPart);
- }
- else
- {
- writer.writeStartElement(prefix, localPart, uri);
- }
- }
- });
- }
-
- public void writeContent(final String content) throws StaxNavException
- {
- apply(CHARACTERS, new StreamClosure()
- {
- public void execute(XMLStreamWriter writer) throws XMLStreamException
- {
- writer.writeCharacters(content);
- }
- });
- }
-
- public void writeNamespace(final String prefix, final String uri) throws
StaxNavException
- {
- apply(NAMESPACE, new StreamClosure()
- {
- public void execute(XMLStreamWriter writer) throws XMLStreamException
- {
- writer.writeNamespace(prefix, uri);
- }
- });
- }
-
- public void writeDefaultNamespace(final String uri) throws StaxNavException
- {
- apply(NAMESPACE, new StreamClosure()
- {
- public void execute(XMLStreamWriter writer) throws XMLStreamException
- {
- writer.writeDefaultNamespace(uri);
- }
- });
- }
-
- public void writeComment(final String comment) throws StaxNavException
- {
- apply(COMMENT, new StreamClosure()
- {
- public void execute(XMLStreamWriter writer) throws XMLStreamException
- {
- writer.writeComment(comment);
- }
- });
- }
-
- public void writeCData(final String cdata) throws StaxNavException
- {
- apply(CDATA, new StreamClosure()
- {
- public void execute(XMLStreamWriter writer) throws XMLStreamException
- {
- writer.writeCData(cdata);
- }
- });
- }
-
- public void end()
- {
- apply(END_ELEMENT, new StreamClosure()
- {
- public void execute(XMLStreamWriter writer) throws XMLStreamException
- {
- writer.writeEndElement();
- }
- });
- }
- }
-
- private static interface StreamClosure
- {
- void execute(XMLStreamWriter writer) throws XMLStreamException;
- }
-}
Copied:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriterImpl.java
(from rev 6958,
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriterImpl.java)
===================================================================
---
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriterImpl.java
(rev 0)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriterImpl.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,503 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.common.xml.stax.writer;
+
+
+import org.gatein.common.xml.stax.writer.formatting.NoOpFormatter;
+import org.gatein.common.xml.stax.writer.formatting.XmlStreamingFormatter;
+import org.staxnav.Naming;
+import org.staxnav.StaxNavException;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.util.ArrayDeque;
+import java.util.Deque;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class StaxWriterImpl<N> implements StaxWriter<N>, XMLStreamConstants
+{
+ private Naming<N> naming;
+ private XMLStreamWriter writer;
+ private XmlStreamingFormatter formatter;
+
+ private Deque<Element> elementStack = new ArrayDeque<Element>();
+
+ public StaxWriterImpl(Naming<N> naming, XMLStreamWriter writer)
+ {
+ this(naming, writer, null);
+ }
+
+ public StaxWriterImpl(Naming<N> naming, XMLStreamWriter writer,
XmlStreamingFormatter formatter)
+ {
+ this(naming, writer, formatter, null, null);
+ }
+
+ public StaxWriterImpl(Naming<N> naming, XMLStreamWriter writer,
XmlStreamingFormatter formatter, String encoding, String version)
+ {
+ this.naming = naming;
+ this.writer = writer;
+ if (formatter == null) formatter = new NoOpFormatter();
+
+ this.formatter = formatter;
+ elementStack.push(new RootElement(writer, formatter, encoding, version));
+ }
+
+ public StaxWriter<N> writeAttribute(String name, String value)
+ {
+ if (name == null) throw new IllegalArgumentException("name cannot be
null");
+ if (value == null) throw new IllegalArgumentException("value cannot be
null");
+
+ Element current = elementStack.peek();
+ current.writeAttribute(name, value);
+ return this;
+ }
+
+ public StaxWriter<N> writeAttribute(QName name, String value)
+ {
+ if (name == null) throw new IllegalArgumentException("name cannot be
null");
+
+ Element current = elementStack.peek();
+ current.writeAttribute(name, value);
+ return this;
+ }
+
+ public StaxWriter<N> writeStartElement(N element) throws StaxNavException
+ {
+ Element current = elementStack.peek();
+ if (current instanceof RootElement)
+ {
+ if (((RootElement) current).started)
+ {
+ current = new StreamElement(writer, formatter);
+ elementStack.push(current);
+ }
+ }
+ else
+ {
+ current = new StreamElement(writer, formatter);
+ elementStack.push(current);
+ }
+
+ current.writeStartElement(naming, element);
+ return this;
+ }
+
+ public StaxWriter<N> writeEndElement() throws StaxNavException
+ {
+ if (elementStack.isEmpty()) throw new StaxNavException(null, "No matching
startElement was found for this endElement");
+
+ elementStack.pop().end();
+
+ return this;
+ }
+
+ public StaxWriter<N> writeContent(String content) throws StaxNavException
+ {
+ return writeContent(WritableValueTypes.STRING, content);
+ }
+
+ public <V> StaxWriter<N> writeContent(WritableValueType<V>
valueType, V content) throws StaxNavException
+ {
+ if (valueType == null) throw new IllegalArgumentException("valueType cannot be
null.");
+ if (content == null) throw new IllegalArgumentException("content cannot be
null.");
+
+ Element current = elementStack.peek();
+ current.writeContent(valueType.format(content));
+
+ return this;
+ }
+
+ public <V> StaxWriter<N> writeElement(N element, String content) throws
StaxNavException
+ {
+ return writeElement(element, WritableValueTypes.STRING, content);
+ }
+
+ public <V> StaxWriter<N> writeElement(N element,
WritableValueType<V> valueType, V content) throws StaxNavException
+ {
+ writeStartElement(element).writeContent(valueType, content).writeEndElement();
+ return this;
+ }
+
+ public StaxWriter<N> writeNamespace(String prefix, String uri) throws
StaxNavException
+ {
+ Element current = elementStack.peek();
+ current.writeNamespace(prefix, uri);
+ return this;
+ }
+
+ public StaxWriter<N> writeDefaultNamespace(String uri) throws StaxNavException
+ {
+ Element current = elementStack.peek();
+ current.writeDefaultNamespace(uri);
+ return this;
+ }
+
+ public StaxWriter<N> writeComment(final String comment) throws StaxNavException
+ {
+ Element current = elementStack.peek();
+ current.writeComment(comment);
+ return this;
+ }
+
+ public StaxWriter<N> writeCData(String cdata) throws StaxNavException
+ {
+ Element current = elementStack.peek();
+ current.writeCData(cdata);
+ return this;
+ }
+
+ public void finish() throws StaxNavException
+ {
+ while (!elementStack.isEmpty())
+ {
+ elementStack.pop().end();
+ }
+ }
+
+ private static abstract class Element
+ {
+ abstract void writeAttribute(String name, String value) throws StaxNavException;
+
+ abstract <N> void writeAttribute(QName name, String value) throws
StaxNavException;
+
+ abstract <N> void writeStartElement(Naming<N> naming, N name) throws
StaxNavException;
+
+ abstract void writeContent(String content) throws StaxNavException;
+
+ abstract void writeNamespace(String prefix, String uri) throws StaxNavException;
+
+ abstract void writeDefaultNamespace(String uri) throws StaxNavException;
+
+ abstract void writeComment(String comment) throws StaxNavException;
+
+ abstract void writeCData(String cdata) throws StaxNavException;
+
+ abstract void end();
+
+ XMLStreamWriter writer;
+ XmlStreamingFormatter formatter;
+ private List<StreamClosure> closures;
+
+ Element(XMLStreamWriter writer, XmlStreamingFormatter formatter)
+ {
+ this(writer, formatter, null);
+ }
+
+ Element(XMLStreamWriter writer, XmlStreamingFormatter formatter,
List<StreamClosure> closures)
+ {
+ this.writer = writer;
+ this.formatter = formatter;
+ this.closures = closures;
+ }
+
+ void apply(int event, StreamClosure closure) throws StaxNavException
+ {
+ try
+ {
+ formatter.before(writer, event);
+ closure.execute(writer);
+ formatter.after(writer, event);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new StaxNavException(e);
+ }
+ }
+ }
+
+ private static class RootElement extends Element
+ {
+ private String encoding;
+ private String version;
+ private Element element;
+ private boolean started;
+
+ RootElement(XMLStreamWriter writer, XmlStreamingFormatter formatter, String
encoding, String version)
+ {
+ super(writer, formatter);
+ this.encoding = encoding;
+ this.version = version;
+ }
+
+ public void writeAttribute(String name, String value) throws StaxNavException
+ {
+ get().writeAttribute(name, value);
+ }
+
+ public <N> void writeAttribute(QName name, String value) throws
StaxNavException
+ {
+ get().writeAttribute(name, value);
+ }
+
+ public <N> void writeStartElement(Naming<N> naming, N name) throws
StaxNavException
+ {
+ get().writeStartElement(naming, name);
+ started = true;
+ }
+
+ public void writeContent(String content) throws StaxNavException
+ {
+ get().writeContent(content);
+ }
+
+ public void writeNamespace(String prefix, String uri) throws StaxNavException
+ {
+ get().writeNamespace(prefix, uri);
+ }
+
+ public void writeDefaultNamespace(String uri) throws StaxNavException
+ {
+ get().writeDefaultNamespace(uri);
+ }
+
+ public void writeComment(String comment) throws StaxNavException
+ {
+ get().writeComment(comment);
+ }
+
+ public void writeCData(String cdata) throws StaxNavException
+ {
+ get().writeCData(cdata);
+ }
+
+ public void end()
+ {
+ if (started)
+ {
+ get().end();
+ }
+ endDocument();
+ }
+
+ private Element get()
+ {
+ if (element == null)
+ {
+ startDocument();
+ element = new StreamElement(writer, formatter);
+ }
+ return element;
+ }
+
+ private void startDocument() throws StaxNavException
+ {
+ apply(START_DOCUMENT, new StreamClosure()
+ {
+ public void execute(XMLStreamWriter writer) throws XMLStreamException
+ {
+ if (encoding == null && version == null)
+ {
+ writer.writeStartDocument();
+ }
+ else if (encoding == null)
+ {
+ writer.writeStartDocument(version);
+ }
+ else
+ {
+ writer.writeStartDocument(encoding, version);
+ }
+ }
+ });
+ }
+
+ private void endDocument() throws StaxNavException
+ {
+ try
+ {
+ apply(END_DOCUMENT, new StreamClosure()
+ {
+ public void execute(XMLStreamWriter writer) throws XMLStreamException
+ {
+ writer.writeEndDocument();
+ }
+ });
+
+ writer.flush();
+ }
+ catch (XMLStreamException e)
+ {
+ throw new StaxNavException(e);
+ }
+ finally
+ {
+ try
+ {
+ writer.close();
+ }
+ catch (XMLStreamException e)
+ {
+ }
+ }
+ }
+ }
+
+ private static class StreamElement extends Element
+ {
+ StreamElement(XMLStreamWriter writer, XmlStreamingFormatter formatter)
+ {
+ super(writer, formatter);
+ }
+
+ public void writeAttribute(final String name, final String value) throws
StaxNavException
+ {
+ apply(ATTRIBUTE, new StreamClosure()
+ {
+ public void execute(XMLStreamWriter writer) throws XMLStreamException
+ {
+ writer.writeAttribute(name, value);
+ }
+ });
+ }
+
+ public <N> void writeAttribute(QName name, final String value) throws
StaxNavException
+ {
+ final String prefix = name.getPrefix();
+ final String uri = name.getNamespaceURI();
+ final String localPart = name.getLocalPart();
+
+ apply(ATTRIBUTE, new StreamClosure()
+ {
+ public void execute(XMLStreamWriter writer) throws XMLStreamException
+ {
+ if (uri == null || XMLConstants.NULL_NS_URI.equals(uri))
+ {
+ writer.writeAttribute(localPart, value);
+ }
+ else if (prefix == null || XMLConstants.DEFAULT_NS_PREFIX.equals(prefix))
+ {
+ writer.writeAttribute(uri, localPart, value);
+ }
+ else
+ {
+ writer.writeAttribute(prefix, uri, localPart, value);
+ }
+ }
+ });
+ }
+
+ public <N> void writeStartElement(Naming<N> naming, N name) throws
StaxNavException
+ {
+ final String prefix = naming.getPrefix(name);
+ final String uri = naming.getURI(name);
+ final String localPart = naming.getLocalPart(name);
+
+ apply(START_ELEMENT, new StreamClosure()
+ {
+ public void execute(XMLStreamWriter writer) throws XMLStreamException
+ {
+ if (uri == null || XMLConstants.NULL_NS_URI.equals(uri))
+ {
+ writer.writeStartElement(localPart);
+ }
+ else if (prefix == null || XMLConstants.DEFAULT_NS_PREFIX.equals(prefix))
+ {
+ writer.writeStartElement(uri, localPart);
+ }
+ else
+ {
+ writer.writeStartElement(prefix, localPart, uri);
+ }
+ }
+ });
+ }
+
+ public void writeContent(final String content) throws StaxNavException
+ {
+ apply(CHARACTERS, new StreamClosure()
+ {
+ public void execute(XMLStreamWriter writer) throws XMLStreamException
+ {
+ writer.writeCharacters(content);
+ }
+ });
+ }
+
+ public void writeNamespace(final String prefix, final String uri) throws
StaxNavException
+ {
+ apply(NAMESPACE, new StreamClosure()
+ {
+ public void execute(XMLStreamWriter writer) throws XMLStreamException
+ {
+ writer.writeNamespace(prefix, uri);
+ }
+ });
+ }
+
+ public void writeDefaultNamespace(final String uri) throws StaxNavException
+ {
+ apply(NAMESPACE, new StreamClosure()
+ {
+ public void execute(XMLStreamWriter writer) throws XMLStreamException
+ {
+ writer.writeDefaultNamespace(uri);
+ }
+ });
+ }
+
+ public void writeComment(final String comment) throws StaxNavException
+ {
+ apply(COMMENT, new StreamClosure()
+ {
+ public void execute(XMLStreamWriter writer) throws XMLStreamException
+ {
+ writer.writeComment(comment);
+ }
+ });
+ }
+
+ public void writeCData(final String cdata) throws StaxNavException
+ {
+ apply(CDATA, new StreamClosure()
+ {
+ public void execute(XMLStreamWriter writer) throws XMLStreamException
+ {
+ writer.writeCData(cdata);
+ }
+ });
+ }
+
+ public void end()
+ {
+ apply(END_ELEMENT, new StreamClosure()
+ {
+ public void execute(XMLStreamWriter writer) throws XMLStreamException
+ {
+ writer.writeEndElement();
+ }
+ });
+ }
+ }
+
+ private static interface StreamClosure
+ {
+ void execute(XMLStreamWriter writer) throws XMLStreamException;
+ }
+}
Deleted:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriterUtils.java
===================================================================
---
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriterUtils.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriterUtils.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,199 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.common.xml.stax.writer;
-
-import org.gatein.common.xml.stax.writer.builder.StaxFormatterBuilder;
-import org.gatein.common.xml.stax.writer.builder.StaxFormatterBuilderImpl;
-import org.gatein.common.xml.stax.writer.builder.StaxWriterBuilder;
-import org.gatein.common.xml.stax.writer.builder.StaxWriterBuilderImpl;
-import org.gatein.common.xml.stax.writer.formatting.XmlStreamingFormatter;
-import org.staxnav.EnumElement;
-import org.staxnav.Naming;
-import org.staxnav.StaxNavException;
-
-import javax.xml.namespace.QName;
-import java.io.OutputStream;
-import java.io.Writer;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class StaxWriterUtils
-{
- public static <N> StaxWriter<N> createWriter(Naming<N> naming,
OutputStream outputStream) throws StaxNavException
- {
- return buildDefaultWriter(outputStream).build(naming);
- }
-
- public static StaxWriter<String> createWriter(OutputStream outputStream) throws
StaxNavException
- {
- return createWriter(new Naming.Local(), outputStream);
- }
-
- public static StaxWriter<QName> createQualifiedWriter(OutputStream outputStream)
throws StaxNavException
- {
- return createWriter(new Naming.Qualified(), outputStream);
- }
-
- public static <E extends Enum<E> & EnumElement<E>>
StaxWriter<E> createWriter(Class<E> enumeratedClass,
-
OutputStream outputStream) throws StaxNavException
- {
- Naming<E> naming;
- if (EnumElement.class.isAssignableFrom(enumeratedClass))
- {
- naming = new Naming.Enumerated.Mapped<E>(enumeratedClass, null);
- }
- else
- {
- naming = new Naming.Enumerated.Simple<E>(enumeratedClass, null);
- }
-
- return createWriter(naming, outputStream);
- }
-
- public static <N> StaxWriter<N> createWriter(Naming<N> naming,
Writer writer) throws StaxNavException
- {
- return buildDefaultWriter().withWriter(writer).build(naming);
- }
-
- public static StaxWriter<String> createWriter(Writer writer) throws
StaxNavException
- {
- return createWriter(new Naming.Local(), writer);
- }
-
- public static StaxWriter<QName> createQualifiedWriter(Writer writer) throws
StaxNavException
- {
- return createWriter(new Naming.Qualified(), writer);
- }
-
- public static <E extends Enum<E> & EnumElement<E>>
StaxWriter<E> createWriter(Class<E> enumeratedClass,
- Writer
writer) throws StaxNavException
- {
- Naming<E> naming;
- if (EnumElement.class.isAssignableFrom(enumeratedClass))
- {
- naming = new Naming.Enumerated.Mapped<E>(enumeratedClass, null);
- }
- else
- {
- naming = new Naming.Enumerated.Simple<E>(enumeratedClass, null);
- }
-
- return createWriter(naming, writer);
- }
-
- public static StaxWriterBuilder buildWriter()
- {
- return new StaxWriterBuilderImpl();
- }
-
- public static XmlStreamingFormatter createFormatter()
- {
- return buildFormatter().withNewline(DEFAULT_NEWLINE)
- .ofIndentSize(DEFAULT_INDENT_SIZE).withIndentCharacter(DEFAULT_INDENT_CHAR)
- .build();
- }
-
- public static XmlStreamingFormatter createFormatter(int indentSize)
- {
- return buildFormatter().withNewline(DEFAULT_NEWLINE)
- .ofIndentSize(indentSize).withIndentCharacter(DEFAULT_INDENT_CHAR)
- .build();
- }
-
- public static StaxFormatterBuilder buildFormatter()
- {
- return new StaxFormatterBuilderImpl();
- }
-
- public static <N> void writeOptionalElement(StaxWriter<N> writer, N
element, String content)
- {
- if (content == null) return;
-
- writer.writeElement(element, content);
- }
-
- public static <N, V> void writeOptionalElement(StaxWriter<N> writer, N
element, WritableValueType<V> valueType, V value)
- {
- if (value == null) return;
-
- writer.writeElement(element, valueType, value);
- }
-
- public static <N> void writeOptionalContent(StaxWriter<N> writer, N
element, String content)
- {
- writer.writeStartElement(element);
- if (content != null)
- {
- writer.writeContent(content);
- }
- writer.writeEndElement();
- }
-
- public static <N, V> void writeOptionalContent(StaxWriter<N> writer, N
element, WritableValueType<V> valueType, V value)
- {
- writer.writeStartElement(element);
- if (value != null)
- {
- writer.writeContent(valueType, value);
- }
- writer.writeEndElement();
- }
-
- private static StaxWriterBuilder buildDefaultWriter()
- {
- return buildWriter().withEncoding("UTF-8").withVersion("1.0")
- .withPropertyIfSupported("com.ctc.wstx.outputEscapeCr",
Boolean.FALSE)
- .withFormatting(createFormatter());
- }
-
- private static StaxWriterBuilder buildDefaultWriter(OutputStream outputStream)
- {
- return buildWriter().withEncoding("UTF-8").withVersion("1.0")
- .withPropertyIfSupported("com.ctc.wstx.outputEscapeCr",
Boolean.FALSE)
- .withFormatting(createFormatter())
- .withOutputStream(outputStream, "UTF-8");
- }
-
- private static final int DEFAULT_INDENT_SIZE = 3;
- private static final char DEFAULT_INDENT_CHAR = ' ';
- private static final String DEFAULT_NEWLINE;
-
- static
- {
- String newline = null;
- try
- {
- newline = System.getProperty("line.separator");
- }
- catch (Throwable ignored)
- {
- }
- if (newline == null) newline = "\n";
-
- DEFAULT_NEWLINE = newline;
- }
-
- private StaxWriterUtils(){}
-}
Copied:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriterUtils.java
(from rev 6958,
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriterUtils.java)
===================================================================
---
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriterUtils.java
(rev 0)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/StaxWriterUtils.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,199 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.common.xml.stax.writer;
+
+import org.gatein.common.xml.stax.writer.builder.StaxFormatterBuilder;
+import org.gatein.common.xml.stax.writer.builder.StaxFormatterBuilderImpl;
+import org.gatein.common.xml.stax.writer.builder.StaxWriterBuilder;
+import org.gatein.common.xml.stax.writer.builder.StaxWriterBuilderImpl;
+import org.gatein.common.xml.stax.writer.formatting.XmlStreamingFormatter;
+import org.staxnav.EnumElement;
+import org.staxnav.Naming;
+import org.staxnav.StaxNavException;
+
+import javax.xml.namespace.QName;
+import java.io.OutputStream;
+import java.io.Writer;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class StaxWriterUtils
+{
+ public static <N> StaxWriter<N> createWriter(Naming<N> naming,
OutputStream outputStream) throws StaxNavException
+ {
+ return buildDefaultWriter(outputStream).build(naming);
+ }
+
+ public static StaxWriter<String> createWriter(OutputStream outputStream) throws
StaxNavException
+ {
+ return createWriter(new Naming.Local(), outputStream);
+ }
+
+ public static StaxWriter<QName> createQualifiedWriter(OutputStream outputStream)
throws StaxNavException
+ {
+ return createWriter(new Naming.Qualified(), outputStream);
+ }
+
+ public static <E extends Enum<E> & EnumElement<E>>
StaxWriter<E> createWriter(Class<E> enumeratedClass,
+
OutputStream outputStream) throws StaxNavException
+ {
+ Naming<E> naming;
+ if (EnumElement.class.isAssignableFrom(enumeratedClass))
+ {
+ naming = new Naming.Enumerated.Mapped<E>(enumeratedClass, null);
+ }
+ else
+ {
+ naming = new Naming.Enumerated.Simple<E>(enumeratedClass, null);
+ }
+
+ return createWriter(naming, outputStream);
+ }
+
+ public static <N> StaxWriter<N> createWriter(Naming<N> naming,
Writer writer) throws StaxNavException
+ {
+ return buildDefaultWriter().withWriter(writer).build(naming);
+ }
+
+ public static StaxWriter<String> createWriter(Writer writer) throws
StaxNavException
+ {
+ return createWriter(new Naming.Local(), writer);
+ }
+
+ public static StaxWriter<QName> createQualifiedWriter(Writer writer) throws
StaxNavException
+ {
+ return createWriter(new Naming.Qualified(), writer);
+ }
+
+ public static <E extends Enum<E> & EnumElement<E>>
StaxWriter<E> createWriter(Class<E> enumeratedClass,
+ Writer
writer) throws StaxNavException
+ {
+ Naming<E> naming;
+ if (EnumElement.class.isAssignableFrom(enumeratedClass))
+ {
+ naming = new Naming.Enumerated.Mapped<E>(enumeratedClass, null);
+ }
+ else
+ {
+ naming = new Naming.Enumerated.Simple<E>(enumeratedClass, null);
+ }
+
+ return createWriter(naming, writer);
+ }
+
+ public static StaxWriterBuilder buildWriter()
+ {
+ return new StaxWriterBuilderImpl();
+ }
+
+ public static XmlStreamingFormatter createFormatter()
+ {
+ return buildFormatter().withNewline(DEFAULT_NEWLINE)
+ .ofIndentSize(DEFAULT_INDENT_SIZE).withIndentCharacter(DEFAULT_INDENT_CHAR)
+ .build();
+ }
+
+ public static XmlStreamingFormatter createFormatter(int indentSize)
+ {
+ return buildFormatter().withNewline(DEFAULT_NEWLINE)
+ .ofIndentSize(indentSize).withIndentCharacter(DEFAULT_INDENT_CHAR)
+ .build();
+ }
+
+ public static StaxFormatterBuilder buildFormatter()
+ {
+ return new StaxFormatterBuilderImpl();
+ }
+
+ public static <N> void writeOptionalElement(StaxWriter<N> writer, N
element, String content)
+ {
+ if (content == null) return;
+
+ writer.writeElement(element, content);
+ }
+
+ public static <N, V> void writeOptionalElement(StaxWriter<N> writer, N
element, WritableValueType<V> valueType, V value)
+ {
+ if (value == null) return;
+
+ writer.writeElement(element, valueType, value);
+ }
+
+ public static <N> void writeOptionalContent(StaxWriter<N> writer, N
element, String content)
+ {
+ writer.writeStartElement(element);
+ if (content != null)
+ {
+ writer.writeContent(content);
+ }
+ writer.writeEndElement();
+ }
+
+ public static <N, V> void writeOptionalContent(StaxWriter<N> writer, N
element, WritableValueType<V> valueType, V value)
+ {
+ writer.writeStartElement(element);
+ if (value != null)
+ {
+ writer.writeContent(valueType, value);
+ }
+ writer.writeEndElement();
+ }
+
+ private static StaxWriterBuilder buildDefaultWriter()
+ {
+ return buildWriter().withEncoding("UTF-8").withVersion("1.0")
+ .withPropertyIfSupported("com.ctc.wstx.outputEscapeCr",
Boolean.FALSE)
+ .withFormatting(createFormatter());
+ }
+
+ private static StaxWriterBuilder buildDefaultWriter(OutputStream outputStream)
+ {
+ return buildWriter().withEncoding("UTF-8").withVersion("1.0")
+ .withPropertyIfSupported("com.ctc.wstx.outputEscapeCr",
Boolean.FALSE)
+ .withFormatting(createFormatter())
+ .withOutputStream(outputStream, "UTF-8");
+ }
+
+ private static final int DEFAULT_INDENT_SIZE = 3;
+ private static final char DEFAULT_INDENT_CHAR = ' ';
+ private static final String DEFAULT_NEWLINE;
+
+ static
+ {
+ String newline = null;
+ try
+ {
+ newline = System.getProperty("line.separator");
+ }
+ catch (Throwable ignored)
+ {
+ }
+ if (newline == null) newline = "\n";
+
+ DEFAULT_NEWLINE = newline;
+ }
+
+ private StaxWriterUtils(){}
+}
Deleted:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/WritableValueType.java
===================================================================
---
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/WritableValueType.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/WritableValueType.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,34 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.common.xml.stax.writer;
-
-import org.staxnav.StaxNavException;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public interface WritableValueType<V>
-{
- String format(V value) throws StaxNavException;
-}
Copied:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/WritableValueType.java
(from rev 6958,
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/WritableValueType.java)
===================================================================
---
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/WritableValueType.java
(rev 0)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/WritableValueType.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.common.xml.stax.writer;
+
+import org.staxnav.StaxNavException;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public interface WritableValueType<V>
+{
+ String format(V value) throws StaxNavException;
+}
Deleted:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/WritableValueTypes.java
===================================================================
---
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/WritableValueTypes.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/WritableValueTypes.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,115 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.common.xml.stax.writer;
-
-import org.staxnav.StaxNavException;
-
-import javax.xml.bind.DatatypeConverter;
-import java.util.Calendar;
-import java.util.Date;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public abstract class WritableValueTypes
-{
- /**
- * Returns a value type for an enum class.
- *
- * @param <E> the enum parameter type
- * @return the corresponding value type
- */
- public static <E extends Enum<E>> WritableValueType<E>
getEnumType()
- {
- return new EnumType<E>();
- }
-
- public static final WritableValueType<String> STRING = new
WritableValueType<String>()
- {
- @Override
- public String format(String value) throws StaxNavException
- {
- return value;
- }
- };
-
- public static final WritableValueType<String> TRIMMED_STRING = new
WritableValueType<String>()
- {
- @Override
- public String format(String value) throws StaxNavException
- {
- return value.trim();
- }
- };
-
- public static final WritableValueType<Boolean> BOOLEAN = new
WritableValueType<Boolean>()
- {
- @Override
- public String format(Boolean value) throws StaxNavException
- {
- return value.toString();
- }
- };
-
- public static final WritableValueType<Integer> INTEGER = new
WritableValueType<Integer>()
- {
- @Override
- public String format(Integer value) throws StaxNavException
- {
- return value.toString();
- }
- };
-
- public static final WritableValueType<Date> DATE = new
WritableValueType<Date>()
- {
- @Override
- public String format(Date value) throws StaxNavException
- {
- Calendar cal = Calendar.getInstance();
- cal.setTime(value);
- return DatatypeConverter.printDate(cal);
- }
- };
-
- public static final WritableValueType<Date> DATE_TIME = new
WritableValueType<Date>()
- {
-
- @Override
- public String format(Date value) throws StaxNavException
- {
- Calendar cal = Calendar.getInstance();
- cal.setTime(value);
- return DatatypeConverter.printDateTime(cal);
- }
- };
-
- protected static class EnumType<E extends Enum<E>> implements
WritableValueType<E>
- {
- @Override
- public String format(E value) throws StaxNavException
- {
- return value.name();
- }
- }
-}
Copied:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/WritableValueTypes.java
(from rev 6958,
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/WritableValueTypes.java)
===================================================================
---
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/WritableValueTypes.java
(rev 0)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/WritableValueTypes.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.common.xml.stax.writer;
+
+import org.staxnav.StaxNavException;
+
+import javax.xml.bind.DatatypeConverter;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class WritableValueTypes
+{
+ /**
+ * Returns a value type for an enum class.
+ *
+ * @param <E> the enum parameter type
+ * @return the corresponding value type
+ */
+ public static <E extends Enum<E>> WritableValueType<E>
getEnumType()
+ {
+ return new EnumType<E>();
+ }
+
+ public static final WritableValueType<String> STRING = new
WritableValueType<String>()
+ {
+ @Override
+ public String format(String value) throws StaxNavException
+ {
+ return value;
+ }
+ };
+
+ public static final WritableValueType<String> TRIMMED_STRING = new
WritableValueType<String>()
+ {
+ @Override
+ public String format(String value) throws StaxNavException
+ {
+ return value.trim();
+ }
+ };
+
+ public static final WritableValueType<Boolean> BOOLEAN = new
WritableValueType<Boolean>()
+ {
+ @Override
+ public String format(Boolean value) throws StaxNavException
+ {
+ return value.toString();
+ }
+ };
+
+ public static final WritableValueType<Integer> INTEGER = new
WritableValueType<Integer>()
+ {
+ @Override
+ public String format(Integer value) throws StaxNavException
+ {
+ return value.toString();
+ }
+ };
+
+ public static final WritableValueType<Date> DATE = new
WritableValueType<Date>()
+ {
+ @Override
+ public String format(Date value) throws StaxNavException
+ {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(value);
+ return DatatypeConverter.printDate(cal);
+ }
+ };
+
+ public static final WritableValueType<Date> DATE_TIME = new
WritableValueType<Date>()
+ {
+
+ @Override
+ public String format(Date value) throws StaxNavException
+ {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(value);
+ return DatatypeConverter.printDateTime(cal);
+ }
+ };
+
+ protected static class EnumType<E extends Enum<E>> implements
WritableValueType<E>
+ {
+ @Override
+ public String format(E value) throws StaxNavException
+ {
+ return value.name();
+ }
+ }
+}
Deleted:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxFormatterBuilder.java
===================================================================
---
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxFormatterBuilder.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxFormatterBuilder.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.common.xml.stax.writer.builder;
-
-
-import org.gatein.common.xml.stax.writer.formatting.XmlStreamingFormatter;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public interface StaxFormatterBuilder
-{
- StaxFormatterBuilder withIndentCharacter(char indentCharacter);
-
- StaxFormatterBuilder ofIndentSize(int indentSize);
-
- StaxFormatterBuilder withNewline(String newline);
-
- XmlStreamingFormatter build() throws IllegalStateException;
-}
Copied:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxFormatterBuilder.java
(from rev 6958,
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxFormatterBuilder.java)
===================================================================
---
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxFormatterBuilder.java
(rev 0)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxFormatterBuilder.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.common.xml.stax.writer.builder;
+
+
+import org.gatein.common.xml.stax.writer.formatting.XmlStreamingFormatter;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public interface StaxFormatterBuilder
+{
+ StaxFormatterBuilder withIndentCharacter(char indentCharacter);
+
+ StaxFormatterBuilder ofIndentSize(int indentSize);
+
+ StaxFormatterBuilder withNewline(String newline);
+
+ XmlStreamingFormatter build() throws IllegalStateException;
+}
Deleted:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxFormatterBuilderImpl.java
===================================================================
---
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxFormatterBuilderImpl.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxFormatterBuilderImpl.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.common.xml.stax.writer.builder;
-
-
-import org.gatein.common.xml.stax.writer.formatting.SimpleFormatter;
-import org.gatein.common.xml.stax.writer.formatting.XmlStreamingFormatter;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class StaxFormatterBuilderImpl implements StaxFormatterBuilder
-{
- private Character indentCharacter;
- private Integer indentSize;
- private String newline;
-
- public StaxFormatterBuilder withIndentCharacter(char indentCharacter)
- {
- this.indentCharacter = indentCharacter;
- return this;
- }
-
- public StaxFormatterBuilder ofIndentSize(int indentSize)
- {
- this.indentSize = indentSize;
- return this;
- }
-
- public StaxFormatterBuilder withNewline(String newline)
- {
- this.newline = newline;
- return this;
- }
-
- public XmlStreamingFormatter build()
- {
- if (indentCharacter == null) throw new IllegalStateException("indent character
is required value for this builder.");
- if (indentSize == null) throw new IllegalArgumentException("indent size is a
required value for this builder.");
- if (newline == null) throw new IllegalArgumentException("newline is a required
value for this builder.");
-
- return new SimpleFormatter(indentCharacter, indentSize, newline);
- }
-}
Copied:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxFormatterBuilderImpl.java
(from rev 6958,
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxFormatterBuilderImpl.java)
===================================================================
---
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxFormatterBuilderImpl.java
(rev 0)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxFormatterBuilderImpl.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.common.xml.stax.writer.builder;
+
+
+import org.gatein.common.xml.stax.writer.formatting.SimpleFormatter;
+import org.gatein.common.xml.stax.writer.formatting.XmlStreamingFormatter;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class StaxFormatterBuilderImpl implements StaxFormatterBuilder
+{
+ private Character indentCharacter;
+ private Integer indentSize;
+ private String newline;
+
+ public StaxFormatterBuilder withIndentCharacter(char indentCharacter)
+ {
+ this.indentCharacter = indentCharacter;
+ return this;
+ }
+
+ public StaxFormatterBuilder ofIndentSize(int indentSize)
+ {
+ this.indentSize = indentSize;
+ return this;
+ }
+
+ public StaxFormatterBuilder withNewline(String newline)
+ {
+ this.newline = newline;
+ return this;
+ }
+
+ public XmlStreamingFormatter build()
+ {
+ if (indentCharacter == null) throw new IllegalStateException("indent character
is required value for this builder.");
+ if (indentSize == null) throw new IllegalArgumentException("indent size is a
required value for this builder.");
+ if (newline == null) throw new IllegalArgumentException("newline is a required
value for this builder.");
+
+ return new SimpleFormatter(indentCharacter, indentSize, newline);
+ }
+}
Deleted:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxWriterBuilder.java
===================================================================
---
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxWriterBuilder.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxWriterBuilder.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,63 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.common.xml.stax.writer.builder;
-
-
-import org.gatein.common.xml.stax.writer.StaxWriter;
-import org.gatein.common.xml.stax.writer.formatting.XmlStreamingFormatter;
-import org.staxnav.Naming;
-import org.staxnav.StaxNavException;
-
-import javax.xml.stream.XMLStreamWriter;
-import javax.xml.transform.Result;
-import java.io.OutputStream;
-import java.io.Writer;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public interface StaxWriterBuilder
-{
- StaxWriterBuilder withProperty(String name, Object value);
-
- StaxWriterBuilder withPropertyIfSupported(String name, Object value);
-
- StaxWriterBuilder withEncoding(String encoding);
-
- StaxWriterBuilder withVersion(String version);
-
- StaxWriterBuilder withFormatting(XmlStreamingFormatter formatter);
-
- StaxWriterBuilder withOutputStream(OutputStream outputStream);
-
- StaxWriterBuilder withOutputStream(OutputStream outputStream, String encoding);
-
- StaxWriterBuilder withWriter(Writer writer);
-
- StaxWriterBuilder withResult(Result result);
-
- StaxWriterBuilder withXmlStreamWriter(XMLStreamWriter writer);
-
- <N> StaxWriter<N> build(Naming<N> naming) throws StaxNavException,
IllegalStateException;
-}
Copied:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxWriterBuilder.java
(from rev 6958,
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxWriterBuilder.java)
===================================================================
---
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxWriterBuilder.java
(rev 0)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxWriterBuilder.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.common.xml.stax.writer.builder;
+
+
+import org.gatein.common.xml.stax.writer.StaxWriter;
+import org.gatein.common.xml.stax.writer.formatting.XmlStreamingFormatter;
+import org.staxnav.Naming;
+import org.staxnav.StaxNavException;
+
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.Result;
+import java.io.OutputStream;
+import java.io.Writer;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public interface StaxWriterBuilder
+{
+ StaxWriterBuilder withProperty(String name, Object value);
+
+ StaxWriterBuilder withPropertyIfSupported(String name, Object value);
+
+ StaxWriterBuilder withEncoding(String encoding);
+
+ StaxWriterBuilder withVersion(String version);
+
+ StaxWriterBuilder withFormatting(XmlStreamingFormatter formatter);
+
+ StaxWriterBuilder withOutputStream(OutputStream outputStream);
+
+ StaxWriterBuilder withOutputStream(OutputStream outputStream, String encoding);
+
+ StaxWriterBuilder withWriter(Writer writer);
+
+ StaxWriterBuilder withResult(Result result);
+
+ StaxWriterBuilder withXmlStreamWriter(XMLStreamWriter writer);
+
+ <N> StaxWriter<N> build(Naming<N> naming) throws StaxNavException,
IllegalStateException;
+}
Deleted:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxWriterBuilderImpl.java
===================================================================
---
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxWriterBuilderImpl.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxWriterBuilderImpl.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,224 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.common.xml.stax.writer.builder;
-
-import org.gatein.common.xml.stax.writer.StaxWriter;
-import org.gatein.common.xml.stax.writer.StaxWriterImpl;
-import org.gatein.common.xml.stax.writer.formatting.XmlStreamingFormatter;
-import org.staxnav.Naming;
-import org.staxnav.StaxNavException;
-
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import javax.xml.transform.Result;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class StaxWriterBuilderImpl implements StaxWriterBuilder
-{
- private XMLStreamWriter writer;
- private Object output;
- private String outputEncoding;
- private String version;
- private String encoding;
-
- private XmlStreamingFormatter formatter;
-
- private Map<String, Object> properties = new HashMap<String, Object>();
- private Map<String, Object> supportedProperties = new HashMap<String,
Object>();
-
- public StaxWriterBuilder withProperty(String name, Object value)
- {
- if (name == null) throw new IllegalArgumentException("name is null");
- if (value == null) throw new IllegalArgumentException("value is null");
-
- properties.put(name, value);
- return this;
- }
-
- public StaxWriterBuilder withPropertyIfSupported(String name, Object value)
- {
- if (name == null) throw new IllegalArgumentException("name is null");
- if (value == null) throw new IllegalArgumentException("value is null");
-
- supportedProperties.put(name, value);
- return this;
- }
-
- public StaxWriterBuilder withOutputStream(OutputStream outputStream)
- {
- if (outputStream == null) throw new IllegalArgumentException("outputStream is
null");
-
- output = outputStream;
- return this;
- }
-
- public StaxWriterBuilder withOutputStream(OutputStream outputStream, String encoding)
- {
- if (outputStream == null) throw new IllegalArgumentException("outputStream is
null");
- if (encoding == null) throw new IllegalArgumentException("encoding is
null");
-
- output = outputStream;
- outputEncoding = encoding;
- return this;
- }
-
- public StaxWriterBuilder withWriter(Writer writer)
- {
- if (writer == null) throw new IllegalArgumentException("writer is
null");
-
- this.output = writer;
- return this;
- }
-
- public StaxWriterBuilder withResult(Result result)
- {
- if (result == null) throw new IllegalArgumentException("result is
null");
-
- output = result;
- return this;
- }
-
- public StaxWriterBuilder withXmlStreamWriter(XMLStreamWriter writer)
- {
- if (writer == null) throw new IllegalArgumentException("writer is
null");
-
- this.writer = writer;
- return this;
- }
-
- public StaxWriterBuilder withEncoding(String encoding)
- {
- if (encoding == null) throw new IllegalArgumentException("encoding is
null");
-
- this.encoding = encoding;
- return this;
- }
-
- public StaxWriterBuilder withVersion(String version)
- {
- if (version == null) throw new IllegalArgumentException("version is
null");
-
- this.version = version;
- return this;
- }
-
- public StaxWriterBuilder withFormatting(XmlStreamingFormatter formatter)
- {
- if (formatter == null) throw new IllegalArgumentException("formatter is
null");
-
- this.formatter = formatter;
- return this;
- }
-
- public <N> StaxWriter<N> build(Naming<N> naming) throws
StaxNavException, IllegalStateException
- {
- if (naming == null) throw new IllegalArgumentException("naming is
null");
-
- if (writer == null && output == null)
- throw new IllegalStateException("Cannot build stax writer. Try calling
withOutputStream/withWriter or pass in own XMLStreamWriter.");
-
- if (writer == null)
- {
- //TODO: Create solution to properly cache XMLOutputFactory
- XMLOutputFactory factory = XMLOutputFactory.newInstance();
-
- // Set properties
- for (Map.Entry<String, Object> entry : properties.entrySet())
- {
- factory.setProperty(entry.getKey(), entry.getValue());
- }
-
- // Set properties if supported
- for (Map.Entry<String, Object> entry : supportedProperties.entrySet())
- {
- String name = entry.getKey();
- if (factory.isPropertySupported(name))
- {
- factory.setProperty(name, entry.getValue());
- }
- }
-
- if (output instanceof OutputStream)
- {
- if (outputEncoding != null)
- {
- try
- {
- writer = factory.createXMLStreamWriter((OutputStream) output,
outputEncoding);
- }
- catch (XMLStreamException e)
- {
- throw new StaxNavException(e);
- }
- }
- else
- {
- try
- {
- writer = factory.createXMLStreamWriter((OutputStream) output);
- }
- catch (XMLStreamException e)
- {
- throw new StaxNavException(null, "Exception creating
XMLStreamWriter with OutputStream: " + output, e);
- }
- }
- }
- else if (output instanceof Writer)
- {
- try
- {
- writer = factory.createXMLStreamWriter((Writer) output);
- }
- catch (XMLStreamException e)
- {
- throw new StaxNavException(null, "Exception creating XMLStreamWriter
with Writer: " + output, e);
- }
- }
- else if (output instanceof Result)
- {
- try
- {
- writer = factory.createXMLStreamWriter((Result) output);
- }
- catch (XMLStreamException e)
- {
- throw new StaxNavException(null, "Exception creating XMLStreamWriter
with Result: " + output, e);
- }
- }
- else
- {
- throw new IllegalStateException("Unknown output: " + output); //
should never happen...
- }
- }
-
- return new StaxWriterImpl<N>(naming, writer, formatter, encoding, version);
- }
-}
Copied:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxWriterBuilderImpl.java
(from rev 6958,
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxWriterBuilderImpl.java)
===================================================================
---
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxWriterBuilderImpl.java
(rev 0)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/builder/StaxWriterBuilderImpl.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,224 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.common.xml.stax.writer.builder;
+
+import org.gatein.common.xml.stax.writer.StaxWriter;
+import org.gatein.common.xml.stax.writer.StaxWriterImpl;
+import org.gatein.common.xml.stax.writer.formatting.XmlStreamingFormatter;
+import org.staxnav.Naming;
+import org.staxnav.StaxNavException;
+
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.Result;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class StaxWriterBuilderImpl implements StaxWriterBuilder
+{
+ private XMLStreamWriter writer;
+ private Object output;
+ private String outputEncoding;
+ private String version;
+ private String encoding;
+
+ private XmlStreamingFormatter formatter;
+
+ private Map<String, Object> properties = new HashMap<String, Object>();
+ private Map<String, Object> supportedProperties = new HashMap<String,
Object>();
+
+ public StaxWriterBuilder withProperty(String name, Object value)
+ {
+ if (name == null) throw new IllegalArgumentException("name is null");
+ if (value == null) throw new IllegalArgumentException("value is null");
+
+ properties.put(name, value);
+ return this;
+ }
+
+ public StaxWriterBuilder withPropertyIfSupported(String name, Object value)
+ {
+ if (name == null) throw new IllegalArgumentException("name is null");
+ if (value == null) throw new IllegalArgumentException("value is null");
+
+ supportedProperties.put(name, value);
+ return this;
+ }
+
+ public StaxWriterBuilder withOutputStream(OutputStream outputStream)
+ {
+ if (outputStream == null) throw new IllegalArgumentException("outputStream is
null");
+
+ output = outputStream;
+ return this;
+ }
+
+ public StaxWriterBuilder withOutputStream(OutputStream outputStream, String encoding)
+ {
+ if (outputStream == null) throw new IllegalArgumentException("outputStream is
null");
+ if (encoding == null) throw new IllegalArgumentException("encoding is
null");
+
+ output = outputStream;
+ outputEncoding = encoding;
+ return this;
+ }
+
+ public StaxWriterBuilder withWriter(Writer writer)
+ {
+ if (writer == null) throw new IllegalArgumentException("writer is
null");
+
+ this.output = writer;
+ return this;
+ }
+
+ public StaxWriterBuilder withResult(Result result)
+ {
+ if (result == null) throw new IllegalArgumentException("result is
null");
+
+ output = result;
+ return this;
+ }
+
+ public StaxWriterBuilder withXmlStreamWriter(XMLStreamWriter writer)
+ {
+ if (writer == null) throw new IllegalArgumentException("writer is
null");
+
+ this.writer = writer;
+ return this;
+ }
+
+ public StaxWriterBuilder withEncoding(String encoding)
+ {
+ if (encoding == null) throw new IllegalArgumentException("encoding is
null");
+
+ this.encoding = encoding;
+ return this;
+ }
+
+ public StaxWriterBuilder withVersion(String version)
+ {
+ if (version == null) throw new IllegalArgumentException("version is
null");
+
+ this.version = version;
+ return this;
+ }
+
+ public StaxWriterBuilder withFormatting(XmlStreamingFormatter formatter)
+ {
+ if (formatter == null) throw new IllegalArgumentException("formatter is
null");
+
+ this.formatter = formatter;
+ return this;
+ }
+
+ public <N> StaxWriter<N> build(Naming<N> naming) throws
StaxNavException, IllegalStateException
+ {
+ if (naming == null) throw new IllegalArgumentException("naming is
null");
+
+ if (writer == null && output == null)
+ throw new IllegalStateException("Cannot build stax writer. Try calling
withOutputStream/withWriter or pass in own XMLStreamWriter.");
+
+ if (writer == null)
+ {
+ //TODO: Create solution to properly cache XMLOutputFactory
+ XMLOutputFactory factory = XMLOutputFactory.newInstance();
+
+ // Set properties
+ for (Map.Entry<String, Object> entry : properties.entrySet())
+ {
+ factory.setProperty(entry.getKey(), entry.getValue());
+ }
+
+ // Set properties if supported
+ for (Map.Entry<String, Object> entry : supportedProperties.entrySet())
+ {
+ String name = entry.getKey();
+ if (factory.isPropertySupported(name))
+ {
+ factory.setProperty(name, entry.getValue());
+ }
+ }
+
+ if (output instanceof OutputStream)
+ {
+ if (outputEncoding != null)
+ {
+ try
+ {
+ writer = factory.createXMLStreamWriter((OutputStream) output,
outputEncoding);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new StaxNavException(e);
+ }
+ }
+ else
+ {
+ try
+ {
+ writer = factory.createXMLStreamWriter((OutputStream) output);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new StaxNavException(null, "Exception creating
XMLStreamWriter with OutputStream: " + output, e);
+ }
+ }
+ }
+ else if (output instanceof Writer)
+ {
+ try
+ {
+ writer = factory.createXMLStreamWriter((Writer) output);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new StaxNavException(null, "Exception creating XMLStreamWriter
with Writer: " + output, e);
+ }
+ }
+ else if (output instanceof Result)
+ {
+ try
+ {
+ writer = factory.createXMLStreamWriter((Result) output);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new StaxNavException(null, "Exception creating XMLStreamWriter
with Result: " + output, e);
+ }
+ }
+ else
+ {
+ throw new IllegalStateException("Unknown output: " + output); //
should never happen...
+ }
+ }
+
+ return new StaxWriterImpl<N>(naming, writer, formatter, encoding, version);
+ }
+}
Deleted:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/NoOpFormatter.java
===================================================================
---
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/NoOpFormatter.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/NoOpFormatter.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.common.xml.stax.writer.formatting;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class NoOpFormatter implements XmlStreamingFormatter
-{
- @Override
- public void before(XMLStreamWriter writer, int event) throws XMLStreamException
- {
- // No-op
- }
-
- @Override
- public void after(XMLStreamWriter writer, int event) throws XMLStreamException
- {
- // No-op
- }
-}
Copied:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/NoOpFormatter.java
(from rev 6958,
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/NoOpFormatter.java)
===================================================================
---
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/NoOpFormatter.java
(rev 0)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/NoOpFormatter.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.common.xml.stax.writer.formatting;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NoOpFormatter implements XmlStreamingFormatter
+{
+ @Override
+ public void before(XMLStreamWriter writer, int event) throws XMLStreamException
+ {
+ // No-op
+ }
+
+ @Override
+ public void after(XMLStreamWriter writer, int event) throws XMLStreamException
+ {
+ // No-op
+ }
+}
Deleted:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/SimpleFormatter.java
===================================================================
---
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/SimpleFormatter.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/SimpleFormatter.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,114 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.common.xml.stax.writer.formatting;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class SimpleFormatter implements XmlStreamingFormatter
-{
-
- public static final int DEFAULT_INDENT_SIZE = 3;
- public static final char DEFAULT_INDENT_CHAR = ' ';
- public static final String DEFAULT_NEWLINE;
-
- static
- {
- String newline = null;
- try
- {
- newline = System.getProperty("line.separator");
- }
- catch (Throwable ignored)
- {
- }
- if (newline == null) newline = "\n";
-
- DEFAULT_NEWLINE = newline;
- }
-
- private String indentSequence;
- private String newline;
- private int depth = 0;
-
- private int previousEvent;
-
- public SimpleFormatter()
- {
- this(DEFAULT_INDENT_CHAR, DEFAULT_INDENT_SIZE, DEFAULT_NEWLINE);
- }
-
- public SimpleFormatter(char indentCharacter, int indentSize, String newline)
- {
- if (newline == null) throw new IllegalArgumentException("newline cannot be
null");
- this.newline = newline;
-
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < indentSize; i++)
- {
- sb.append(indentCharacter);
- }
- indentSequence = sb.toString();
- }
-
- public void before(XMLStreamWriter writer, int event) throws XMLStreamException
- {
- switch (event)
- {
- case START_ELEMENT:
- depth++;
- nl(writer);
- indent(writer);
- break;
- case END_ELEMENT:
- if (previousEvent == END_ELEMENT)
- {
- nl(writer);
- indent(writer);
- }
- depth--;
- }
- }
-
- public void after(XMLStreamWriter writer, int event) throws XMLStreamException
- {
- previousEvent = event;
- }
-
- private void nl(XMLStreamWriter writer) throws XMLStreamException
- {
- writer.writeCharacters(newline);
- }
-
- private void indent(XMLStreamWriter writer) throws XMLStreamException
- {
- for (int i = 0; i < depth - 1; i++)
- {
- writer.writeCharacters(indentSequence);
- }
- }
-}
Copied:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/SimpleFormatter.java
(from rev 6958,
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/SimpleFormatter.java)
===================================================================
---
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/SimpleFormatter.java
(rev 0)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/SimpleFormatter.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.common.xml.stax.writer.formatting;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SimpleFormatter implements XmlStreamingFormatter
+{
+
+ public static final int DEFAULT_INDENT_SIZE = 3;
+ public static final char DEFAULT_INDENT_CHAR = ' ';
+ public static final String DEFAULT_NEWLINE;
+
+ static
+ {
+ String newline = null;
+ try
+ {
+ newline = System.getProperty("line.separator");
+ }
+ catch (Throwable ignored)
+ {
+ }
+ if (newline == null) newline = "\n";
+
+ DEFAULT_NEWLINE = newline;
+ }
+
+ private String indentSequence;
+ private String newline;
+ private int depth = 0;
+
+ private int previousEvent;
+
+ public SimpleFormatter()
+ {
+ this(DEFAULT_INDENT_CHAR, DEFAULT_INDENT_SIZE, DEFAULT_NEWLINE);
+ }
+
+ public SimpleFormatter(char indentCharacter, int indentSize, String newline)
+ {
+ if (newline == null) throw new IllegalArgumentException("newline cannot be
null");
+ this.newline = newline;
+
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < indentSize; i++)
+ {
+ sb.append(indentCharacter);
+ }
+ indentSequence = sb.toString();
+ }
+
+ public void before(XMLStreamWriter writer, int event) throws XMLStreamException
+ {
+ switch (event)
+ {
+ case START_ELEMENT:
+ depth++;
+ nl(writer);
+ indent(writer);
+ break;
+ case END_ELEMENT:
+ if (previousEvent == END_ELEMENT)
+ {
+ nl(writer);
+ indent(writer);
+ }
+ depth--;
+ }
+ }
+
+ public void after(XMLStreamWriter writer, int event) throws XMLStreamException
+ {
+ previousEvent = event;
+ }
+
+ private void nl(XMLStreamWriter writer) throws XMLStreamException
+ {
+ writer.writeCharacters(newline);
+ }
+
+ private void indent(XMLStreamWriter writer) throws XMLStreamException
+ {
+ for (int i = 0; i < depth - 1; i++)
+ {
+ writer.writeCharacters(indentSequence);
+ }
+ }
+}
Deleted:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/XmlStreamingFormatter.java
===================================================================
---
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/XmlStreamingFormatter.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/XmlStreamingFormatter.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.common.xml.stax.writer.formatting;
-
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public interface XmlStreamingFormatter extends XMLStreamConstants
-{
- void before(XMLStreamWriter writer, int event) throws XMLStreamException;
-
- void after(XMLStreamWriter writer, int event) throws XMLStreamException;
-}
Copied:
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/XmlStreamingFormatter.java
(from rev 6958,
portal/branches/gatein-management/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/XmlStreamingFormatter.java)
===================================================================
---
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/XmlStreamingFormatter.java
(rev 0)
+++
portal/trunk/component/common/src/main/java/org/gatein/common/xml/stax/writer/formatting/XmlStreamingFormatter.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.common.xml.stax.writer.formatting;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public interface XmlStreamingFormatter extends XMLStreamConstants
+{
+ void before(XMLStreamWriter writer, int event) throws XMLStreamException;
+
+ void after(XMLStreamWriter writer, int event) throws XMLStreamException;
+}
Deleted:
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/AbstractStaxWriterTest.java
===================================================================
---
portal/branches/gatein-management/component/common/src/test/java/org/gatein/common/xml/stax/AbstractStaxWriterTest.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/AbstractStaxWriterTest.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,357 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.common.xml.stax;
-
-import junit.framework.TestCase;
-import org.gatein.common.xml.stax.writer.StaxWriter;
-import org.gatein.common.xml.stax.writer.StaxWriterImpl;
-import org.gatein.common.xml.stax.writer.WritableValueType;
-import org.gatein.common.xml.stax.writer.formatting.XmlStreamingFormatter;
-import org.mockito.InOrder;
-import org.staxnav.Naming;
-
-import javax.xml.XMLConstants;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamWriter;
-
-import static org.mockito.Mockito.*;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public abstract class AbstractStaxWriterTest<N> extends TestCase
-{
- static final String ENCODING = "UTF-8";
- static final String VERSION = "1.0";
-
- private Naming<N> naming;
- protected XMLStreamWriter stream;
- protected XmlStreamingFormatter formatter;
- protected StaxWriter<N> writer;
-
- public abstract Naming<N> getNaming();
-
- @Override
- public void setUp() throws Exception
- {
- naming = getNaming();
- formatter = mock(XmlStreamingFormatter.class);
- stream = mock(XMLStreamWriter.class);
- writer = new StaxWriterImpl<N>(naming, stream, formatter, ENCODING,
VERSION);
- }
-
- protected N createName(String localPart)
- {
- return naming.getName(null, null, localPart);
- }
-
- public void testEncodingAndVersion() throws Exception
- {
- String encoding = "UTF-8";
- String version = "1.0";
- StaxWriter<N> writer = new StaxWriterImpl<N>(naming, stream, formatter,
encoding, version);
- writer.writeElement(createName("foo"), "blah");
-
- verify(stream).writeStartDocument(encoding, version);
-
- reset(stream);
- encoding = "encoding";
- version = "version";
- writer = new StaxWriterImpl<N>(naming, stream, formatter, encoding,
version);
- writer.writeElement(createName("foo"), "blah");
-
- verify(stream).writeStartDocument(encoding, version);
- }
-
- public void testEncoding() throws Exception
- {
- String encoding = "ISO-8859-1";
- StaxWriter<N> writer = new StaxWriterImpl<N>(naming, stream, formatter,
encoding, null);
- writer.writeElement(createName("foo"), "blah");
-
- verify(stream).writeStartDocument(encoding, null);
- }
-
- public void testNoEncoding() throws Exception
- {
- StaxWriter<N> writer = new StaxWriterImpl<N>(naming, stream,
formatter);
- writer.writeElement(createName("foo"), "blah");
-
- verify(stream).writeStartDocument();
- }
-
- public void testStartDocument() throws Exception
- {
- writer.writeStartElement(createName("foo"));
- writer.writeComment("some comment");
- writer.writeCData("some cdata < & ...");
-
- verify(stream, times(1)).writeStartDocument(ENCODING, VERSION);
-
- }
-
- public void testWriteStartElement() throws Exception
- {
- writer.writeStartElement(createName("foo"));
- verify(stream).writeStartElement("foo");
- }
-
- public void testWriteAttribute() throws Exception
- {
-
writer.writeStartElement(createName("foo")).writeAttribute("name",
"value");
-
- verify(stream).writeAttribute("name", "value");
- }
-
- public void testWriteQNameAttribute() throws Exception
- {
- writer.writeStartElement(createName("foo"))
- .writeAttribute(new QName("uri", "local", "pre"),
"value")
- .writeAttribute(new QName("uri", "local"),
"value");
-
- verify(stream).writeAttribute("pre", "uri", "local",
"value");
- verify(stream).writeAttribute("uri", "local",
"value");
- }
-
- public void testWriteElement() throws Exception
- {
- writer.writeElement(createName("foo"), "content");
-
- verify(stream).writeStartElement("foo");
- verify(stream).writeCharacters("content");
- verify(stream).writeEndElement();
- }
-
- public void testWriteContent() throws Exception
- {
-
-
writer.writeStartElement(createName("foo")).writeContent("blah");
- verify(stream).writeCharacters("blah");
-
- WritableValueType<String> vt = new WritableValueType<String>()
- {
- @Override
- public String format(String value)
- {
- return "some value";
- }
- };
-
- writer.writeStartElement(createName("bar")).writeContent(vt,
"content");
- verify(stream).writeCharacters("some value");
- }
-
- public void testWriteNullContent() throws Exception
- {
- try
- {
- writer.writeContent(null);
- fail("IllegalArgumentException expected to be thrown");
- }
- catch (IllegalArgumentException e){}
- }
-
- public void testNamespace() throws Exception
- {
-
writer.writeStartElement(createName("foo")).writeNamespace("xsi",
XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
-
- verify(stream).writeNamespace("xsi",
XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
- }
-
- public void testDefaultNamespace() throws Exception
- {
- String namespace = "http://www.example.com/ns/mynamespace";
-
-
writer.writeStartElement(createName("foo")).writeDefaultNamespace(namespace);
-
- verify(stream).writeDefaultNamespace(namespace);
- }
-
- public void testComment() throws Exception
- {
- writer.writeComment("Some comment");
- writer.writeStartElement(createName("foo"));
-
- verify(stream, times(1)).writeStartDocument(ENCODING, VERSION);
- verify(stream).writeComment("Some comment");
- }
-
- public void testCData() throws Exception
- {
- String cdata = "Some cdata stuff here < & \" ";
- writer.writeCData(cdata);
- writer.writeStartElement(createName("foo"));
-
- verify(stream).writeStartDocument(ENCODING, VERSION);
- verify(stream).writeCData(cdata);
- }
-
- public void testFinish() throws Exception
- {
- writer.writeStartElement(createName("foo")).finish();
-
- verify(stream).flush();
- verify(stream).close();
- }
-
- public void testFinishNoElements() throws Exception
- {
- writer.writeComment("comment");
- writer.finish();
- verify(stream).flush();
- verify(stream).close();
- }
-
- public void testEndElementOnFinish() throws Exception
- {
- writer.writeStartElement(createName("foo")).
- writeStartElement(createName("bar")).
- writeElement(createName("foobar"), "stuff");
-
- // Even though we never explicitly call endElement for the first two start
elements, finish will do that for us.
- writer.finish();
-
- verify(stream).writeStartElement("foo");
- verify(stream).writeStartElement("bar");
- verify(stream).writeStartElement("foobar");
- verify(stream).writeCharacters("stuff");
- verify(stream, times(3)).writeEndElement();
- }
-
- public void testFormatter() throws Exception
- {
- InOrder order = inOrder(formatter, stream);
-
- // Start element
- writer.writeStartElement(createName("foo"));
- verifyFormatter(order, XMLStreamConstants.START_DOCUMENT, new VerifyClosure()
- {
- public void verify(InOrder order) throws Exception
- {
- // first start element also writes the document
- order.verify(stream).writeStartDocument(ENCODING, VERSION);
- }
- });
- verifyFormatter(order, XMLStreamConstants.START_ELEMENT, new VerifyClosure()
- {
- public void verify(InOrder order) throws Exception
- {
- order.verify(stream).writeStartElement("foo");
- }
- });
-
- // Namespace
- writer.writeNamespace("prefix", "uri");
- verifyFormatter(order, XMLStreamConstants.NAMESPACE, new VerifyClosure()
- {
- public void verify(InOrder order) throws Exception
- {
- order.verify(stream).writeNamespace("prefix", "uri");
- }
- });
-
- // Default namespace
- writer.writeDefaultNamespace("uri");
- verifyFormatter(order, XMLStreamConstants.NAMESPACE, new VerifyClosure()
- {
- public void verify(InOrder order) throws Exception
- {
- order.verify(stream).writeDefaultNamespace("uri");
- }
- });
-
- // Attribute
- writer.writeAttribute("name", "value");
- verifyFormatter(order, XMLStreamConstants.ATTRIBUTE, new VerifyClosure()
- {
- public void verify(InOrder order) throws Exception
- {
- order.verify(stream).writeAttribute("name", "value");
- }
- });
-
- // Comment
- writer.writeComment("comment");
- verifyFormatter(order, XMLStreamConstants.COMMENT, new VerifyClosure()
- {
- public void verify(InOrder order) throws Exception
- {
- order.verify(stream).writeComment("comment");
- }
- });
-
- // CData
- writer.writeCData("cdata");
- verifyFormatter(order, XMLStreamConstants.CDATA, new VerifyClosure()
- {
- public void verify(InOrder order) throws Exception
- {
- order.verify(stream).writeCData("cdata");
- }
- });
-
- // Content
- writer.writeContent("content");
- verifyFormatter(order, XMLStreamConstants.CHARACTERS, new VerifyClosure()
- {
- public void verify(InOrder order) throws Exception
- {
- order.verify(stream).writeCharacters("content");
- }
- });
-
- // End element
- writer.writeEndElement();
- verifyFormatter(order, XMLStreamConstants.END_ELEMENT, new VerifyClosure()
- {
- public void verify(InOrder order) throws Exception
- {
- order.verify(stream).writeEndElement();
- }
- });
-
- // End document
- writer.finish();
- verifyFormatter(order, XMLStreamConstants.END_DOCUMENT, new VerifyClosure()
- {
- public void verify(InOrder order) throws Exception
- {
- order.verify(stream).writeEndDocument();
- }
- });
- }
-
- protected void verifyFormatter(InOrder order, int event, VerifyClosure closure) throws
Exception
- {
- order.verify(formatter).before(stream, event);
- closure.verify(order);
- order.verify(formatter).after(stream, event);
- }
-
- private static interface VerifyClosure
- {
- void verify(InOrder order) throws Exception;
- }
-}
Copied:
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/AbstractStaxWriterTest.java
(from rev 6958,
portal/branches/gatein-management/component/common/src/test/java/org/gatein/common/xml/stax/AbstractStaxWriterTest.java)
===================================================================
---
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/AbstractStaxWriterTest.java
(rev 0)
+++
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/AbstractStaxWriterTest.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,357 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.common.xml.stax;
+
+import junit.framework.TestCase;
+import org.gatein.common.xml.stax.writer.StaxWriter;
+import org.gatein.common.xml.stax.writer.StaxWriterImpl;
+import org.gatein.common.xml.stax.writer.WritableValueType;
+import org.gatein.common.xml.stax.writer.formatting.XmlStreamingFormatter;
+import org.mockito.InOrder;
+import org.staxnav.Naming;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamWriter;
+
+import static org.mockito.Mockito.*;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class AbstractStaxWriterTest<N> extends TestCase
+{
+ static final String ENCODING = "UTF-8";
+ static final String VERSION = "1.0";
+
+ private Naming<N> naming;
+ protected XMLStreamWriter stream;
+ protected XmlStreamingFormatter formatter;
+ protected StaxWriter<N> writer;
+
+ public abstract Naming<N> getNaming();
+
+ @Override
+ public void setUp() throws Exception
+ {
+ naming = getNaming();
+ formatter = mock(XmlStreamingFormatter.class);
+ stream = mock(XMLStreamWriter.class);
+ writer = new StaxWriterImpl<N>(naming, stream, formatter, ENCODING,
VERSION);
+ }
+
+ protected N createName(String localPart)
+ {
+ return naming.getName(null, null, localPart);
+ }
+
+ public void testEncodingAndVersion() throws Exception
+ {
+ String encoding = "UTF-8";
+ String version = "1.0";
+ StaxWriter<N> writer = new StaxWriterImpl<N>(naming, stream, formatter,
encoding, version);
+ writer.writeElement(createName("foo"), "blah");
+
+ verify(stream).writeStartDocument(encoding, version);
+
+ reset(stream);
+ encoding = "encoding";
+ version = "version";
+ writer = new StaxWriterImpl<N>(naming, stream, formatter, encoding,
version);
+ writer.writeElement(createName("foo"), "blah");
+
+ verify(stream).writeStartDocument(encoding, version);
+ }
+
+ public void testEncoding() throws Exception
+ {
+ String encoding = "ISO-8859-1";
+ StaxWriter<N> writer = new StaxWriterImpl<N>(naming, stream, formatter,
encoding, null);
+ writer.writeElement(createName("foo"), "blah");
+
+ verify(stream).writeStartDocument(encoding, null);
+ }
+
+ public void testNoEncoding() throws Exception
+ {
+ StaxWriter<N> writer = new StaxWriterImpl<N>(naming, stream,
formatter);
+ writer.writeElement(createName("foo"), "blah");
+
+ verify(stream).writeStartDocument();
+ }
+
+ public void testStartDocument() throws Exception
+ {
+ writer.writeStartElement(createName("foo"));
+ writer.writeComment("some comment");
+ writer.writeCData("some cdata < & ...");
+
+ verify(stream, times(1)).writeStartDocument(ENCODING, VERSION);
+
+ }
+
+ public void testWriteStartElement() throws Exception
+ {
+ writer.writeStartElement(createName("foo"));
+ verify(stream).writeStartElement("foo");
+ }
+
+ public void testWriteAttribute() throws Exception
+ {
+
writer.writeStartElement(createName("foo")).writeAttribute("name",
"value");
+
+ verify(stream).writeAttribute("name", "value");
+ }
+
+ public void testWriteQNameAttribute() throws Exception
+ {
+ writer.writeStartElement(createName("foo"))
+ .writeAttribute(new QName("uri", "local", "pre"),
"value")
+ .writeAttribute(new QName("uri", "local"),
"value");
+
+ verify(stream).writeAttribute("pre", "uri", "local",
"value");
+ verify(stream).writeAttribute("uri", "local",
"value");
+ }
+
+ public void testWriteElement() throws Exception
+ {
+ writer.writeElement(createName("foo"), "content");
+
+ verify(stream).writeStartElement("foo");
+ verify(stream).writeCharacters("content");
+ verify(stream).writeEndElement();
+ }
+
+ public void testWriteContent() throws Exception
+ {
+
+
writer.writeStartElement(createName("foo")).writeContent("blah");
+ verify(stream).writeCharacters("blah");
+
+ WritableValueType<String> vt = new WritableValueType<String>()
+ {
+ @Override
+ public String format(String value)
+ {
+ return "some value";
+ }
+ };
+
+ writer.writeStartElement(createName("bar")).writeContent(vt,
"content");
+ verify(stream).writeCharacters("some value");
+ }
+
+ public void testWriteNullContent() throws Exception
+ {
+ try
+ {
+ writer.writeContent(null);
+ fail("IllegalArgumentException expected to be thrown");
+ }
+ catch (IllegalArgumentException e){}
+ }
+
+ public void testNamespace() throws Exception
+ {
+
writer.writeStartElement(createName("foo")).writeNamespace("xsi",
XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
+
+ verify(stream).writeNamespace("xsi",
XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
+ }
+
+ public void testDefaultNamespace() throws Exception
+ {
+ String namespace = "http://www.example.com/ns/mynamespace";
+
+
writer.writeStartElement(createName("foo")).writeDefaultNamespace(namespace);
+
+ verify(stream).writeDefaultNamespace(namespace);
+ }
+
+ public void testComment() throws Exception
+ {
+ writer.writeComment("Some comment");
+ writer.writeStartElement(createName("foo"));
+
+ verify(stream, times(1)).writeStartDocument(ENCODING, VERSION);
+ verify(stream).writeComment("Some comment");
+ }
+
+ public void testCData() throws Exception
+ {
+ String cdata = "Some cdata stuff here < & \" ";
+ writer.writeCData(cdata);
+ writer.writeStartElement(createName("foo"));
+
+ verify(stream).writeStartDocument(ENCODING, VERSION);
+ verify(stream).writeCData(cdata);
+ }
+
+ public void testFinish() throws Exception
+ {
+ writer.writeStartElement(createName("foo")).finish();
+
+ verify(stream).flush();
+ verify(stream).close();
+ }
+
+ public void testFinishNoElements() throws Exception
+ {
+ writer.writeComment("comment");
+ writer.finish();
+ verify(stream).flush();
+ verify(stream).close();
+ }
+
+ public void testEndElementOnFinish() throws Exception
+ {
+ writer.writeStartElement(createName("foo")).
+ writeStartElement(createName("bar")).
+ writeElement(createName("foobar"), "stuff");
+
+ // Even though we never explicitly call endElement for the first two start
elements, finish will do that for us.
+ writer.finish();
+
+ verify(stream).writeStartElement("foo");
+ verify(stream).writeStartElement("bar");
+ verify(stream).writeStartElement("foobar");
+ verify(stream).writeCharacters("stuff");
+ verify(stream, times(3)).writeEndElement();
+ }
+
+ public void testFormatter() throws Exception
+ {
+ InOrder order = inOrder(formatter, stream);
+
+ // Start element
+ writer.writeStartElement(createName("foo"));
+ verifyFormatter(order, XMLStreamConstants.START_DOCUMENT, new VerifyClosure()
+ {
+ public void verify(InOrder order) throws Exception
+ {
+ // first start element also writes the document
+ order.verify(stream).writeStartDocument(ENCODING, VERSION);
+ }
+ });
+ verifyFormatter(order, XMLStreamConstants.START_ELEMENT, new VerifyClosure()
+ {
+ public void verify(InOrder order) throws Exception
+ {
+ order.verify(stream).writeStartElement("foo");
+ }
+ });
+
+ // Namespace
+ writer.writeNamespace("prefix", "uri");
+ verifyFormatter(order, XMLStreamConstants.NAMESPACE, new VerifyClosure()
+ {
+ public void verify(InOrder order) throws Exception
+ {
+ order.verify(stream).writeNamespace("prefix", "uri");
+ }
+ });
+
+ // Default namespace
+ writer.writeDefaultNamespace("uri");
+ verifyFormatter(order, XMLStreamConstants.NAMESPACE, new VerifyClosure()
+ {
+ public void verify(InOrder order) throws Exception
+ {
+ order.verify(stream).writeDefaultNamespace("uri");
+ }
+ });
+
+ // Attribute
+ writer.writeAttribute("name", "value");
+ verifyFormatter(order, XMLStreamConstants.ATTRIBUTE, new VerifyClosure()
+ {
+ public void verify(InOrder order) throws Exception
+ {
+ order.verify(stream).writeAttribute("name", "value");
+ }
+ });
+
+ // Comment
+ writer.writeComment("comment");
+ verifyFormatter(order, XMLStreamConstants.COMMENT, new VerifyClosure()
+ {
+ public void verify(InOrder order) throws Exception
+ {
+ order.verify(stream).writeComment("comment");
+ }
+ });
+
+ // CData
+ writer.writeCData("cdata");
+ verifyFormatter(order, XMLStreamConstants.CDATA, new VerifyClosure()
+ {
+ public void verify(InOrder order) throws Exception
+ {
+ order.verify(stream).writeCData("cdata");
+ }
+ });
+
+ // Content
+ writer.writeContent("content");
+ verifyFormatter(order, XMLStreamConstants.CHARACTERS, new VerifyClosure()
+ {
+ public void verify(InOrder order) throws Exception
+ {
+ order.verify(stream).writeCharacters("content");
+ }
+ });
+
+ // End element
+ writer.writeEndElement();
+ verifyFormatter(order, XMLStreamConstants.END_ELEMENT, new VerifyClosure()
+ {
+ public void verify(InOrder order) throws Exception
+ {
+ order.verify(stream).writeEndElement();
+ }
+ });
+
+ // End document
+ writer.finish();
+ verifyFormatter(order, XMLStreamConstants.END_DOCUMENT, new VerifyClosure()
+ {
+ public void verify(InOrder order) throws Exception
+ {
+ order.verify(stream).writeEndDocument();
+ }
+ });
+ }
+
+ protected void verifyFormatter(InOrder order, int event, VerifyClosure closure) throws
Exception
+ {
+ order.verify(formatter).before(stream, event);
+ closure.verify(order);
+ order.verify(formatter).after(stream, event);
+ }
+
+ private static interface VerifyClosure
+ {
+ void verify(InOrder order) throws Exception;
+ }
+}
Deleted:
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/LocalStaxWriterTest.java
===================================================================
---
portal/branches/gatein-management/component/common/src/test/java/org/gatein/common/xml/stax/LocalStaxWriterTest.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/LocalStaxWriterTest.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,34 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.common.xml.stax;
-
-import org.staxnav.Naming;
-
-public class LocalStaxWriterTest extends AbstractStaxWriterTest<String>
-{
- @Override
- public Naming<String> getNaming()
- {
- return new Naming.Local();
- }
-}
\ No newline at end of file
Copied:
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/LocalStaxWriterTest.java
(from rev 6958,
portal/branches/gatein-management/component/common/src/test/java/org/gatein/common/xml/stax/LocalStaxWriterTest.java)
===================================================================
---
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/LocalStaxWriterTest.java
(rev 0)
+++
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/LocalStaxWriterTest.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.common.xml.stax;
+
+import org.staxnav.Naming;
+
+public class LocalStaxWriterTest extends AbstractStaxWriterTest<String>
+{
+ @Override
+ public Naming<String> getNaming()
+ {
+ return new Naming.Local();
+ }
+}
\ No newline at end of file
Deleted:
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/QualifiedStaxWriterTest.java
===================================================================
---
portal/branches/gatein-management/component/common/src/test/java/org/gatein/common/xml/stax/QualifiedStaxWriterTest.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/QualifiedStaxWriterTest.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.common.xml.stax;
-
-import org.mockito.Mockito;
-import org.staxnav.Naming;
-
-import javax.xml.namespace.QName;
-
-public class QualifiedStaxWriterTest extends AbstractStaxWriterTest<QName>
-{
- @Override
- public Naming<QName> getNaming()
- {
- return new Naming.Qualified();
- }
-
- public void testWriteQualifiedStartElement() throws Exception
- {
- QName bar = new QName("uri", "pre", "bar");
-
- writer.writeStartElement(bar);
- Mockito.verify(stream).writeStartElement(bar.getPrefix(), bar.getLocalPart(),
bar.getNamespaceURI());
-
- QName foobar = new
QName("http://www.gatein.org/xml/ns/gatein_objects_1_0", "foobar");
- writer.writeStartElement(foobar);
- Mockito.verify(stream).writeStartElement(foobar.getNamespaceURI(),
foobar.getLocalPart());
- }
-}
\ No newline at end of file
Copied:
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/QualifiedStaxWriterTest.java
(from rev 6958,
portal/branches/gatein-management/component/common/src/test/java/org/gatein/common/xml/stax/QualifiedStaxWriterTest.java)
===================================================================
---
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/QualifiedStaxWriterTest.java
(rev 0)
+++
portal/trunk/component/common/src/test/java/org/gatein/common/xml/stax/QualifiedStaxWriterTest.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.common.xml.stax;
+
+import org.mockito.Mockito;
+import org.staxnav.Naming;
+
+import javax.xml.namespace.QName;
+
+public class QualifiedStaxWriterTest extends AbstractStaxWriterTest<QName>
+{
+ @Override
+ public Naming<QName> getNaming()
+ {
+ return new Naming.Qualified();
+ }
+
+ public void testWriteQualifiedStartElement() throws Exception
+ {
+ QName bar = new QName("uri", "pre", "bar");
+
+ writer.writeStartElement(bar);
+ Mockito.verify(stream).writeStartElement(bar.getPrefix(), bar.getLocalPart(),
bar.getNamespaceURI());
+
+ QName foobar = new
QName("http://www.gatein.org/xml/ns/gatein_objects_1_0", "foobar");
+ writer.writeStartElement(foobar);
+ Mockito.verify(stream).writeStartElement(foobar.getNamespaceURI(),
foobar.getLocalPart());
+ }
+}
\ No newline at end of file
Modified: portal/trunk/component/management/pom.xml
===================================================================
--- portal/trunk/component/management/pom.xml 2011-07-30 02:15:53 UTC (rev 6959)
+++ portal/trunk/component/management/pom.xml 2011-07-30 02:53:38 UTC (rev 6960)
@@ -43,6 +43,13 @@
<groupId>org.exoplatform.ws</groupId>
<artifactId>exo.ws.rest.core</artifactId>
</dependency>
-
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-rest</artifactId>
+ </dependency>
</dependencies>
</project>
Deleted:
portal/trunk/component/management/src/main/java/org/gatein/management/runtime/ManagementBootstrap.java
===================================================================
---
portal/branches/gatein-management/component/management/src/main/java/org/gatein/management/runtime/ManagementBootstrap.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/management/src/main/java/org/gatein/management/runtime/ManagementBootstrap.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,30 +0,0 @@
-package org.gatein.management.runtime;
-
-import org.gatein.management.api.ManagementService;
-import org.picocontainer.Startable;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class ManagementBootstrap implements Startable
-{
- private ManagementService service;
-
- public ManagementBootstrap(ManagementService service)
- {
- this.service = service;
- }
-
- @Override
- public void start()
- {
- service.load();
- }
-
- @Override
- public void stop()
- {
- service.unload();
- }
-}
Copied:
portal/trunk/component/management/src/main/java/org/gatein/management/runtime/ManagementBootstrap.java
(from rev 6958,
portal/branches/gatein-management/component/management/src/main/java/org/gatein/management/runtime/ManagementBootstrap.java)
===================================================================
---
portal/trunk/component/management/src/main/java/org/gatein/management/runtime/ManagementBootstrap.java
(rev 0)
+++
portal/trunk/component/management/src/main/java/org/gatein/management/runtime/ManagementBootstrap.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,30 @@
+package org.gatein.management.runtime;
+
+import org.gatein.management.api.ManagementService;
+import org.picocontainer.Startable;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class ManagementBootstrap implements Startable
+{
+ private ManagementService service;
+
+ public ManagementBootstrap(ManagementService service)
+ {
+ this.service = service;
+ }
+
+ @Override
+ public void start()
+ {
+ service.load();
+ }
+
+ @Override
+ public void stop()
+ {
+ service.unload();
+ }
+}
Deleted:
portal/trunk/component/management/src/main/java/org/gatein/management/runtime/RuntimeContextImpl.java
===================================================================
---
portal/branches/gatein-management/component/management/src/main/java/org/gatein/management/runtime/RuntimeContextImpl.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/management/src/main/java/org/gatein/management/runtime/RuntimeContextImpl.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,17 +0,0 @@
-package org.gatein.management.runtime;
-
-import org.exoplatform.container.PortalContainer;
-import org.gatein.management.api.RuntimeContext;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class RuntimeContextImpl implements RuntimeContext
-{
- @Override
- public <T> T getRuntimeComponent(Class<T> componentClass)
- {
- return
componentClass.cast(PortalContainer.getInstance().getComponentInstanceOfType(componentClass));
- }
-}
Copied:
portal/trunk/component/management/src/main/java/org/gatein/management/runtime/RuntimeContextImpl.java
(from rev 6958,
portal/branches/gatein-management/component/management/src/main/java/org/gatein/management/runtime/RuntimeContextImpl.java)
===================================================================
---
portal/trunk/component/management/src/main/java/org/gatein/management/runtime/RuntimeContextImpl.java
(rev 0)
+++
portal/trunk/component/management/src/main/java/org/gatein/management/runtime/RuntimeContextImpl.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,17 @@
+package org.gatein.management.runtime;
+
+import org.exoplatform.container.PortalContainer;
+import org.gatein.management.api.RuntimeContext;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class RuntimeContextImpl implements RuntimeContext
+{
+ @Override
+ public <T> T getRuntimeComponent(Class<T> componentClass)
+ {
+ return
componentClass.cast(PortalContainer.getInstance().getComponentInstanceOfType(componentClass));
+ }
+}
Deleted:
portal/trunk/component/management/src/main/resources/conf/portal/configuration.xml
===================================================================
---
portal/branches/gatein-management/component/management/src/main/resources/conf/portal/configuration.xml 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/management/src/main/resources/conf/portal/configuration.xml 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,50 +0,0 @@
-<!--
- ~ JBoss, Home of Professional Open Source.
- ~ Copyright 2011, Red Hat, Inc., and individual contributors
- ~ as indicated by the @author tags. See the copyright.txt file in the
- ~ distribution for a full listing of individual contributors.
- ~
- ~ This is free software; you can redistribute it and/or modify it
- ~ under the terms of the GNU Lesser General Public License as
- ~ published by the Free Software Foundation; either version 2.1 of
- ~ the License, or (at your option) any later version.
- ~
- ~ This software is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
- ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- ~ Lesser General Public License for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public
- ~ License along with this software; if not, write to the Free
- ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- -->
-
-<configuration
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd
http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
-
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
-
- <component>
- <key>org.gatein.management.api.ManagementService</key>
- <type>org.gatein.management.core.api.ManagementServiceImpl</type>
- </component>
-
- <component>
- <key>org.gatein.management.api.controller.ManagementController</key>
-
<type>org.gatein.management.core.api.controller.SimpleManagementController</type>
- </component>
-
- <component>
- <type>org.gatein.management.rest.RestApplication</type>
- </component>
-
- <component>
- <type>org.gatein.management.runtime.RuntimeContextImpl</type>
- </component>
-
- <component>
- <type>org.gatein.management.runtime.ManagementBootstrap</type>
- </component>
-
-</configuration>
\ No newline at end of file
Copied: portal/trunk/component/management/src/main/resources/conf/portal/configuration.xml
(from rev 6958,
portal/branches/gatein-management/component/management/src/main/resources/conf/portal/configuration.xml)
===================================================================
--- portal/trunk/component/management/src/main/resources/conf/portal/configuration.xml
(rev 0)
+++
portal/trunk/component/management/src/main/resources/conf/portal/configuration.xml 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,50 @@
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ -->
+
+<configuration
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd
http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
+
+ <component>
+ <key>org.gatein.management.api.ManagementService</key>
+ <type>org.gatein.management.core.api.ManagementServiceImpl</type>
+ </component>
+
+ <component>
+ <key>org.gatein.management.api.controller.ManagementController</key>
+
<type>org.gatein.management.core.api.controller.SimpleManagementController</type>
+ </component>
+
+ <component>
+ <type>org.gatein.management.rest.RestApplication</type>
+ </component>
+
+ <component>
+ <type>org.gatein.management.runtime.RuntimeContextImpl</type>
+ </component>
+
+ <component>
+ <type>org.gatein.management.runtime.ManagementBootstrap</type>
+ </component>
+
+</configuration>
\ No newline at end of file
Modified: portal/trunk/component/portal/pom.xml
===================================================================
--- portal/trunk/component/portal/pom.xml 2011-07-30 02:15:53 UTC (rev 6959)
+++ portal/trunk/component/portal/pom.xml 2011-07-30 02:53:38 UTC (rev 6960)
@@ -74,6 +74,11 @@
</dependency>
<dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-spi</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-core</artifactId>
</dependency>
@@ -114,6 +119,13 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>1.8.5</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java 2011-07-30
02:15:53 UTC (rev 6959)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -217,6 +217,8 @@
*/
public void saveDashboard(Dashboard dashboard) throws Exception;
+ public void save() throws Exception;
+
/**
* Returns the list of all portal names.
*
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java 2011-07-30
02:15:53 UTC (rev 6959)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -285,6 +285,11 @@
delegate.save(portletPreferences);
}
+ public void save() throws Exception
+ {
+ delegate.save();
+ }
+
public PortalConfig getPortalConfig(String ownerType, String portalName) throws
Exception
{
PortalKey key = new PortalKey(ownerType, portalName);
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,129 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management;
-
-import org.exoplatform.portal.mop.management.binding.MopBindingProvider;
-import org.exoplatform.portal.mop.management.operations.MopImportResource;
-import org.exoplatform.portal.mop.management.operations.MopReadResource;
-import
org.exoplatform.portal.mop.management.operations.navigation.NavigationExportResource;
-import
org.exoplatform.portal.mop.management.operations.navigation.NavigationReadConfigAsXml;
-import
org.exoplatform.portal.mop.management.operations.navigation.NavigationReadResource;
-import org.exoplatform.portal.mop.management.operations.page.PageExportResource;
-import org.exoplatform.portal.mop.management.operations.page.PageReadConfigAsXml;
-import org.exoplatform.portal.mop.management.operations.page.PageReadResource;
-import org.exoplatform.portal.mop.management.operations.site.SiteLayoutExportResource;
-import org.exoplatform.portal.mop.management.operations.site.SiteLayoutReadConfigAsXml;
-import org.exoplatform.portal.mop.management.operations.site.SiteReadResource;
-import org.exoplatform.portal.mop.management.operations.site.SiteTypeReadResource;
-import org.gatein.management.api.ComponentRegistration;
-import org.gatein.management.api.ManagedDescription;
-import org.gatein.management.api.ManagedResource;
-import org.gatein.management.api.operation.OperationNames;
-import org.gatein.management.spi.ExtensionContext;
-import org.gatein.management.spi.ManagementExtension;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class MopManagementExtension implements ManagementExtension
-{
- @Override
- public void initialize(ExtensionContext context)
- {
- ComponentRegistration registration =
context.registerManagedComponent("mop");
- registration.registerBindingProvider(MopBindingProvider.INSTANCE);
-
- ManagedResource.Registration mop =
registration.registerManagedResource(description("MOP (Model Object for Portal)
Managed Resource"));
- mop.registerOperationHandler(OperationNames.IMPORT_RESOURCE, new
MopImportResource(), description("Imports mop data from an exported zip
file."));
-
- mop.registerOperationHandler(OperationNames.READ_RESOURCE, new MopReadResource(),
description("Available site types for a portal"));
-
- ManagedResource.Registration sitetypes =
mop.registerSubResource("{site-type}sites", description("Management
resource responsible for handling management operations on a specific site type for a
portal."));
- sitetypes.registerOperationHandler(OperationNames.READ_RESOURCE, new
SiteTypeReadResource(), description("Available sites for a given site type."));
-
- ManagedResource.Registration sites =
sitetypes.registerSubResource("{site-name: .*}", description("Management
resource responsible for handling management operations on a specific site."));
- sites.registerOperationHandler(OperationNames.READ_RESOURCE, new
SiteReadResource(), description("Available artifacts for a given site (ie pages,
navigation, site layout)"));
-
- // Site Layout management
- siteLayoutManagementRegistration(sites);
-
- // Page management
- pageManagementRegistration(sites);
-
- // Navigation management
- navigationManagementRegistration(sites);
- }
-
- private void siteLayoutManagementRegistration(ManagedResource.Registration sites)
- {
- ManagedResource.Registration siteLayout =
sites.registerSubResource("portal", description("Management resource
responsible for handling management operations for a site layout."));
- siteLayout.registerOperationHandler(OperationNames.READ_CONFIG_AS_XML, new
SiteLayoutReadConfigAsXml(), description("Reads site layout data for a specific site
as configuration xml."));
- siteLayout.registerOperationHandler(OperationNames.EXPORT_RESOURCE, new
SiteLayoutExportResource(), description("Exports site layout configuration xml as a
zip file."));
- }
-
- private void pageManagementRegistration(ManagedResource.Registration sites)
- {
- // Pages management resource registration
- ManagedResource.Registration pages = sites.registerSubResource("pages",
description("Management resource responsible for handling management operations on
all pages of a site."));
-
- // Pages management operations
- pages.registerOperationHandler(OperationNames.READ_RESOURCE, new
PageReadResource(), description("Available pages at the specified address."),
true);
- pages.registerOperationHandler(OperationNames.READ_CONFIG_AS_XML, new
PageReadConfigAsXml(), description("Reads pages as configuration xml at the specified
address."), true);
- pages.registerOperationHandler(OperationNames.EXPORT_RESOURCE, new
PageExportResource(), description("Exports pages configuration xml as a zip
file."), true);
-
- // Page name management resource registration
- pages.registerSubResource("{page-name}", description("Page
management resource representing an individual page."));
- }
-
- private void navigationManagementRegistration(ManagedResource.Registration sites)
- {
- // Navigation management resource registration
- ManagedResource.Registration navigation =
sites.registerSubResource("navigation", description("Management resource
responsible for handling management operations on a sites navigation."));
-
- // Navigation management operations
- navigation.registerOperationHandler(OperationNames.READ_RESOURCE, new
NavigationReadResource(), description("Available navigation nodes at the specified
address."), true);
- navigation.registerOperationHandler(OperationNames.READ_CONFIG_AS_XML, new
NavigationReadConfigAsXml(), description("Reads navigation as configuration xml at
the specified address."), true);
- navigation.registerOperationHandler(OperationNames.EXPORT_RESOURCE, new
NavigationExportResource(), description("Exports navigation configuration xml as a
zip file."), true);
-
- // Navigation node management resource registration
- navigation.registerSubResource("{nav-uri: .*}",
description("Management resource responsible for handling management operations on
specific navigation nodes."));
- }
-
- @Override
- public void destroy()
- {
- }
-
- private static ManagedDescription description(final String description)
- {
- return new ManagedDescription()
- {
- @Override
- public String getDescription()
- {
- return description;
- }
- };
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management;
+
+import org.exoplatform.portal.mop.management.binding.MopBindingProvider;
+import org.exoplatform.portal.mop.management.operations.MopImportResource;
+import org.exoplatform.portal.mop.management.operations.MopReadResource;
+import
org.exoplatform.portal.mop.management.operations.navigation.NavigationExportResource;
+import
org.exoplatform.portal.mop.management.operations.navigation.NavigationReadConfigAsXml;
+import
org.exoplatform.portal.mop.management.operations.navigation.NavigationReadResource;
+import org.exoplatform.portal.mop.management.operations.page.PageExportResource;
+import org.exoplatform.portal.mop.management.operations.page.PageReadConfigAsXml;
+import org.exoplatform.portal.mop.management.operations.page.PageReadResource;
+import org.exoplatform.portal.mop.management.operations.site.SiteLayoutExportResource;
+import org.exoplatform.portal.mop.management.operations.site.SiteLayoutReadConfigAsXml;
+import org.exoplatform.portal.mop.management.operations.site.SiteReadResource;
+import org.exoplatform.portal.mop.management.operations.site.SiteTypeReadResource;
+import org.gatein.management.api.ComponentRegistration;
+import org.gatein.management.api.ManagedDescription;
+import org.gatein.management.api.ManagedResource;
+import org.gatein.management.api.operation.OperationNames;
+import org.gatein.management.spi.ExtensionContext;
+import org.gatein.management.spi.ManagementExtension;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class MopManagementExtension implements ManagementExtension
+{
+ @Override
+ public void initialize(ExtensionContext context)
+ {
+ ComponentRegistration registration =
context.registerManagedComponent("mop");
+ registration.registerBindingProvider(MopBindingProvider.INSTANCE);
+
+ ManagedResource.Registration mop =
registration.registerManagedResource(description("MOP (Model Object for Portal)
Managed Resource"));
+ mop.registerOperationHandler(OperationNames.IMPORT_RESOURCE, new
MopImportResource(), description("Imports mop data from an exported zip
file."));
+
+ mop.registerOperationHandler(OperationNames.READ_RESOURCE, new MopReadResource(),
description("Available site types for a portal"));
+
+ ManagedResource.Registration sitetypes =
mop.registerSubResource("{site-type}sites", description("Management
resource responsible for handling management operations on a specific site type for a
portal."));
+ sitetypes.registerOperationHandler(OperationNames.READ_RESOURCE, new
SiteTypeReadResource(), description("Available sites for a given site type."));
+
+ ManagedResource.Registration sites =
sitetypes.registerSubResource("{site-name: .*}", description("Management
resource responsible for handling management operations on a specific site."));
+ sites.registerOperationHandler(OperationNames.READ_RESOURCE, new
SiteReadResource(), description("Available artifacts for a given site (ie pages,
navigation, site layout)"));
+
+ // Site Layout management
+ siteLayoutManagementRegistration(sites);
+
+ // Page management
+ pageManagementRegistration(sites);
+
+ // Navigation management
+ navigationManagementRegistration(sites);
+ }
+
+ private void siteLayoutManagementRegistration(ManagedResource.Registration sites)
+ {
+ ManagedResource.Registration siteLayout =
sites.registerSubResource("portal", description("Management resource
responsible for handling management operations for a site layout."));
+ siteLayout.registerOperationHandler(OperationNames.READ_CONFIG_AS_XML, new
SiteLayoutReadConfigAsXml(), description("Reads site layout data for a specific site
as configuration xml."));
+ siteLayout.registerOperationHandler(OperationNames.EXPORT_RESOURCE, new
SiteLayoutExportResource(), description("Exports site layout configuration xml as a
zip file."));
+ }
+
+ private void pageManagementRegistration(ManagedResource.Registration sites)
+ {
+ // Pages management resource registration
+ ManagedResource.Registration pages = sites.registerSubResource("pages",
description("Management resource responsible for handling management operations on
all pages of a site."));
+
+ // Pages management operations
+ pages.registerOperationHandler(OperationNames.READ_RESOURCE, new
PageReadResource(), description("Available pages at the specified address."),
true);
+ pages.registerOperationHandler(OperationNames.READ_CONFIG_AS_XML, new
PageReadConfigAsXml(), description("Reads pages as configuration xml at the specified
address."), true);
+ pages.registerOperationHandler(OperationNames.EXPORT_RESOURCE, new
PageExportResource(), description("Exports pages configuration xml as a zip
file."), true);
+
+ // Page name management resource registration
+ pages.registerSubResource("{page-name}", description("Page
management resource representing an individual page."));
+ }
+
+ private void navigationManagementRegistration(ManagedResource.Registration sites)
+ {
+ // Navigation management resource registration
+ ManagedResource.Registration navigation =
sites.registerSubResource("navigation", description("Management resource
responsible for handling management operations on a sites navigation."));
+
+ // Navigation management operations
+ navigation.registerOperationHandler(OperationNames.READ_RESOURCE, new
NavigationReadResource(), description("Available navigation nodes at the specified
address."), true);
+ navigation.registerOperationHandler(OperationNames.READ_CONFIG_AS_XML, new
NavigationReadConfigAsXml(), description("Reads navigation as configuration xml at
the specified address."), true);
+ navigation.registerOperationHandler(OperationNames.EXPORT_RESOURCE, new
NavigationExportResource(), description("Exports navigation configuration xml as a
zip file."), true);
+
+ // Navigation node management resource registration
+ navigation.registerSubResource("{nav-uri: .*}",
description("Management resource responsible for handling management operations on
specific navigation nodes."));
+ }
+
+ @Override
+ public void destroy()
+ {
+ }
+
+ private static ManagedDescription description(final String description)
+ {
+ return new ManagedDescription()
+ {
+ @Override
+ public String getDescription()
+ {
+ return description;
+ }
+ };
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/MopBindingProvider.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/MopBindingProvider.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/MopBindingProvider.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,123 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.binding;
-
-import org.exoplatform.portal.config.model.Page;
-import org.exoplatform.portal.config.model.PageNavigation;
-import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.mop.management.binding.xml.NavigationMarshaller;
-import org.exoplatform.portal.mop.management.binding.xml.PageMarshaller;
-import org.exoplatform.portal.mop.management.binding.xml.SiteLayoutMarshaller;
-import org.exoplatform.portal.pom.data.PortalData;
-import org.gatein.management.api.ContentType;
-import org.gatein.management.api.binding.BindingException;
-import org.gatein.management.api.binding.BindingProvider;
-import org.gatein.management.api.binding.Marshaller;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class MopBindingProvider implements BindingProvider
-{
- public static final MopBindingProvider INSTANCE = new MopBindingProvider();
-
- private MopBindingProvider(){}
-
- @Override
- public <T> Marshaller<T> getMarshaller(Class<T> type, ContentType
contentType) throws BindingException
- {
- switch (contentType)
- {
- case XML:
- return getXmlMarshaller(type);
- case JSON:
- case ZIP:
- default:
- return null;
- }
- }
-
- @SuppressWarnings("unchecked")
- private <T> Marshaller<T> getXmlMarshaller(Class<T> type)
- {
- if (Page.class.isAssignableFrom(type))
- {
- return (Marshaller<T>) XmlMarshallers.page_marshaller;
- }
- else if (Page.PageSet.class.isAssignableFrom(type))
- {
- return (Marshaller<T>) XmlMarshallers.pages_marshaller;
- }
- else if (PageNavigation.class.isAssignableFrom(type))
- {
- return (Marshaller<T>) XmlMarshallers.navigation_marshaller;
- }
- else if (PortalConfig.class.isAssignableFrom(type))
- {
- return (Marshaller<T>) XmlMarshallers.site_marshaller;
- }
-
- return null;
- }
-
- private static class XmlMarshallers
- {
-
- //------------------------------------ Page Marshallers
------------------------------------//
- private static Marshaller<Page.PageSet> pages_marshaller = new
PageMarshaller();
-
- private static Marshaller<Page> page_marshaller = new
Marshaller<Page>()
- {
- @Override
- public void marshal(Page page, OutputStream outputStream) throws
BindingException
- {
- Page.PageSet pages = new Page.PageSet();
- pages.setPages(new ArrayList<Page>(1));
- pages.getPages().add(page);
-
- XmlMarshallers.pages_marshaller.marshal(pages, outputStream);
- }
-
- @Override
- public Page unmarshal(InputStream inputStream) throws BindingException
- {
- Page.PageSet pages = pages_marshaller.unmarshal(inputStream);
-
- if (pages.getPages().isEmpty()) throw new BindingException("No page was
unmarshalled.");
-
- if (pages.getPages().size() != 1) throw new BindingException("Multiple
pages found.");
-
- return pages.getPages().get(0);
- }
- };
-
- private static Marshaller<PageNavigation> navigation_marshaller = new
NavigationMarshaller();
-
- private static Marshaller<PortalConfig> site_marshaller = new
SiteLayoutMarshaller();
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/MopBindingProvider.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/MopBindingProvider.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/MopBindingProvider.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/MopBindingProvider.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.binding;
+
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.management.binding.xml.NavigationMarshaller;
+import org.exoplatform.portal.mop.management.binding.xml.PageMarshaller;
+import org.exoplatform.portal.mop.management.binding.xml.SiteLayoutMarshaller;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.gatein.management.api.ContentType;
+import org.gatein.management.api.binding.BindingException;
+import org.gatein.management.api.binding.BindingProvider;
+import org.gatein.management.api.binding.Marshaller;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class MopBindingProvider implements BindingProvider
+{
+ public static final MopBindingProvider INSTANCE = new MopBindingProvider();
+
+ private MopBindingProvider(){}
+
+ @Override
+ public <T> Marshaller<T> getMarshaller(Class<T> type, ContentType
contentType) throws BindingException
+ {
+ switch (contentType)
+ {
+ case XML:
+ return getXmlMarshaller(type);
+ case JSON:
+ case ZIP:
+ default:
+ return null;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private <T> Marshaller<T> getXmlMarshaller(Class<T> type)
+ {
+ if (Page.class.isAssignableFrom(type))
+ {
+ return (Marshaller<T>) XmlMarshallers.page_marshaller;
+ }
+ else if (Page.PageSet.class.isAssignableFrom(type))
+ {
+ return (Marshaller<T>) XmlMarshallers.pages_marshaller;
+ }
+ else if (PageNavigation.class.isAssignableFrom(type))
+ {
+ return (Marshaller<T>) XmlMarshallers.navigation_marshaller;
+ }
+ else if (PortalConfig.class.isAssignableFrom(type))
+ {
+ return (Marshaller<T>) XmlMarshallers.site_marshaller;
+ }
+
+ return null;
+ }
+
+ private static class XmlMarshallers
+ {
+
+ //------------------------------------ Page Marshallers
------------------------------------//
+ private static Marshaller<Page.PageSet> pages_marshaller = new
PageMarshaller();
+
+ private static Marshaller<Page> page_marshaller = new
Marshaller<Page>()
+ {
+ @Override
+ public void marshal(Page page, OutputStream outputStream) throws
BindingException
+ {
+ Page.PageSet pages = new Page.PageSet();
+ pages.setPages(new ArrayList<Page>(1));
+ pages.getPages().add(page);
+
+ XmlMarshallers.pages_marshaller.marshal(pages, outputStream);
+ }
+
+ @Override
+ public Page unmarshal(InputStream inputStream) throws BindingException
+ {
+ Page.PageSet pages = pages_marshaller.unmarshal(inputStream);
+
+ if (pages.getPages().isEmpty()) throw new BindingException("No page was
unmarshalled.");
+
+ if (pages.getPages().size() != 1) throw new BindingException("Multiple
pages found.");
+
+ return pages.getPages().get(0);
+ }
+ };
+
+ private static Marshaller<PageNavigation> navigation_marshaller = new
NavigationMarshaller();
+
+ private static Marshaller<PortalConfig> site_marshaller = new
SiteLayoutMarshaller();
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshaller.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshaller.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshaller.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,666 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.binding.xml;
-
-import org.exoplatform.container.ExoContainer;
-import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.container.PortalContainer;
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.model.Application;
-import org.exoplatform.portal.config.model.ApplicationState;
-import org.exoplatform.portal.config.model.ApplicationType;
-import org.exoplatform.portal.config.model.Container;
-import org.exoplatform.portal.config.model.ModelObject;
-import org.exoplatform.portal.config.model.Page;
-import org.exoplatform.portal.config.model.PageBody;
-import org.exoplatform.portal.config.model.TransientApplicationState;
-import org.gatein.common.xml.stax.writer.StaxWriter;
-import org.gatein.common.xml.stax.writer.WritableValueTypes;
-import org.exoplatform.portal.pom.data.ModelDataStorage;
-import org.exoplatform.portal.pom.spi.gadget.Gadget;
-import org.exoplatform.portal.pom.spi.portlet.Portlet;
-import org.exoplatform.portal.pom.spi.portlet.PortletBuilder;
-import org.exoplatform.portal.pom.spi.portlet.Preference;
-import org.gatein.management.api.binding.Marshaller;
-import org.staxnav.StaxNavigator;
-import org.staxnav.ValueType;
-
-import javax.xml.stream.XMLStreamException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import static org.gatein.common.xml.stax.navigator.Exceptions.*;
-import static org.gatein.common.xml.stax.navigator.StaxNavUtils.*;
-import static org.gatein.common.xml.stax.writer.StaxWriterUtils.*;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public abstract class AbstractMarshaller<T> implements Marshaller<T>
-{
- protected void marshalModelObject(StaxWriter<Element> writer, ModelObject
modelObject) throws XMLStreamException
- {
- if (modelObject instanceof Application)
- {
- Application application = (Application) modelObject;
- ApplicationType type = application.getType();
- if (ApplicationType.PORTLET == type)
- {
- marshalPortletApplication(writer, safeCast(application, Portlet.class));
- }
- else if (ApplicationType.GADGET == type)
- {
- marshalGadgetApplication(writer, safeCast(application, Gadget.class));
- }
- else if (ApplicationType.WSRP_PORTLET == type)
- {
- throw new XMLStreamException("WSRP portlet marshalling not
supported.");
- }
- }
- else if (modelObject instanceof Page)
- {
- //marshalPageData(writer, (PageData) componentData);
- throw new XMLStreamException("Unexpected PageData object. Storage id:
" + modelObject.getStorageId());
- }
- else if (modelObject instanceof Container)
- {
- marshalContainer(writer, (Container) modelObject);
- }
- else if (modelObject instanceof PageBody)
- {
- writer.writeStartElement(Element.PAGE_BODY).writeEndElement();
- }
- else
- {
- throw new XMLStreamException("Unknown ComponentData type " +
modelObject);
- }
- }
-
- protected void marshalContainer(StaxWriter<Element> writer, Container container)
throws XMLStreamException
- {
- writer.writeStartElement(Element.CONTAINER);
-
- writeOptionalAttribute(writer, Attribute.ID, container.getId());
- writeOptionalAttribute(writer, Attribute.TEMPLATE, container.getTemplate());
- writeOptionalAttribute(writer, Attribute.WIDTH, container.getWidth());
- writeOptionalAttribute(writer, Attribute.HEIGHT, container.getHeight());
-
- writeOptionalElement(writer, Element.NAME, container.getName());
- writeOptionalElement(writer, Element.TITLE, container.getTitle());
- writeOptionalElement(writer, Element.ICON, container.getIcon());
- writeOptionalElement(writer, Element.DESCRIPTION, container.getDescription());
-
- marshalAccessPermissions(writer, container.getAccessPermissions());
-
- writeOptionalElement(writer, Element.FACTORY_ID, container.getFactoryId());
-
- List<ModelObject> children = container.getChildren();
- for (ModelObject child : children)
- {
- marshalModelObject(writer, child);
- }
-
- writer.writeEndElement(); // End of container element
- }
-
- protected Container unmarshalContainer(StaxNavigator<Element> navigator) throws
XMLStreamException
- {
- Container container = new Container();
- container.setId(navigator.getAttribute(Attribute.ID.getLocalName()));
- container.setTemplate(navigator.getAttribute(Attribute.TEMPLATE.getLocalName()));
- container.setWidth(navigator.getAttribute(Attribute.WIDTH.getLocalName()));
- container.setHeight(navigator.getAttribute(Attribute.HEIGHT.getLocalName()));
-
- Element current = navigator.child();
- while (current != null)
- {
- switch (current)
- {
- case NAME:
- container.setName(navigator.getContent());
- current = navigator.sibling();
- break;
- case TITLE:
- container.setTitle(navigator.getContent());
- current = navigator.sibling();
- break;
- case ICON:
- container.setIcon(navigator.getContent());
- current = navigator.sibling();
- break;
- case DESCRIPTION:
- container.setDescription(navigator.getContent());
- current = navigator.sibling();
- break;
- case ACCESS_PERMISSIONS:
- container.setAccessPermissions(unmarshalAccessPermissions(navigator,
false));
- current = navigator.sibling();
- break;
- case FACTORY_ID:
- container.setFactoryId(navigator.getContent());
- current = navigator.sibling();
- break;
- case CONTAINER:
- if (container.getChildren() == null)
- {
- container.setChildren(new ArrayList<ModelObject>());
- }
- container.getChildren().add(unmarshalContainer(navigator.fork()));
- current = navigator.sibling();
- break;
- case PORTLET_APPLICATION:
- if (container.getChildren() == null)
- {
- container.setChildren(new ArrayList<ModelObject>());
- }
-
container.getChildren().add(unmarshalPortletApplication(navigator.fork()));
- current = navigator.sibling();
- break;
- case GADGET_APPLICATION:
- if (container.getChildren() == null)
- {
- container.setChildren(new ArrayList<ModelObject>());
- }
-
container.getChildren().add(unmarshalGadgetApplication(navigator.fork()));
- current = navigator.sibling();
- break;
- case UNKNOWN:
- throw unknownElement(navigator);
- default:
- throw unexpectedElement(navigator);
- }
- }
-
- return container;
- }
-
- protected void marshalPortletApplication(StaxWriter<Element> writer,
Application<Portlet> portletApplication) throws XMLStreamException
- {
-
writer.writeStartElement(Element.PORTLET_APPLICATION).writeStartElement(Element.PORTLET);
-
- // Marshal ApplicationState
- ApplicationState<Portlet> state = portletApplication.getState();
-
- // Marshal application state
- String contentId;
- Portlet portlet;
- // If transient we have all the information we need
- if (state instanceof TransientApplicationState)
- {
- TransientApplicationState<Portlet> transientApplicationState =
(TransientApplicationState<Portlet>) state;
- contentId = transientApplicationState.getContentId();
- portlet = transientApplicationState.getContentState();
- }
- else
- {
- // The only way to retrieve the information if the state is not transient is if
we're within the portal context
- ExoContainer container = ExoContainerContext.getCurrentContainer();
- if (container instanceof PortalContainer)
- {
- DataStorage dataStorage = (DataStorage)
container.getComponentInstanceOfType(DataStorage.class);
- try
- {
- portlet = dataStorage.load(state, ApplicationType.PORTLET);
- }
- catch (Exception e)
- {
- throw new XMLStreamException("Could not obtain portlet
state.");
- }
-
- try
- {
- contentId = dataStorage.getId(state);
- }
- catch (Exception e)
- {
- throw new XMLStreamException("Could not obtain contentId.", e);
- }
- }
- else
- {
- throw new XMLStreamException("Cannot marshal application state " +
state + " outside the context of the portal.");
- }
- }
-
- // Marshal portlet application id
- if (contentId == null) throw new XMLStreamException("Portlet application ID
was null.");
- writer.writeElement(Element.APPLICATION_REF, contentId.substring(0,
contentId.indexOf("/")));
- writer.writeElement(Element.PORTLET_REF,
contentId.substring(contentId.indexOf("/") + 1, contentId.length()));
-
- // Marshal preferences
- if (portlet != null)
- {
- boolean prefsWritten = false;
- for (Preference preference : portlet)
- {
- if (!prefsWritten)
- {
- writer.writeStartElement(Element.PREFERENCES);
- prefsWritten = true;
- }
-
- writer.writeStartElement(Element.PREFERENCE);
- writer.writeElement(Element.NAME, preference.getName());
- for (String value : preference.getValues())
- {
- writeOptionalContent(writer, Element.PREFERENCE_VALUE, value);
- }
- writer.writeElement(Element.PREFERENCE_READONLY, WritableValueTypes.BOOLEAN,
preference.isReadOnly());
- writer.writeEndElement(); // End of preference
- }
- if (prefsWritten)
- {
- writer.writeEndElement(); // End of preferences
- }
- }
- writer.writeEndElement(); // End of portlet
-
- marshalApplication(writer, portletApplication);
-
- writer.writeEndElement(); // End of portlet-application
- }
-
- protected Application<Portlet>
unmarshalPortletApplication(StaxNavigator<Element> navigator) throws
XMLStreamException
- {
- requiresChild(navigator, Element.PORTLET);
- ApplicationState<Portlet> state =
unmarshalPortletApplicationState(navigator.fork());
-
- Application<Portlet> portlet = new
Application<Portlet>(ApplicationType.PORTLET);
- portlet.setState(state);
-
- boolean showInfoBarParsed = false;
-
- Element current = navigator.sibling();
- while (current != null)
- {
- switch (current)
- {
- case THEME:
- portlet.setTheme(navigator.getContent());
- current = navigator.sibling();
- break;
- case TITLE:
- portlet.setTitle(navigator.getContent());
- current = navigator.sibling();
- break;
- case ACCESS_PERMISSIONS:
- portlet.setAccessPermissions(unmarshalAccessPermissions(navigator,
true));
- current = navigator.sibling();
- break;
- case SHOW_INFO_BAR:
- portlet.setShowInfoBar(parseRequiredContent(navigator,
ValueType.BOOLEAN));
- showInfoBarParsed = true;
- current = navigator.sibling();
- break;
- case SHOW_APPLICATION_STATE:
-
portlet.setShowApplicationState(navigator.parseContent(ValueType.BOOLEAN));
- current = navigator.sibling();
- break;
- case SHOW_APPLICATION_MODE:
-
portlet.setShowApplicationMode(navigator.parseContent(ValueType.BOOLEAN));
- current = navigator.sibling();
- break;
- case DESCRIPTION:
- portlet.setDescription(navigator.getContent());
- current = navigator.sibling();
- break;
- case ICON:
- portlet.setIcon(navigator.getContent());
- current = navigator.sibling();
- break;
- case WIDTH:
- portlet.setWidth(navigator.getContent());
- current = navigator.sibling();
- break;
- case HEIGHT:
- portlet.setHeight(navigator.getContent());
- current = navigator.sibling();
- break;
- case UNKNOWN:
- throw unknownElement(navigator);
- default:
- throw unexpectedElement(navigator);
- }
- }
-
- //TODO: We should raise this exception as soon as we know so location is accurate
- if (portlet.getAccessPermissions() == null) throw expectedElement(navigator,
Element.ACCESS_PERMISSIONS);
- if (!showInfoBarParsed) throw expectedElement(navigator, Element.SHOW_INFO_BAR);
-
- return portlet;
- }
-
- private ApplicationState<Portlet>
unmarshalPortletApplicationState(StaxNavigator<Element> navigator) throws
XMLStreamException
- {
- // Application name
- requiresChild(navigator, Element.APPLICATION_REF);
- String applicationRef = getRequiredContent(navigator, true);
-
- // Portlet name
- requiresSibling(navigator, Element.PORTLET_REF);
- String portletRef = getRequiredContent(navigator, true);
-
- // Preferences
- PortletBuilder portletBuilder = null;
- if (navigator.sibling() == Element.PREFERENCES)
- {
- requiresChild(navigator, Element.PREFERENCE);
- portletBuilder = new PortletBuilder();
- for (StaxNavigator<Element> fork : navigator.fork(Element.PREFERENCE))
- {
- // Preference name
- requiresChild(fork, Element.NAME);
- String prefName = getRequiredContent(fork, false);
-
- // Preference values
- List<String> values = null;
- while (fork.sibling() == Element.PREFERENCE_VALUE)
- {
- if (values == null) values = new ArrayList<String>();
- values.add(getContent(fork, false));
- }
- if (values == null)
- {
- values = Collections.singletonList(null);
- }
-
- // Preference readonly
- Boolean readOnly = null;
- if (fork.getName() == Element.PREFERENCE_READONLY)
- {
- readOnly = parseRequiredContent(fork, ValueType.BOOLEAN);
- }
-
- // Ensure nothing is left.
- if (fork.next() != null)
- {
- throw unexpectedElement(fork);
- }
-
- if (readOnly == null)
- {
- portletBuilder.add(prefName, values);
- }
- else
- {
- portletBuilder.add(prefName, values, readOnly);
- }
- }
- }
-
- TransientApplicationState<Portlet> state = new
TransientApplicationState<Portlet>(applicationRef + "/" + portletRef);
- if (portletBuilder != null)
- {
- state.setContentState(portletBuilder.build());
- }
-
- return state;
- }
-
- protected void marshalGadgetApplication(StaxWriter<Element> writer,
Application<Gadget> gadgetApplication) throws XMLStreamException
- {
-
writer.writeStartElement(Element.GADGET_APPLICATION).writeStartElement(Element.GADGET);
-
- // Marshal ApplicationState
- ApplicationState<Gadget> state = gadgetApplication.getState();
-
- // Marshal application state
- String contentId;
- Gadget gadget;
- // If transient we have all the information we need
- if (state instanceof TransientApplicationState)
- {
- TransientApplicationState<Gadget> transientApplicationState =
(TransientApplicationState<Gadget>) state;
- contentId = transientApplicationState.getContentId();
- gadget = transientApplicationState.getContentState();
- }
- else
- {
- // The only way to retrieve the information if the state is not transient is if
we're within a portal context
- ExoContainer container = ExoContainerContext.getCurrentContainer();
- if (container instanceof PortalContainer)
- {
- ModelDataStorage dataStorage = (ModelDataStorage)
container.getComponentInstanceOfType(ModelDataStorage.class);
- try
- {
- gadget = dataStorage.load(state, ApplicationType.GADGET);
- }
- catch (Exception e)
- {
- throw new XMLStreamException("Could not obtain gadget state from
custom context.");
- }
-
- try
- {
- contentId = dataStorage.getId(state);
- }
- catch (Exception e)
- {
- throw new XMLStreamException("Could not obtain contentId from custom
context.", e);
- }
- }
- else
- {
- throw new XMLStreamException("Cannot marshal application state " +
state + " outside the context of the portal.");
- }
- }
-
- // Marshal portlet application id
- if (contentId == null) throw new XMLStreamException("Gadget content ID was
null.");
- writer.writeElement(Element.GADGET_REF, contentId);
-
- // Marshal preferences
- if (gadget != null)
- {
- //TODO: When user-prefs are supported, uncomment
- //writer.writeOptionalElement(Element.PREFERENCES, gadget.getUserPref());
- }
- writer.writeEndElement(); // End of portlet
-
- marshalApplication(writer, gadgetApplication);
-
-
- writer.writeEndElement(); // End of gadget-application
- }
-
- protected Application<Gadget>
unmarshalGadgetApplication(StaxNavigator<Element> navigator) throws
XMLStreamException
- {
- requiresChild(navigator, Element.GADGET);
- ApplicationState<Gadget> state =
unmarshalGadgetApplicationState(navigator.fork());
-
- Application<Gadget> gadget = new
Application<Gadget>(ApplicationType.GADGET);
- gadget.setState(state);
-
- boolean showInfoBarParsed = false;
-
- Element current = navigator.sibling();
- while (current != null)
- {
- switch (current)
- {
- case THEME:
- gadget.setTheme(navigator.getContent());
- current = navigator.sibling();
- break;
- case TITLE:
- gadget.setTitle(navigator.getContent());
- current = navigator.sibling();
- break;
- case ACCESS_PERMISSIONS:
- gadget.setAccessPermissions(unmarshalAccessPermissions(navigator, true));
- current = navigator.sibling();
- break;
- case SHOW_INFO_BAR:
- gadget.setShowInfoBar(parseRequiredContent(navigator,
ValueType.BOOLEAN));
- showInfoBarParsed = true;
- current = navigator.sibling();
- break;
- case SHOW_APPLICATION_STATE:
-
gadget.setShowApplicationState(navigator.parseContent(ValueType.BOOLEAN));
- current = navigator.sibling();
- break;
- case SHOW_APPLICATION_MODE:
- gadget.setShowApplicationMode(navigator.parseContent(ValueType.BOOLEAN));
- current = navigator.sibling();
- break;
- case DESCRIPTION:
- gadget.setDescription(navigator.getContent());
- current = navigator.sibling();
- break;
- case ICON:
- gadget.setIcon(navigator.getContent());
- current = navigator.sibling();
- break;
- case WIDTH:
- gadget.setWidth(navigator.getContent());
- current = navigator.sibling();
- break;
- case HEIGHT:
- gadget.setHeight(navigator.getContent());
- current = navigator.sibling();
- break;
- case UNKNOWN:
- throw unknownElement(navigator);
- default:
- throw unexpectedElement(navigator);
- }
- }
-
- //TODO: We should raise this exception as soon as we know so location is accurate
- if (gadget.getAccessPermissions() == null) throw expectedElement(navigator,
Element.ACCESS_PERMISSIONS);
- if (!showInfoBarParsed) throw expectedElement(navigator, Element.SHOW_INFO_BAR);
-
- return gadget;
- }
-
- private ApplicationState<Gadget>
unmarshalGadgetApplicationState(StaxNavigator<Element> navigator) throws
XMLStreamException
- {
- requiresChild(navigator, Element.GADGET_REF);
- String gadgetRef = getRequiredContent(navigator, true);
-
- //TODO: Implement userPref unmarshalling when gatein_objects support it
- Gadget gadget = null;
-
- if (navigator.next() != null)
- {
- throw unexpectedElement(navigator);
- }
-
- return new TransientApplicationState<Gadget>(gadgetRef, gadget);
- }
-
- protected void marshalApplication(StaxWriter<Element> writer,
Application<?> application) throws XMLStreamException
- {
- // Theme, Title
- writeOptionalElement(writer, Element.THEME, application.getTheme());
- writeOptionalElement(writer, Element.TITLE, application.getTitle());
-
- // Access Permissions
- marshalAccessPermissions(writer, application.getAccessPermissions());
-
- // common application elements
- writeOptionalElement(writer, Element.SHOW_INFO_BAR,
String.valueOf(application.getShowInfoBar()));
- writeOptionalElement(writer, Element.SHOW_APPLICATION_STATE,
String.valueOf(application.getShowApplicationState()));
- writeOptionalElement(writer, Element.SHOW_APPLICATION_MODE,
String.valueOf(application.getShowApplicationMode()));
-
- // Description, Icon
- writeOptionalElement(writer, Element.DESCRIPTION, application.getDescription());
- writeOptionalElement(writer, Element.ICON, application.getIcon());
-
- // Width & Height
- writeOptionalElement(writer, Element.WIDTH, application.getWidth());
- writeOptionalElement(writer, Element.HEIGHT, application.getHeight());
- }
-
- protected void marshalAccessPermissions(StaxWriter<Element> writer, String[]
accessPermissions) throws XMLStreamException
- {
- writeOptionalElement(writer, Element.ACCESS_PERMISSIONS,
DelimitedValueType.SEMI_COLON, accessPermissions);
- }
-
- protected String[] unmarshalAccessPermissions(StaxNavigator<Element> navigator,
boolean required) throws XMLStreamException
- {
- if (required)
- {
- return parseRequiredContent(navigator, DelimitedValueType.SEMI_COLON);
- }
- else
- {
- return parseContent(navigator, DelimitedValueType.SEMI_COLON, null);
- }
- }
-
- protected void marshalEditPermission(StaxWriter<Element> writer, String
editPermission) throws XMLStreamException
- {
- writeOptionalElement(writer, Element.EDIT_PERMISSION, editPermission);
- }
-
- protected String unmarshalEditPermission(StaxNavigator<Element> navigator)
throws XMLStreamException
- {
- return getContent(navigator, true);
- }
-
- protected void writeGateinObjectsNamespace(StaxWriter<Element> writer) throws
XMLStreamException
- {
- Utils.writeGateinObjectsNamespace(writer);
- }
-
- @SuppressWarnings("unchecked")
- private <S> Application<S> safeCast(Application application,
Class<S> stateClass)
- {
- return (Application<S>) application;
- }
-
- private static void writeOptionalAttribute(StaxWriter writer, Attribute attribute,
String value) throws XMLStreamException
- {
- if (value == null) return;
-
- writer.writeAttribute(attribute.getLocalName(), value);
- }
-
- private static enum Attribute
- {
- ID("id"),
- TEMPLATE("template"),
- WIDTH("width"),
- HEIGHT("height");
-
- private final String name;
-
- Attribute(final String name)
- {
- this.name = name;
- }
-
- /**
- * Get the local name of this element.
- *
- * @return the local name
- */
- public String getLocalName()
- {
- return name;
- }
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshaller.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshaller.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshaller.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshaller.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,666 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.binding.xml;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.Application;
+import org.exoplatform.portal.config.model.ApplicationState;
+import org.exoplatform.portal.config.model.ApplicationType;
+import org.exoplatform.portal.config.model.Container;
+import org.exoplatform.portal.config.model.ModelObject;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.config.model.PageBody;
+import org.exoplatform.portal.config.model.TransientApplicationState;
+import org.gatein.common.xml.stax.writer.StaxWriter;
+import org.gatein.common.xml.stax.writer.WritableValueTypes;
+import org.exoplatform.portal.pom.data.ModelDataStorage;
+import org.exoplatform.portal.pom.spi.gadget.Gadget;
+import org.exoplatform.portal.pom.spi.portlet.Portlet;
+import org.exoplatform.portal.pom.spi.portlet.PortletBuilder;
+import org.exoplatform.portal.pom.spi.portlet.Preference;
+import org.gatein.management.api.binding.Marshaller;
+import org.staxnav.StaxNavigator;
+import org.staxnav.ValueType;
+
+import javax.xml.stream.XMLStreamException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import static org.gatein.common.xml.stax.navigator.Exceptions.*;
+import static org.gatein.common.xml.stax.navigator.StaxNavUtils.*;
+import static org.gatein.common.xml.stax.writer.StaxWriterUtils.*;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class AbstractMarshaller<T> implements Marshaller<T>
+{
+ protected void marshalModelObject(StaxWriter<Element> writer, ModelObject
modelObject) throws XMLStreamException
+ {
+ if (modelObject instanceof Application)
+ {
+ Application application = (Application) modelObject;
+ ApplicationType type = application.getType();
+ if (ApplicationType.PORTLET == type)
+ {
+ marshalPortletApplication(writer, safeCast(application, Portlet.class));
+ }
+ else if (ApplicationType.GADGET == type)
+ {
+ marshalGadgetApplication(writer, safeCast(application, Gadget.class));
+ }
+ else if (ApplicationType.WSRP_PORTLET == type)
+ {
+ throw new XMLStreamException("WSRP portlet marshalling not
supported.");
+ }
+ }
+ else if (modelObject instanceof Page)
+ {
+ //marshalPageData(writer, (PageData) componentData);
+ throw new XMLStreamException("Unexpected PageData object. Storage id:
" + modelObject.getStorageId());
+ }
+ else if (modelObject instanceof Container)
+ {
+ marshalContainer(writer, (Container) modelObject);
+ }
+ else if (modelObject instanceof PageBody)
+ {
+ writer.writeStartElement(Element.PAGE_BODY).writeEndElement();
+ }
+ else
+ {
+ throw new XMLStreamException("Unknown ComponentData type " +
modelObject);
+ }
+ }
+
+ protected void marshalContainer(StaxWriter<Element> writer, Container container)
throws XMLStreamException
+ {
+ writer.writeStartElement(Element.CONTAINER);
+
+ writeOptionalAttribute(writer, Attribute.ID, container.getId());
+ writeOptionalAttribute(writer, Attribute.TEMPLATE, container.getTemplate());
+ writeOptionalAttribute(writer, Attribute.WIDTH, container.getWidth());
+ writeOptionalAttribute(writer, Attribute.HEIGHT, container.getHeight());
+
+ writeOptionalElement(writer, Element.NAME, container.getName());
+ writeOptionalElement(writer, Element.TITLE, container.getTitle());
+ writeOptionalElement(writer, Element.ICON, container.getIcon());
+ writeOptionalElement(writer, Element.DESCRIPTION, container.getDescription());
+
+ marshalAccessPermissions(writer, container.getAccessPermissions());
+
+ writeOptionalElement(writer, Element.FACTORY_ID, container.getFactoryId());
+
+ List<ModelObject> children = container.getChildren();
+ for (ModelObject child : children)
+ {
+ marshalModelObject(writer, child);
+ }
+
+ writer.writeEndElement(); // End of container element
+ }
+
+ protected Container unmarshalContainer(StaxNavigator<Element> navigator) throws
XMLStreamException
+ {
+ Container container = new Container();
+ container.setId(navigator.getAttribute(Attribute.ID.getLocalName()));
+ container.setTemplate(navigator.getAttribute(Attribute.TEMPLATE.getLocalName()));
+ container.setWidth(navigator.getAttribute(Attribute.WIDTH.getLocalName()));
+ container.setHeight(navigator.getAttribute(Attribute.HEIGHT.getLocalName()));
+
+ Element current = navigator.child();
+ while (current != null)
+ {
+ switch (current)
+ {
+ case NAME:
+ container.setName(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case TITLE:
+ container.setTitle(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case ICON:
+ container.setIcon(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case DESCRIPTION:
+ container.setDescription(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case ACCESS_PERMISSIONS:
+ container.setAccessPermissions(unmarshalAccessPermissions(navigator,
false));
+ current = navigator.sibling();
+ break;
+ case FACTORY_ID:
+ container.setFactoryId(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case CONTAINER:
+ if (container.getChildren() == null)
+ {
+ container.setChildren(new ArrayList<ModelObject>());
+ }
+ container.getChildren().add(unmarshalContainer(navigator.fork()));
+ current = navigator.sibling();
+ break;
+ case PORTLET_APPLICATION:
+ if (container.getChildren() == null)
+ {
+ container.setChildren(new ArrayList<ModelObject>());
+ }
+
container.getChildren().add(unmarshalPortletApplication(navigator.fork()));
+ current = navigator.sibling();
+ break;
+ case GADGET_APPLICATION:
+ if (container.getChildren() == null)
+ {
+ container.setChildren(new ArrayList<ModelObject>());
+ }
+
container.getChildren().add(unmarshalGadgetApplication(navigator.fork()));
+ current = navigator.sibling();
+ break;
+ case UNKNOWN:
+ throw unknownElement(navigator);
+ default:
+ throw unexpectedElement(navigator);
+ }
+ }
+
+ return container;
+ }
+
+ protected void marshalPortletApplication(StaxWriter<Element> writer,
Application<Portlet> portletApplication) throws XMLStreamException
+ {
+
writer.writeStartElement(Element.PORTLET_APPLICATION).writeStartElement(Element.PORTLET);
+
+ // Marshal ApplicationState
+ ApplicationState<Portlet> state = portletApplication.getState();
+
+ // Marshal application state
+ String contentId;
+ Portlet portlet;
+ // If transient we have all the information we need
+ if (state instanceof TransientApplicationState)
+ {
+ TransientApplicationState<Portlet> transientApplicationState =
(TransientApplicationState<Portlet>) state;
+ contentId = transientApplicationState.getContentId();
+ portlet = transientApplicationState.getContentState();
+ }
+ else
+ {
+ // The only way to retrieve the information if the state is not transient is if
we're within the portal context
+ ExoContainer container = ExoContainerContext.getCurrentContainer();
+ if (container instanceof PortalContainer)
+ {
+ DataStorage dataStorage = (DataStorage)
container.getComponentInstanceOfType(DataStorage.class);
+ try
+ {
+ portlet = dataStorage.load(state, ApplicationType.PORTLET);
+ }
+ catch (Exception e)
+ {
+ throw new XMLStreamException("Could not obtain portlet
state.");
+ }
+
+ try
+ {
+ contentId = dataStorage.getId(state);
+ }
+ catch (Exception e)
+ {
+ throw new XMLStreamException("Could not obtain contentId.", e);
+ }
+ }
+ else
+ {
+ throw new XMLStreamException("Cannot marshal application state " +
state + " outside the context of the portal.");
+ }
+ }
+
+ // Marshal portlet application id
+ if (contentId == null) throw new XMLStreamException("Portlet application ID
was null.");
+ writer.writeElement(Element.APPLICATION_REF, contentId.substring(0,
contentId.indexOf("/")));
+ writer.writeElement(Element.PORTLET_REF,
contentId.substring(contentId.indexOf("/") + 1, contentId.length()));
+
+ // Marshal preferences
+ if (portlet != null)
+ {
+ boolean prefsWritten = false;
+ for (Preference preference : portlet)
+ {
+ if (!prefsWritten)
+ {
+ writer.writeStartElement(Element.PREFERENCES);
+ prefsWritten = true;
+ }
+
+ writer.writeStartElement(Element.PREFERENCE);
+ writer.writeElement(Element.NAME, preference.getName());
+ for (String value : preference.getValues())
+ {
+ writeOptionalContent(writer, Element.PREFERENCE_VALUE, value);
+ }
+ writer.writeElement(Element.PREFERENCE_READONLY, WritableValueTypes.BOOLEAN,
preference.isReadOnly());
+ writer.writeEndElement(); // End of preference
+ }
+ if (prefsWritten)
+ {
+ writer.writeEndElement(); // End of preferences
+ }
+ }
+ writer.writeEndElement(); // End of portlet
+
+ marshalApplication(writer, portletApplication);
+
+ writer.writeEndElement(); // End of portlet-application
+ }
+
+ protected Application<Portlet>
unmarshalPortletApplication(StaxNavigator<Element> navigator) throws
XMLStreamException
+ {
+ requiresChild(navigator, Element.PORTLET);
+ ApplicationState<Portlet> state =
unmarshalPortletApplicationState(navigator.fork());
+
+ Application<Portlet> portlet = new
Application<Portlet>(ApplicationType.PORTLET);
+ portlet.setState(state);
+
+ boolean showInfoBarParsed = false;
+
+ Element current = navigator.sibling();
+ while (current != null)
+ {
+ switch (current)
+ {
+ case THEME:
+ portlet.setTheme(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case TITLE:
+ portlet.setTitle(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case ACCESS_PERMISSIONS:
+ portlet.setAccessPermissions(unmarshalAccessPermissions(navigator,
true));
+ current = navigator.sibling();
+ break;
+ case SHOW_INFO_BAR:
+ portlet.setShowInfoBar(parseRequiredContent(navigator,
ValueType.BOOLEAN));
+ showInfoBarParsed = true;
+ current = navigator.sibling();
+ break;
+ case SHOW_APPLICATION_STATE:
+
portlet.setShowApplicationState(navigator.parseContent(ValueType.BOOLEAN));
+ current = navigator.sibling();
+ break;
+ case SHOW_APPLICATION_MODE:
+
portlet.setShowApplicationMode(navigator.parseContent(ValueType.BOOLEAN));
+ current = navigator.sibling();
+ break;
+ case DESCRIPTION:
+ portlet.setDescription(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case ICON:
+ portlet.setIcon(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case WIDTH:
+ portlet.setWidth(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case HEIGHT:
+ portlet.setHeight(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case UNKNOWN:
+ throw unknownElement(navigator);
+ default:
+ throw unexpectedElement(navigator);
+ }
+ }
+
+ //TODO: We should raise this exception as soon as we know so location is accurate
+ if (portlet.getAccessPermissions() == null) throw expectedElement(navigator,
Element.ACCESS_PERMISSIONS);
+ if (!showInfoBarParsed) throw expectedElement(navigator, Element.SHOW_INFO_BAR);
+
+ return portlet;
+ }
+
+ private ApplicationState<Portlet>
unmarshalPortletApplicationState(StaxNavigator<Element> navigator) throws
XMLStreamException
+ {
+ // Application name
+ requiresChild(navigator, Element.APPLICATION_REF);
+ String applicationRef = getRequiredContent(navigator, true);
+
+ // Portlet name
+ requiresSibling(navigator, Element.PORTLET_REF);
+ String portletRef = getRequiredContent(navigator, true);
+
+ // Preferences
+ PortletBuilder portletBuilder = null;
+ if (navigator.sibling() == Element.PREFERENCES)
+ {
+ requiresChild(navigator, Element.PREFERENCE);
+ portletBuilder = new PortletBuilder();
+ for (StaxNavigator<Element> fork : navigator.fork(Element.PREFERENCE))
+ {
+ // Preference name
+ requiresChild(fork, Element.NAME);
+ String prefName = getRequiredContent(fork, false);
+
+ // Preference values
+ List<String> values = null;
+ while (fork.sibling() == Element.PREFERENCE_VALUE)
+ {
+ if (values == null) values = new ArrayList<String>();
+ values.add(getContent(fork, false));
+ }
+ if (values == null)
+ {
+ values = Collections.singletonList(null);
+ }
+
+ // Preference readonly
+ Boolean readOnly = null;
+ if (fork.getName() == Element.PREFERENCE_READONLY)
+ {
+ readOnly = parseRequiredContent(fork, ValueType.BOOLEAN);
+ }
+
+ // Ensure nothing is left.
+ if (fork.next() != null)
+ {
+ throw unexpectedElement(fork);
+ }
+
+ if (readOnly == null)
+ {
+ portletBuilder.add(prefName, values);
+ }
+ else
+ {
+ portletBuilder.add(prefName, values, readOnly);
+ }
+ }
+ }
+
+ TransientApplicationState<Portlet> state = new
TransientApplicationState<Portlet>(applicationRef + "/" + portletRef);
+ if (portletBuilder != null)
+ {
+ state.setContentState(portletBuilder.build());
+ }
+
+ return state;
+ }
+
+ protected void marshalGadgetApplication(StaxWriter<Element> writer,
Application<Gadget> gadgetApplication) throws XMLStreamException
+ {
+
writer.writeStartElement(Element.GADGET_APPLICATION).writeStartElement(Element.GADGET);
+
+ // Marshal ApplicationState
+ ApplicationState<Gadget> state = gadgetApplication.getState();
+
+ // Marshal application state
+ String contentId;
+ Gadget gadget;
+ // If transient we have all the information we need
+ if (state instanceof TransientApplicationState)
+ {
+ TransientApplicationState<Gadget> transientApplicationState =
(TransientApplicationState<Gadget>) state;
+ contentId = transientApplicationState.getContentId();
+ gadget = transientApplicationState.getContentState();
+ }
+ else
+ {
+ // The only way to retrieve the information if the state is not transient is if
we're within a portal context
+ ExoContainer container = ExoContainerContext.getCurrentContainer();
+ if (container instanceof PortalContainer)
+ {
+ ModelDataStorage dataStorage = (ModelDataStorage)
container.getComponentInstanceOfType(ModelDataStorage.class);
+ try
+ {
+ gadget = dataStorage.load(state, ApplicationType.GADGET);
+ }
+ catch (Exception e)
+ {
+ throw new XMLStreamException("Could not obtain gadget state from
custom context.");
+ }
+
+ try
+ {
+ contentId = dataStorage.getId(state);
+ }
+ catch (Exception e)
+ {
+ throw new XMLStreamException("Could not obtain contentId from custom
context.", e);
+ }
+ }
+ else
+ {
+ throw new XMLStreamException("Cannot marshal application state " +
state + " outside the context of the portal.");
+ }
+ }
+
+ // Marshal portlet application id
+ if (contentId == null) throw new XMLStreamException("Gadget content ID was
null.");
+ writer.writeElement(Element.GADGET_REF, contentId);
+
+ // Marshal preferences
+ if (gadget != null)
+ {
+ //TODO: When user-prefs are supported, uncomment
+ //writer.writeOptionalElement(Element.PREFERENCES, gadget.getUserPref());
+ }
+ writer.writeEndElement(); // End of portlet
+
+ marshalApplication(writer, gadgetApplication);
+
+
+ writer.writeEndElement(); // End of gadget-application
+ }
+
+ protected Application<Gadget>
unmarshalGadgetApplication(StaxNavigator<Element> navigator) throws
XMLStreamException
+ {
+ requiresChild(navigator, Element.GADGET);
+ ApplicationState<Gadget> state =
unmarshalGadgetApplicationState(navigator.fork());
+
+ Application<Gadget> gadget = new
Application<Gadget>(ApplicationType.GADGET);
+ gadget.setState(state);
+
+ boolean showInfoBarParsed = false;
+
+ Element current = navigator.sibling();
+ while (current != null)
+ {
+ switch (current)
+ {
+ case THEME:
+ gadget.setTheme(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case TITLE:
+ gadget.setTitle(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case ACCESS_PERMISSIONS:
+ gadget.setAccessPermissions(unmarshalAccessPermissions(navigator, true));
+ current = navigator.sibling();
+ break;
+ case SHOW_INFO_BAR:
+ gadget.setShowInfoBar(parseRequiredContent(navigator,
ValueType.BOOLEAN));
+ showInfoBarParsed = true;
+ current = navigator.sibling();
+ break;
+ case SHOW_APPLICATION_STATE:
+
gadget.setShowApplicationState(navigator.parseContent(ValueType.BOOLEAN));
+ current = navigator.sibling();
+ break;
+ case SHOW_APPLICATION_MODE:
+ gadget.setShowApplicationMode(navigator.parseContent(ValueType.BOOLEAN));
+ current = navigator.sibling();
+ break;
+ case DESCRIPTION:
+ gadget.setDescription(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case ICON:
+ gadget.setIcon(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case WIDTH:
+ gadget.setWidth(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case HEIGHT:
+ gadget.setHeight(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case UNKNOWN:
+ throw unknownElement(navigator);
+ default:
+ throw unexpectedElement(navigator);
+ }
+ }
+
+ //TODO: We should raise this exception as soon as we know so location is accurate
+ if (gadget.getAccessPermissions() == null) throw expectedElement(navigator,
Element.ACCESS_PERMISSIONS);
+ if (!showInfoBarParsed) throw expectedElement(navigator, Element.SHOW_INFO_BAR);
+
+ return gadget;
+ }
+
+ private ApplicationState<Gadget>
unmarshalGadgetApplicationState(StaxNavigator<Element> navigator) throws
XMLStreamException
+ {
+ requiresChild(navigator, Element.GADGET_REF);
+ String gadgetRef = getRequiredContent(navigator, true);
+
+ //TODO: Implement userPref unmarshalling when gatein_objects support it
+ Gadget gadget = null;
+
+ if (navigator.next() != null)
+ {
+ throw unexpectedElement(navigator);
+ }
+
+ return new TransientApplicationState<Gadget>(gadgetRef, gadget);
+ }
+
+ protected void marshalApplication(StaxWriter<Element> writer,
Application<?> application) throws XMLStreamException
+ {
+ // Theme, Title
+ writeOptionalElement(writer, Element.THEME, application.getTheme());
+ writeOptionalElement(writer, Element.TITLE, application.getTitle());
+
+ // Access Permissions
+ marshalAccessPermissions(writer, application.getAccessPermissions());
+
+ // common application elements
+ writeOptionalElement(writer, Element.SHOW_INFO_BAR,
String.valueOf(application.getShowInfoBar()));
+ writeOptionalElement(writer, Element.SHOW_APPLICATION_STATE,
String.valueOf(application.getShowApplicationState()));
+ writeOptionalElement(writer, Element.SHOW_APPLICATION_MODE,
String.valueOf(application.getShowApplicationMode()));
+
+ // Description, Icon
+ writeOptionalElement(writer, Element.DESCRIPTION, application.getDescription());
+ writeOptionalElement(writer, Element.ICON, application.getIcon());
+
+ // Width & Height
+ writeOptionalElement(writer, Element.WIDTH, application.getWidth());
+ writeOptionalElement(writer, Element.HEIGHT, application.getHeight());
+ }
+
+ protected void marshalAccessPermissions(StaxWriter<Element> writer, String[]
accessPermissions) throws XMLStreamException
+ {
+ writeOptionalElement(writer, Element.ACCESS_PERMISSIONS,
DelimitedValueType.SEMI_COLON, accessPermissions);
+ }
+
+ protected String[] unmarshalAccessPermissions(StaxNavigator<Element> navigator,
boolean required) throws XMLStreamException
+ {
+ if (required)
+ {
+ return parseRequiredContent(navigator, DelimitedValueType.SEMI_COLON);
+ }
+ else
+ {
+ return parseContent(navigator, DelimitedValueType.SEMI_COLON, null);
+ }
+ }
+
+ protected void marshalEditPermission(StaxWriter<Element> writer, String
editPermission) throws XMLStreamException
+ {
+ writeOptionalElement(writer, Element.EDIT_PERMISSION, editPermission);
+ }
+
+ protected String unmarshalEditPermission(StaxNavigator<Element> navigator)
throws XMLStreamException
+ {
+ return getContent(navigator, true);
+ }
+
+ protected void writeGateinObjectsNamespace(StaxWriter<Element> writer) throws
XMLStreamException
+ {
+ Utils.writeGateinObjectsNamespace(writer);
+ }
+
+ @SuppressWarnings("unchecked")
+ private <S> Application<S> safeCast(Application application,
Class<S> stateClass)
+ {
+ return (Application<S>) application;
+ }
+
+ private static void writeOptionalAttribute(StaxWriter writer, Attribute attribute,
String value) throws XMLStreamException
+ {
+ if (value == null) return;
+
+ writer.writeAttribute(attribute.getLocalName(), value);
+ }
+
+ private static enum Attribute
+ {
+ ID("id"),
+ TEMPLATE("template"),
+ WIDTH("width"),
+ HEIGHT("height");
+
+ private final String name;
+
+ Attribute(final String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Get the local name of this element.
+ *
+ * @return the local name
+ */
+ public String getLocalName()
+ {
+ return name;
+ }
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/DelimitedValueType.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/DelimitedValueType.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/DelimitedValueType.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.binding.xml;
-
-import org.gatein.common.xml.stax.writer.WritableValueType;
-import org.exoplatform.portal.pom.config.Utils;
-import org.staxnav.StaxNavException;
-import org.staxnav.ValueType;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class DelimitedValueType extends ValueType<String[]> implements
WritableValueType<String[]>
-{
- public static DelimitedValueType SEMI_COLON = new DelimitedValueType(";");
-
- private final String delimiter;
-
- public DelimitedValueType(String delimiter)
- {
- this.delimiter = delimiter;
- }
-
- @Override
- protected String[] parse(String s) throws Exception
- {
- return Utils.split(delimiter, s);
- }
-
- @Override
- public String format(String[] value) throws StaxNavException
- {
- String s = Utils.join(delimiter, value);
-
- if (s != null && s.trim().length() == 0)
- {
- return null;
- }
- else
- {
- return s;
- }
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/DelimitedValueType.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/DelimitedValueType.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/DelimitedValueType.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/DelimitedValueType.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.binding.xml;
+
+import org.gatein.common.xml.stax.writer.WritableValueType;
+import org.exoplatform.portal.pom.config.Utils;
+import org.staxnav.StaxNavException;
+import org.staxnav.ValueType;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class DelimitedValueType extends ValueType<String[]> implements
WritableValueType<String[]>
+{
+ public static DelimitedValueType SEMI_COLON = new DelimitedValueType(";");
+
+ private final String delimiter;
+
+ public DelimitedValueType(String delimiter)
+ {
+ this.delimiter = delimiter;
+ }
+
+ @Override
+ protected String[] parse(String s) throws Exception
+ {
+ return Utils.split(delimiter, s);
+ }
+
+ @Override
+ public String format(String[] value) throws StaxNavException
+ {
+ String s = Utils.join(delimiter, value);
+
+ if (s != null && s.trim().length() == 0)
+ {
+ return null;
+ }
+ else
+ {
+ return s;
+ }
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Element.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Element.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Element.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,104 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.binding.xml;
-
-
-import org.staxnav.EnumElement;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public enum Element implements EnumElement<Element>
-{
- // Navigation Elements
- UNKNOWN(null),
- NODE_NAVIGATION("node-navigation"),
- PRIORITY("priority"),
- PAGE_NODES("page-nodes"),
- NODE("node"),
- @Deprecated
- URI("uri"),
- PARENT_URI("parent-uri"),
- LABEL("label"),
- START_PUBLICATION_DATE("start-publication-date"),
- END_PUBLICATION_DATE("end-publication-date"),
- VISIBILITY("visibility"),
- PAGE_REFERENCE("page-reference"),
-
- // Page elements
- PAGE_SET("page-set"),
- PAGE("page"),
- NAME("name"),
- SHOW_MAX_WINDOW("show-max-window"),
-
- // Portal config elements
- PORTAL_CONFIG("portal-config"),
- PORTAL_NAME("portal-name"),
- LOCALE("locale"),
- SKIN("skin"),
- PROPERTIES("properties"),
- PROPERTIES_ENTRY("entry"),
- PORTAL_LAYOUT("portal-layout"),
-
- // Common elements
- TITLE("title"),
- DESCRIPTION("description"),
- FACTORY_ID("factory-id"),
- ACCESS_PERMISSIONS("access-permissions"),
- EDIT_PERMISSION("edit-permission"),
- PORTLET_APPLICATION("portlet-application"),
- GADGET_APPLICATION("gadget-application"),
- CONTAINER("container"),
- PAGE_BODY("page-body"),
- APPLICATION_REF("application-ref"),
- PORTLET_REF("portlet-ref"),
- PORTLET("portlet"),
- GADGET_REF("gadget-ref"),
- GADGET("gadget"),
- THEME("theme"),
- SHOW_INFO_BAR("show-info-bar"),
- SHOW_APPLICATION_STATE("show-application-state"),
- SHOW_APPLICATION_MODE("show-application-mode"),
- ICON("icon"),
- WIDTH("width"),
- HEIGHT("height"),
- PREFERENCES("preferences"),
- PREFERENCE("preference"),
- PREFERENCE_VALUE("value"),
- PREFERENCE_READONLY("read-only")
- ;
-
- private final String name;
-
- Element(String name)
- {
- this.name = name;
- }
-
- @Override
- public String getLocalName()
- {
- return name;
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Element.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Element.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Element.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Element.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.binding.xml;
+
+
+import org.staxnav.EnumElement;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public enum Element implements EnumElement<Element>
+{
+ // Navigation Elements
+ UNKNOWN(null),
+ NODE_NAVIGATION("node-navigation"),
+ PRIORITY("priority"),
+ PAGE_NODES("page-nodes"),
+ NODE("node"),
+ @Deprecated
+ URI("uri"),
+ PARENT_URI("parent-uri"),
+ LABEL("label"),
+ START_PUBLICATION_DATE("start-publication-date"),
+ END_PUBLICATION_DATE("end-publication-date"),
+ VISIBILITY("visibility"),
+ PAGE_REFERENCE("page-reference"),
+
+ // Page elements
+ PAGE_SET("page-set"),
+ PAGE("page"),
+ NAME("name"),
+ SHOW_MAX_WINDOW("show-max-window"),
+
+ // Portal config elements
+ PORTAL_CONFIG("portal-config"),
+ PORTAL_NAME("portal-name"),
+ LOCALE("locale"),
+ SKIN("skin"),
+ PROPERTIES("properties"),
+ PROPERTIES_ENTRY("entry"),
+ PORTAL_LAYOUT("portal-layout"),
+
+ // Common elements
+ TITLE("title"),
+ DESCRIPTION("description"),
+ FACTORY_ID("factory-id"),
+ ACCESS_PERMISSIONS("access-permissions"),
+ EDIT_PERMISSION("edit-permission"),
+ PORTLET_APPLICATION("portlet-application"),
+ GADGET_APPLICATION("gadget-application"),
+ CONTAINER("container"),
+ PAGE_BODY("page-body"),
+ APPLICATION_REF("application-ref"),
+ PORTLET_REF("portlet-ref"),
+ PORTLET("portlet"),
+ GADGET_REF("gadget-ref"),
+ GADGET("gadget"),
+ THEME("theme"),
+ SHOW_INFO_BAR("show-info-bar"),
+ SHOW_APPLICATION_STATE("show-application-state"),
+ SHOW_APPLICATION_MODE("show-application-mode"),
+ ICON("icon"),
+ WIDTH("width"),
+ HEIGHT("height"),
+ PREFERENCES("preferences"),
+ PREFERENCE("preference"),
+ PREFERENCE_VALUE("value"),
+ PREFERENCE_READONLY("read-only")
+ ;
+
+ private final String name;
+
+ Element(String name)
+ {
+ this.name = name;
+ }
+
+ @Override
+ public String getLocalName()
+ {
+ return name;
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Namespace.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Namespace.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Namespace.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.binding.xml;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public enum Namespace
-{
-
GATEIN_OBJECTS_1_1("http://www.gatein.org/xml/ns/gatein_objects_1_1&...,
-
GATEIN_OBJECTS_1_2("http://www.gatein.org/xml/ns/gatein_objects_1_2&...;
-
- /**
- * The current namespace version.
- */
- public static final Namespace CURRENT = GATEIN_OBJECTS_1_2;
-
- private final String name;
-
- Namespace(final String name)
- {
- this.name = name;
- }
-
- /**
- * Get the URI of this namespace.
- *
- * @return the URI
- */
- public String getUri()
- {
- return name;
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Namespace.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Namespace.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Namespace.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Namespace.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.binding.xml;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public enum Namespace
+{
+
GATEIN_OBJECTS_1_1("http://www.gatein.org/xml/ns/gatein_objects_1_1&...,
+
GATEIN_OBJECTS_1_2("http://www.gatein.org/xml/ns/gatein_objects_1_2&...;
+
+ /**
+ * The current namespace version.
+ */
+ public static final Namespace CURRENT = GATEIN_OBJECTS_1_2;
+
+ private final String name;
+
+ Namespace(final String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Get the URI of this namespace.
+ *
+ * @return the URI
+ */
+ public String getUri()
+ {
+ return name;
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshaller.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshaller.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshaller.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,302 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.binding.xml;
-
-import org.exoplatform.portal.config.model.I18NString;
-import org.exoplatform.portal.config.model.LocalizedString;
-import org.exoplatform.portal.config.model.NavigationFragment;
-import org.exoplatform.portal.config.model.PageNavigation;
-import org.exoplatform.portal.config.model.PageNode;
-import org.exoplatform.portal.mop.Visibility;
-import org.gatein.common.xml.stax.writer.StaxWriter;
-import org.gatein.common.xml.stax.writer.WritableValueTypes;
-import org.gatein.management.api.binding.BindingException;
-import org.gatein.management.api.binding.Marshaller;
-import org.staxnav.StaxNavException;
-import org.staxnav.StaxNavigator;
-import org.staxnav.ValueType;
-
-import javax.xml.XMLConstants;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import static org.gatein.common.xml.stax.navigator.Exceptions.*;
-import static org.gatein.common.xml.stax.navigator.StaxNavUtils.*;
-import static org.gatein.common.xml.stax.writer.StaxWriterUtils.*;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class NavigationMarshaller implements Marshaller<PageNavigation>
-{
-
- @Override
- public void marshal(PageNavigation navigation, OutputStream outputStream) throws
BindingException
- {
- try
- {
- StaxWriter<Element> writer = createWriter(Element.class, outputStream);
- marshalNavigation(writer, navigation);
- }
- catch (StaxNavException e)
- {
- throw new BindingException(e);
- }
- catch (XMLStreamException e)
- {
- throw new BindingException(e);
- }
- }
-
- @Override
- public PageNavigation unmarshal(InputStream is) throws BindingException
- {
- try
- {
- StaxNavigator<Element> navigator = createNavigator(Element.class,
Element.UNKNOWN, is);
- return unmarshalNavigation(navigator);
- }
- catch (StaxNavException e)
- {
- throw new BindingException(e);
- }
- }
-
- private void marshalNavigation(StaxWriter<Element> writer, PageNavigation
navigation) throws XMLStreamException
- {
- writer.writeStartElement(Element.NODE_NAVIGATION);
-
- // Write gatein_objects xml namespace
- Utils.writeGateinObjectsNamespace(writer);
-
- // Priority
- writer.writeElement(Element.PRIORITY, WritableValueTypes.INTEGER,
navigation.getPriority());
-
- // Page nodes
- writer.writeStartElement(Element.PAGE_NODES);
- ArrayList<NavigationFragment> fragments = navigation.getFragments();
- for (NavigationFragment fragment : fragments)
- {
- if (fragment.getParentURI() != null)
- {
- String parentUri = fragment.getParentURI();
- writeOptionalElement(writer, Element.PARENT_URI, parentUri);
- }
-
- Collection<PageNode> nodes = fragment.getNodes();
- if (nodes != null && !nodes.isEmpty())
- {
- for (PageNode node : nodes)
- {
- marshallNode(writer, node);
- }
- }
- }
-
- writer.writeEndElement().writeEndElement(); // End page-nodes and node-navigation
- }
-
- public void marshallNode(StaxWriter<Element> writer, PageNode node) throws
XMLStreamException
- {
- writer.writeStartElement(Element.NODE);
- writer.writeElement(Element.NAME, node.getName());
-
- if (node.getLabels() != null)
- {
- for (LocalizedString label : node.getLabels())
- {
- writer.writeStartElement(Element.LABEL);
- if (label.getLang() != null)
- {
- String localeString = label.getLang().getLanguage();
- if (localeString == null)
- {
- throw new XMLStreamException("Language was null for locale "
+ label.getLang());
- }
- String country = label.getLang().getCountry();
- if (country != null && country.length() > 0)
- {
- localeString += "-" + country.toLowerCase();
- }
-
- writer.writeAttribute(new QName(XMLConstants.XML_NS_URI, "lang",
XMLConstants.XML_NS_PREFIX), localeString);
- }
- writer.writeContent(label.getValue()).writeEndElement();
- }
- }
-
- writeOptionalElement(writer, Element.ICON, node.getIcon());
-
- writeOptionalElement(writer, Element.START_PUBLICATION_DATE,
WritableValueTypes.DATE_TIME, node.getStartPublicationDate());
- writeOptionalElement(writer, Element.END_PUBLICATION_DATE,
WritableValueTypes.DATE_TIME, node.getEndPublicationDate());
-
- String visibility = (node.getVisibility() == null) ? null :
node.getVisibility().name();
- writeOptionalElement(writer, Element.VISIBILITY, visibility);
- writeOptionalElement(writer, Element.PAGE_REFERENCE, node.getPageReference());
-
- // Marshall children
- List<PageNode> children = node.getNodes();
- if (children != null && !children.isEmpty())
- {
- for (PageNode child : children)
- {
- marshallNode(writer, child);
- }
- }
-
- writer.writeEndElement(); // End of node
- }
-
- private PageNavigation unmarshalNavigation(StaxNavigator<Element> navigator)
throws StaxNavException
- {
- PageNavigation navigation = new PageNavigation();
-
- if (navigator.getName() == Element.NODE_NAVIGATION)
- {
- Element next = navigator.child();
- if (next != Element.PRIORITY)
- {
- throw expectedElement(navigator, Element.PRIORITY);
- }
- Integer priority = parseRequiredContent(navigator, ValueType.INTEGER);
- navigation.setPriority(priority);
-
- next = navigator.sibling();
- if (next == Element.PAGE_NODES)
- {
- for (StaxNavigator<Element> fork: navigator.fork(Element.PAGE_NODES))
- {
- NavigationFragment fragment = new NavigationFragment();
- navigation.addFragment(fragment);
-
- next = fork.child();
- if (next == Element.PARENT_URI)
- {
- String parentUri = fork.getContent();
- if (parentUri == null)
- {
- parentUri = "";
- }
- else if (parentUri.charAt(0) == '/')
- {
- parentUri = parentUri.substring(1, parentUri.length());
- }
- fragment.setParentURI(parentUri);
-
- next = fork.sibling();
- }
-
- if (next == Element.NODE)
- {
- ArrayList<PageNode> nodes = new ArrayList<PageNode>();
- for (StaxNavigator<Element> nodeFork : fork.fork(Element.NODE))
- {
- nodes.add(unmarshalNode(nodeFork));
- }
- fragment.setNodes(nodes);
- }
- else if (next != null)
- {
- throw unknownElement(fork);
- }
- }
- }
- else if (next != null)
- {
- throw expectedElement(navigator, Element.PAGE_NODES);
- }
-
- return navigation;
- }
- else
- {
- throw unknownElement(navigator);
- }
- }
-
- private PageNode unmarshalNode(StaxNavigator<Element> navigator) throws
StaxNavException
- {
- PageNode node = new PageNode();
- I18NString labels = new I18NString();
- ArrayList<PageNode> children = new ArrayList<PageNode>();
-
- Element current = navigator.child();
- while (current != null)
- {
- switch (navigator.getName())
- {
- case URI: // For backwards compatibility
- current = navigator.sibling();
- break;
- case NAME:
- node.setName(navigator.getContent());
- current = navigator.sibling();
- break;
- case LABEL:
- labels.add(Utils.parseLocalizedString(navigator));
- current = navigator.sibling();
- break;
- case ICON:
- node.setIcon(navigator.getContent());
- current = navigator.sibling();
- break;
- case START_PUBLICATION_DATE:
-
node.setStartPublicationDate(navigator.parseContent(ValueType.DATE_TIME));
- current = navigator.sibling();
- break;
- case END_PUBLICATION_DATE:
- node.setEndPublicationDate(navigator.parseContent(ValueType.DATE_TIME));
- current = navigator.sibling();
- break;
- case VISIBILITY:
-
node.setVisibility(navigator.parseContent(ValueType.get(Visibility.class)));
- current = navigator.sibling();
- break;
- case PAGE_REFERENCE:
- node.setPageReference(navigator.getContent());
- current = navigator.sibling();
- break;
- case NODE:
- PageNode child = unmarshalNode(navigator.fork());
- children.add(child);
- current = navigator.sibling();
- break;
- case UNKNOWN:
- throw unknownElement(navigator);
- default:
- throw unexpectedElement(navigator);
- }
- }
-
- node.setLabels(labels);
- node.setChildren(children);
-
- return node;
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshaller.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshaller.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshaller.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshaller.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,302 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.binding.xml;
+
+import org.exoplatform.portal.config.model.I18NString;
+import org.exoplatform.portal.config.model.LocalizedString;
+import org.exoplatform.portal.config.model.NavigationFragment;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PageNode;
+import org.exoplatform.portal.mop.Visibility;
+import org.gatein.common.xml.stax.writer.StaxWriter;
+import org.gatein.common.xml.stax.writer.WritableValueTypes;
+import org.gatein.management.api.binding.BindingException;
+import org.gatein.management.api.binding.Marshaller;
+import org.staxnav.StaxNavException;
+import org.staxnav.StaxNavigator;
+import org.staxnav.ValueType;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import static org.gatein.common.xml.stax.navigator.Exceptions.*;
+import static org.gatein.common.xml.stax.navigator.StaxNavUtils.*;
+import static org.gatein.common.xml.stax.writer.StaxWriterUtils.*;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationMarshaller implements Marshaller<PageNavigation>
+{
+
+ @Override
+ public void marshal(PageNavigation navigation, OutputStream outputStream) throws
BindingException
+ {
+ try
+ {
+ StaxWriter<Element> writer = createWriter(Element.class, outputStream);
+ marshalNavigation(writer, navigation);
+ }
+ catch (StaxNavException e)
+ {
+ throw new BindingException(e);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new BindingException(e);
+ }
+ }
+
+ @Override
+ public PageNavigation unmarshal(InputStream is) throws BindingException
+ {
+ try
+ {
+ StaxNavigator<Element> navigator = createNavigator(Element.class,
Element.UNKNOWN, is);
+ return unmarshalNavigation(navigator);
+ }
+ catch (StaxNavException e)
+ {
+ throw new BindingException(e);
+ }
+ }
+
+ private void marshalNavigation(StaxWriter<Element> writer, PageNavigation
navigation) throws XMLStreamException
+ {
+ writer.writeStartElement(Element.NODE_NAVIGATION);
+
+ // Write gatein_objects xml namespace
+ Utils.writeGateinObjectsNamespace(writer);
+
+ // Priority
+ writer.writeElement(Element.PRIORITY, WritableValueTypes.INTEGER,
navigation.getPriority());
+
+ // Page nodes
+ writer.writeStartElement(Element.PAGE_NODES);
+ ArrayList<NavigationFragment> fragments = navigation.getFragments();
+ for (NavigationFragment fragment : fragments)
+ {
+ if (fragment.getParentURI() != null)
+ {
+ String parentUri = fragment.getParentURI();
+ writeOptionalElement(writer, Element.PARENT_URI, parentUri);
+ }
+
+ Collection<PageNode> nodes = fragment.getNodes();
+ if (nodes != null && !nodes.isEmpty())
+ {
+ for (PageNode node : nodes)
+ {
+ marshallNode(writer, node);
+ }
+ }
+ }
+
+ writer.writeEndElement().writeEndElement(); // End page-nodes and node-navigation
+ }
+
+ public void marshallNode(StaxWriter<Element> writer, PageNode node) throws
XMLStreamException
+ {
+ writer.writeStartElement(Element.NODE);
+ writer.writeElement(Element.NAME, node.getName());
+
+ if (node.getLabels() != null)
+ {
+ for (LocalizedString label : node.getLabels())
+ {
+ writer.writeStartElement(Element.LABEL);
+ if (label.getLang() != null)
+ {
+ String localeString = label.getLang().getLanguage();
+ if (localeString == null)
+ {
+ throw new XMLStreamException("Language was null for locale "
+ label.getLang());
+ }
+ String country = label.getLang().getCountry();
+ if (country != null && country.length() > 0)
+ {
+ localeString += "-" + country.toLowerCase();
+ }
+
+ writer.writeAttribute(new QName(XMLConstants.XML_NS_URI, "lang",
XMLConstants.XML_NS_PREFIX), localeString);
+ }
+ writer.writeContent(label.getValue()).writeEndElement();
+ }
+ }
+
+ writeOptionalElement(writer, Element.ICON, node.getIcon());
+
+ writeOptionalElement(writer, Element.START_PUBLICATION_DATE,
WritableValueTypes.DATE_TIME, node.getStartPublicationDate());
+ writeOptionalElement(writer, Element.END_PUBLICATION_DATE,
WritableValueTypes.DATE_TIME, node.getEndPublicationDate());
+
+ String visibility = (node.getVisibility() == null) ? null :
node.getVisibility().name();
+ writeOptionalElement(writer, Element.VISIBILITY, visibility);
+ writeOptionalElement(writer, Element.PAGE_REFERENCE, node.getPageReference());
+
+ // Marshall children
+ List<PageNode> children = node.getNodes();
+ if (children != null && !children.isEmpty())
+ {
+ for (PageNode child : children)
+ {
+ marshallNode(writer, child);
+ }
+ }
+
+ writer.writeEndElement(); // End of node
+ }
+
+ private PageNavigation unmarshalNavigation(StaxNavigator<Element> navigator)
throws StaxNavException
+ {
+ PageNavigation navigation = new PageNavigation();
+
+ if (navigator.getName() == Element.NODE_NAVIGATION)
+ {
+ Element next = navigator.child();
+ if (next != Element.PRIORITY)
+ {
+ throw expectedElement(navigator, Element.PRIORITY);
+ }
+ Integer priority = parseRequiredContent(navigator, ValueType.INTEGER);
+ navigation.setPriority(priority);
+
+ next = navigator.sibling();
+ if (next == Element.PAGE_NODES)
+ {
+ for (StaxNavigator<Element> fork: navigator.fork(Element.PAGE_NODES))
+ {
+ NavigationFragment fragment = new NavigationFragment();
+ navigation.addFragment(fragment);
+
+ next = fork.child();
+ if (next == Element.PARENT_URI)
+ {
+ String parentUri = fork.getContent();
+ if (parentUri == null)
+ {
+ parentUri = "";
+ }
+ else if (parentUri.charAt(0) == '/')
+ {
+ parentUri = parentUri.substring(1, parentUri.length());
+ }
+ fragment.setParentURI(parentUri);
+
+ next = fork.sibling();
+ }
+
+ if (next == Element.NODE)
+ {
+ ArrayList<PageNode> nodes = new ArrayList<PageNode>();
+ for (StaxNavigator<Element> nodeFork : fork.fork(Element.NODE))
+ {
+ nodes.add(unmarshalNode(nodeFork));
+ }
+ fragment.setNodes(nodes);
+ }
+ else if (next != null)
+ {
+ throw unknownElement(fork);
+ }
+ }
+ }
+ else if (next != null)
+ {
+ throw expectedElement(navigator, Element.PAGE_NODES);
+ }
+
+ return navigation;
+ }
+ else
+ {
+ throw unknownElement(navigator);
+ }
+ }
+
+ private PageNode unmarshalNode(StaxNavigator<Element> navigator) throws
StaxNavException
+ {
+ PageNode node = new PageNode();
+ I18NString labels = new I18NString();
+ ArrayList<PageNode> children = new ArrayList<PageNode>();
+
+ Element current = navigator.child();
+ while (current != null)
+ {
+ switch (navigator.getName())
+ {
+ case URI: // For backwards compatibility
+ current = navigator.sibling();
+ break;
+ case NAME:
+ node.setName(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case LABEL:
+ labels.add(Utils.parseLocalizedString(navigator));
+ current = navigator.sibling();
+ break;
+ case ICON:
+ node.setIcon(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case START_PUBLICATION_DATE:
+
node.setStartPublicationDate(navigator.parseContent(ValueType.DATE_TIME));
+ current = navigator.sibling();
+ break;
+ case END_PUBLICATION_DATE:
+ node.setEndPublicationDate(navigator.parseContent(ValueType.DATE_TIME));
+ current = navigator.sibling();
+ break;
+ case VISIBILITY:
+
node.setVisibility(navigator.parseContent(ValueType.get(Visibility.class)));
+ current = navigator.sibling();
+ break;
+ case PAGE_REFERENCE:
+ node.setPageReference(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case NODE:
+ PageNode child = unmarshalNode(navigator.fork());
+ children.add(child);
+ current = navigator.sibling();
+ break;
+ case UNKNOWN:
+ throw unknownElement(navigator);
+ default:
+ throw unexpectedElement(navigator);
+ }
+ }
+
+ node.setLabels(labels);
+ node.setChildren(children);
+
+ return node;
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshaller.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshaller.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshaller.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,220 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.binding.xml;
-
-import org.exoplatform.portal.config.model.ModelObject;
-import org.exoplatform.portal.config.model.Page;
-import org.gatein.common.xml.stax.writer.StaxWriter;
-import org.gatein.common.xml.stax.writer.WritableValueTypes;
-import org.gatein.management.api.binding.BindingException;
-import org.staxnav.StaxNavException;
-import org.staxnav.StaxNavigator;
-import org.staxnav.ValueType;
-
-import javax.xml.stream.XMLStreamException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.gatein.common.xml.stax.navigator.Exceptions.*;
-import static org.gatein.common.xml.stax.navigator.StaxNavUtils.*;
-import static org.gatein.common.xml.stax.writer.StaxWriterUtils.*;
-
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PageMarshaller extends AbstractMarshaller<Page.PageSet>
-{
- @Override
- public void marshal(Page.PageSet pageSet, OutputStream outputStream) throws
BindingException
- {
- try
- {
- StaxWriter<Element> writer = createWriter(Element.class, outputStream);
-
- writer.writeStartElement(Element.PAGE_SET);
- writeGateinObjectsNamespace(writer);
-
- // Marshal pages
- for (Page page : pageSet.getPages())
- {
- marshalPage(writer, page);
- }
-
- writer.finish();
- }
- catch (StaxNavException e)
- {
- throw new BindingException(e);
- }
- catch (XMLStreamException e)
- {
- throw new BindingException(e);
- }
- }
-
- @Override
- public Page.PageSet unmarshal(InputStream inputStream) throws BindingException
- {
- try
- {
- StaxNavigator<Element> navigator = createNavigator(Element.class,
Element.UNKNOWN, inputStream);
- if (navigator.getName() == Element.PAGE_SET)
- {
- ArrayList<Page> pages = new ArrayList<Page>();
- Element next = navigator.child();
- if (next == Element.PAGE)
- {
- for (StaxNavigator<Element> fork : navigator.fork(Element.PAGE))
- {
- pages.add(unmarshalPage(fork));
- }
- }
- else if (next != null)
- {
- throw unexpectedElement(navigator);
- }
-
- //Seems like next should be null here...
- if (navigator.sibling() != null)
- {
- throw unexpectedElement(navigator);
- }
-
- Page.PageSet pageSet = new Page.PageSet();
- pageSet.setPages(pages);
-
- return pageSet;
- }
- else
- {
- throw unknownElement(navigator);
- }
- }
- catch (StaxNavException e)
- {
- throw new BindingException(e);
- }
- catch (XMLStreamException e)
- {
- throw new BindingException(e);
- }
- }
-
- private void marshalPage(StaxWriter<Element> writer, Page page) throws
XMLStreamException
- {
- writer.writeStartElement(Element.PAGE);
-
- // name, title description
- writer.writeElement(Element.NAME, page.getName());
- writeOptionalElement(writer, Element.TITLE, page.getTitle());
- writeOptionalElement(writer, Element.DESCRIPTION, page.getDescription());
-
- // Access/Edit permissions
- marshalAccessPermissions(writer, page.getAccessPermissions());
- marshalEditPermission(writer, page.getEditPermission());
-
- writeOptionalElement(writer, Element.SHOW_MAX_WINDOW, WritableValueTypes.BOOLEAN,
page.isShowMaxWindow());
-
- List<ModelObject> children = page.getChildren();
- for (ModelObject child : children)
- {
- marshalModelObject(writer, child);
- }
-
- writer.writeEndElement(); // End of page element
- }
-
- private Page unmarshalPage(StaxNavigator<Element> navigator) throws
XMLStreamException
- {
- requiresChild(navigator, Element.NAME);
- String name = getRequiredContent(navigator, true);
-
- Page page = new Page();
- page.setName(name);
-
- //TODO: Need valid way to ensure a sequence of xml elements, with a mix of required
and optional elements.
- Element current = navigator.sibling();
- while (current != null)
- {
- switch (current)
- {
- case TITLE:
- page.setTitle(getContent(navigator, false));
- current = navigator.sibling();
- break;
- case DESCRIPTION:
- page.setDescription(getContent(navigator, false));
- current = navigator.sibling();
- break;
- case ACCESS_PERMISSIONS:
- page.setAccessPermissions(unmarshalAccessPermissions(navigator, true));
- current = navigator.sibling();
- break;
- case EDIT_PERMISSION:
- page.setEditPermission(unmarshalEditPermission(navigator));
- current = navigator.sibling();
- break;
- case SHOW_MAX_WINDOW:
- page.setShowMaxWindow(parseRequiredContent(navigator,
ValueType.BOOLEAN));
- current = navigator.sibling();
- break;
- case CONTAINER:
- if (page.getChildren() == null)
- {
- page.setChildren(new ArrayList<ModelObject>());
- }
- page.getChildren().add(unmarshalContainer(navigator.fork()));
- current = navigator.sibling();
- break;
- case PORTLET_APPLICATION:
- if (page.getChildren() == null)
- {
- page.setChildren(new ArrayList<ModelObject>());
- }
- page.getChildren().add(unmarshalPortletApplication(navigator.fork()));
- current = navigator.sibling();
- break;
- case GADGET_APPLICATION:
- if (page.getChildren() == null)
- {
- page.setChildren(new ArrayList<ModelObject>());
- }
- page.getChildren().add(unmarshalGadgetApplication(navigator.fork()));
- current = navigator.sibling();
- break;
- case UNKNOWN:
- throw unknownElement(navigator);
- default:
- throw unexpectedElement(navigator);
- }
- }
- //TODO: We should raise this exception as soon as we know so location is accurate
- if (page.getAccessPermissions() == null) throw expectedElement(navigator,
Element.ACCESS_PERMISSIONS);
-
- return page;
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshaller.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshaller.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshaller.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshaller.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,220 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.binding.xml;
+
+import org.exoplatform.portal.config.model.ModelObject;
+import org.exoplatform.portal.config.model.Page;
+import org.gatein.common.xml.stax.writer.StaxWriter;
+import org.gatein.common.xml.stax.writer.WritableValueTypes;
+import org.gatein.management.api.binding.BindingException;
+import org.staxnav.StaxNavException;
+import org.staxnav.StaxNavigator;
+import org.staxnav.ValueType;
+
+import javax.xml.stream.XMLStreamException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.gatein.common.xml.stax.navigator.Exceptions.*;
+import static org.gatein.common.xml.stax.navigator.StaxNavUtils.*;
+import static org.gatein.common.xml.stax.writer.StaxWriterUtils.*;
+
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageMarshaller extends AbstractMarshaller<Page.PageSet>
+{
+ @Override
+ public void marshal(Page.PageSet pageSet, OutputStream outputStream) throws
BindingException
+ {
+ try
+ {
+ StaxWriter<Element> writer = createWriter(Element.class, outputStream);
+
+ writer.writeStartElement(Element.PAGE_SET);
+ writeGateinObjectsNamespace(writer);
+
+ // Marshal pages
+ for (Page page : pageSet.getPages())
+ {
+ marshalPage(writer, page);
+ }
+
+ writer.finish();
+ }
+ catch (StaxNavException e)
+ {
+ throw new BindingException(e);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new BindingException(e);
+ }
+ }
+
+ @Override
+ public Page.PageSet unmarshal(InputStream inputStream) throws BindingException
+ {
+ try
+ {
+ StaxNavigator<Element> navigator = createNavigator(Element.class,
Element.UNKNOWN, inputStream);
+ if (navigator.getName() == Element.PAGE_SET)
+ {
+ ArrayList<Page> pages = new ArrayList<Page>();
+ Element next = navigator.child();
+ if (next == Element.PAGE)
+ {
+ for (StaxNavigator<Element> fork : navigator.fork(Element.PAGE))
+ {
+ pages.add(unmarshalPage(fork));
+ }
+ }
+ else if (next != null)
+ {
+ throw unexpectedElement(navigator);
+ }
+
+ //Seems like next should be null here...
+ if (navigator.sibling() != null)
+ {
+ throw unexpectedElement(navigator);
+ }
+
+ Page.PageSet pageSet = new Page.PageSet();
+ pageSet.setPages(pages);
+
+ return pageSet;
+ }
+ else
+ {
+ throw unknownElement(navigator);
+ }
+ }
+ catch (StaxNavException e)
+ {
+ throw new BindingException(e);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new BindingException(e);
+ }
+ }
+
+ private void marshalPage(StaxWriter<Element> writer, Page page) throws
XMLStreamException
+ {
+ writer.writeStartElement(Element.PAGE);
+
+ // name, title description
+ writer.writeElement(Element.NAME, page.getName());
+ writeOptionalElement(writer, Element.TITLE, page.getTitle());
+ writeOptionalElement(writer, Element.DESCRIPTION, page.getDescription());
+
+ // Access/Edit permissions
+ marshalAccessPermissions(writer, page.getAccessPermissions());
+ marshalEditPermission(writer, page.getEditPermission());
+
+ writeOptionalElement(writer, Element.SHOW_MAX_WINDOW, WritableValueTypes.BOOLEAN,
page.isShowMaxWindow());
+
+ List<ModelObject> children = page.getChildren();
+ for (ModelObject child : children)
+ {
+ marshalModelObject(writer, child);
+ }
+
+ writer.writeEndElement(); // End of page element
+ }
+
+ private Page unmarshalPage(StaxNavigator<Element> navigator) throws
XMLStreamException
+ {
+ requiresChild(navigator, Element.NAME);
+ String name = getRequiredContent(navigator, true);
+
+ Page page = new Page();
+ page.setName(name);
+
+ //TODO: Need valid way to ensure a sequence of xml elements, with a mix of required
and optional elements.
+ Element current = navigator.sibling();
+ while (current != null)
+ {
+ switch (current)
+ {
+ case TITLE:
+ page.setTitle(getContent(navigator, false));
+ current = navigator.sibling();
+ break;
+ case DESCRIPTION:
+ page.setDescription(getContent(navigator, false));
+ current = navigator.sibling();
+ break;
+ case ACCESS_PERMISSIONS:
+ page.setAccessPermissions(unmarshalAccessPermissions(navigator, true));
+ current = navigator.sibling();
+ break;
+ case EDIT_PERMISSION:
+ page.setEditPermission(unmarshalEditPermission(navigator));
+ current = navigator.sibling();
+ break;
+ case SHOW_MAX_WINDOW:
+ page.setShowMaxWindow(parseRequiredContent(navigator,
ValueType.BOOLEAN));
+ current = navigator.sibling();
+ break;
+ case CONTAINER:
+ if (page.getChildren() == null)
+ {
+ page.setChildren(new ArrayList<ModelObject>());
+ }
+ page.getChildren().add(unmarshalContainer(navigator.fork()));
+ current = navigator.sibling();
+ break;
+ case PORTLET_APPLICATION:
+ if (page.getChildren() == null)
+ {
+ page.setChildren(new ArrayList<ModelObject>());
+ }
+ page.getChildren().add(unmarshalPortletApplication(navigator.fork()));
+ current = navigator.sibling();
+ break;
+ case GADGET_APPLICATION:
+ if (page.getChildren() == null)
+ {
+ page.setChildren(new ArrayList<ModelObject>());
+ }
+ page.getChildren().add(unmarshalGadgetApplication(navigator.fork()));
+ current = navigator.sibling();
+ break;
+ case UNKNOWN:
+ throw unknownElement(navigator);
+ default:
+ throw unexpectedElement(navigator);
+ }
+ }
+ //TODO: We should raise this exception as soon as we know so location is accurate
+ if (page.getAccessPermissions() == null) throw expectedElement(navigator,
Element.ACCESS_PERMISSIONS);
+
+ return page;
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshaller.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshaller.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshaller.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,292 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.binding.xml;
-
-import org.exoplatform.portal.config.model.Container;
-import org.exoplatform.portal.config.model.ModelObject;
-import org.exoplatform.portal.config.model.PageBody;
-import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.config.model.Properties;
-import org.gatein.common.xml.stax.navigator.StaxNavUtils;
-import org.gatein.common.xml.stax.writer.StaxWriter;
-import org.gatein.management.api.binding.BindingException;
-import org.staxnav.Axis;
-import org.staxnav.StaxNavException;
-import org.staxnav.StaxNavigator;
-
-import javax.xml.stream.XMLStreamException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.List;
-import java.util.Map;
-
-import static org.gatein.common.xml.stax.navigator.Exceptions.*;
-import static org.gatein.common.xml.stax.navigator.StaxNavUtils.*;
-import static org.gatein.common.xml.stax.writer.StaxWriterUtils.*;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class SiteLayoutMarshaller extends AbstractMarshaller<PortalConfig>
-{
- @Override
- public void marshal(PortalConfig object, OutputStream outputStream) throws
BindingException
- {
- try
- {
- StaxWriter<Element> writer = createWriter(Element.class, outputStream);
-
- // root element
- writer.writeStartElement(Element.PORTAL_CONFIG);
- writeGateinObjectsNamespace(writer);
-
- marshalPortalConfig(writer, object);
-
- writer.finish();
- }
- catch (StaxNavException e)
- {
- throw new BindingException(e);
- }
- catch (XMLStreamException e)
- {
- throw new BindingException(e);
- }
- }
-
- @Override
- public PortalConfig unmarshal(InputStream is) throws BindingException
- {
- try
- {
- StaxNavigator<Element> navigator =
StaxNavUtils.createNavigator(Element.class, Element.UNKNOWN, is);
-
- if (navigator.getName() == Element.PORTAL_CONFIG)
- {
- return unmarshalPortalConfig(navigator);
- }
- else
- {
- throw unknownElement(navigator);
- }
- }
- catch (StaxNavException e)
- {
- throw new BindingException(e);
- }
- catch (XMLStreamException e)
- {
- throw new BindingException(e);
- }
- }
-
- private void marshalPortalConfig(StaxWriter<Element> writer, PortalConfig
portalConfig) throws XMLStreamException
- {
- writer.writeElement(Element.PORTAL_NAME, portalConfig.getName());
- writeOptionalElement(writer, Element.LABEL, portalConfig.getLabel());
- writeOptionalElement(writer, Element.DESCRIPTION, portalConfig.getDescription());
- writeOptionalElement(writer, Element.LOCALE, portalConfig.getLocale());
-
- // Access permissions
- marshalAccessPermissions(writer, portalConfig.getAccessPermissions());
-
- // Edit permission
- marshalEditPermission(writer, portalConfig.getEditPermission());
-
- writeOptionalElement(writer, Element.SKIN, portalConfig.getSkin());
-
- boolean propertiesWritten = false;
- Map<String, String> properties = portalConfig.getProperties();
- if (properties != null)
- {
- for (String key : properties.keySet())
- {
- if (!propertiesWritten)
- {
- writer.writeStartElement(Element.PROPERTIES);
- propertiesWritten = true;
- }
- String value = properties.get(key);
- if (value != null)
- {
- writer.writeStartElement(Element.PROPERTIES_ENTRY);
- writer.writeAttribute(Attribute.PROPERTIES_KEY.getLocalName(), key);
- writer.writeContent(value).writeEndElement();
- }
- }
- if (propertiesWritten)
- {
- writer.writeEndElement();
- }
- }
-
- Container container = portalConfig.getPortalLayout();
- if (container != null)
- {
- writer.writeStartElement(Element.PORTAL_LAYOUT);
- List<ModelObject> children = container.getChildren();
- if (children != null && !children.isEmpty())
- {
- for (ModelObject child : children)
- {
- marshalModelObject(writer, child);
- }
- }
- writer.writeEndElement();
- }
- }
-
- private PortalConfig unmarshalPortalConfig(StaxNavigator<Element> navigator)
throws XMLStreamException
- {
- PortalConfig portalConfig = new PortalConfig();
-
- Container portalLayout = null;
- Element current = navigator.child();
- while (current != null)
- {
- switch (current)
- {
- case PORTAL_NAME:
- portalConfig.setName(navigator.getContent());
- current = navigator.sibling();
- break;
- case LOCALE:
- portalConfig.setLocale(navigator.getContent());
- current = navigator.sibling();
- break;
- case LABEL:
- portalConfig.setLabel(navigator.getContent());
- current = navigator.sibling();
- break;
- case DESCRIPTION:
- portalConfig.setDescription(navigator.getContent());
- current = navigator.sibling();
- break;
- case SKIN:
- portalConfig.setSkin(navigator.getContent());
- current = navigator.sibling();
- break;
- case PROPERTIES:
- Properties properties = new Properties();
- if (navigator.navigate(Axis.CHILD, Element.PROPERTIES_ENTRY))
- {
- for (StaxNavigator<Element> fork :
navigator.fork(Element.PROPERTIES_ENTRY))
- {
- String key = getRequiredAttribute(fork,
Attribute.PROPERTIES_KEY.getLocalName());
- String value = getRequiredContent(fork, false);
- properties.put(key, value);
- }
- }
- else
- {
- throw expectedElement(navigator, Element.PROPERTIES_ENTRY);
- }
- portalConfig.setProperties(properties);
- current = navigator.next();
- break;
- case ACCESS_PERMISSIONS:
- portalConfig.setAccessPermissions(unmarshalAccessPermissions(navigator,
false));
- current = navigator.sibling();
- break;
- case EDIT_PERMISSION:
- portalConfig.setEditPermission(unmarshalEditPermission(navigator));
- current = navigator.sibling();
- break;
- case PORTAL_LAYOUT:
- portalLayout = new Container();
- current = navigator.child();
- break;
- case PAGE_BODY:
- if (portalLayout == null)
- {
- throw expectedElement(navigator, Element.PORTAL_LAYOUT);
- }
- portalLayout.getChildren().add(new PageBody());
- current = navigator.sibling();
- break;
- case PORTLET_APPLICATION:
- if (portalLayout == null)
- {
- throw expectedElement(navigator, Element.PORTAL_LAYOUT);
- }
-
portalLayout.getChildren().add(unmarshalPortletApplication(navigator.fork()));
- current = navigator.sibling();
- break;
- case GADGET_APPLICATION:
- if (portalLayout == null)
- {
- throw expectedElement(navigator, Element.PORTAL_LAYOUT);
- }
-
portalLayout.getChildren().add(unmarshalGadgetApplication(navigator.fork()));
- current = navigator.sibling();
- break;
- case CONTAINER:
- if (portalLayout == null)
- {
- throw expectedElement(navigator, Element.PORTAL_LAYOUT);
- }
- portalLayout.getChildren().add(unmarshalContainer(navigator.fork()));
- current = navigator.sibling();
- break;
- case UNKNOWN:
- throw unknownElement(navigator);
- default:
- throw unexpectedElement(navigator);
- }
- }
-
- //TODO: We should raise this exception as soon as we know so location is accurate
- if (portalConfig.getAccessPermissions() == null) throw expectedElement(navigator,
Element.ACCESS_PERMISSIONS);
- if (portalLayout == null)
- {
- portalLayout = PortalConfig.DEFAULT_LAYOUT;
- }
-
- portalConfig.setPortalLayout(portalLayout);
-
- return portalConfig;
- }
-
- private static enum Attribute
- {
- PROPERTIES_KEY("key");
-
- private final String name;
-
- Attribute(final String name)
- {
- this.name = name;
- }
-
- /**
- * Get the local name of this element.
- *
- * @return the local name
- */
- public String getLocalName()
- {
- return name;
- }
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshaller.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshaller.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshaller.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshaller.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,292 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.binding.xml;
+
+import org.exoplatform.portal.config.model.Container;
+import org.exoplatform.portal.config.model.ModelObject;
+import org.exoplatform.portal.config.model.PageBody;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.config.model.Properties;
+import org.gatein.common.xml.stax.navigator.StaxNavUtils;
+import org.gatein.common.xml.stax.writer.StaxWriter;
+import org.gatein.management.api.binding.BindingException;
+import org.staxnav.Axis;
+import org.staxnav.StaxNavException;
+import org.staxnav.StaxNavigator;
+
+import javax.xml.stream.XMLStreamException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+import java.util.Map;
+
+import static org.gatein.common.xml.stax.navigator.Exceptions.*;
+import static org.gatein.common.xml.stax.navigator.StaxNavUtils.*;
+import static org.gatein.common.xml.stax.writer.StaxWriterUtils.*;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SiteLayoutMarshaller extends AbstractMarshaller<PortalConfig>
+{
+ @Override
+ public void marshal(PortalConfig object, OutputStream outputStream) throws
BindingException
+ {
+ try
+ {
+ StaxWriter<Element> writer = createWriter(Element.class, outputStream);
+
+ // root element
+ writer.writeStartElement(Element.PORTAL_CONFIG);
+ writeGateinObjectsNamespace(writer);
+
+ marshalPortalConfig(writer, object);
+
+ writer.finish();
+ }
+ catch (StaxNavException e)
+ {
+ throw new BindingException(e);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new BindingException(e);
+ }
+ }
+
+ @Override
+ public PortalConfig unmarshal(InputStream is) throws BindingException
+ {
+ try
+ {
+ StaxNavigator<Element> navigator =
StaxNavUtils.createNavigator(Element.class, Element.UNKNOWN, is);
+
+ if (navigator.getName() == Element.PORTAL_CONFIG)
+ {
+ return unmarshalPortalConfig(navigator);
+ }
+ else
+ {
+ throw unknownElement(navigator);
+ }
+ }
+ catch (StaxNavException e)
+ {
+ throw new BindingException(e);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new BindingException(e);
+ }
+ }
+
+ private void marshalPortalConfig(StaxWriter<Element> writer, PortalConfig
portalConfig) throws XMLStreamException
+ {
+ writer.writeElement(Element.PORTAL_NAME, portalConfig.getName());
+ writeOptionalElement(writer, Element.LABEL, portalConfig.getLabel());
+ writeOptionalElement(writer, Element.DESCRIPTION, portalConfig.getDescription());
+ writeOptionalElement(writer, Element.LOCALE, portalConfig.getLocale());
+
+ // Access permissions
+ marshalAccessPermissions(writer, portalConfig.getAccessPermissions());
+
+ // Edit permission
+ marshalEditPermission(writer, portalConfig.getEditPermission());
+
+ writeOptionalElement(writer, Element.SKIN, portalConfig.getSkin());
+
+ boolean propertiesWritten = false;
+ Map<String, String> properties = portalConfig.getProperties();
+ if (properties != null)
+ {
+ for (String key : properties.keySet())
+ {
+ if (!propertiesWritten)
+ {
+ writer.writeStartElement(Element.PROPERTIES);
+ propertiesWritten = true;
+ }
+ String value = properties.get(key);
+ if (value != null)
+ {
+ writer.writeStartElement(Element.PROPERTIES_ENTRY);
+ writer.writeAttribute(Attribute.PROPERTIES_KEY.getLocalName(), key);
+ writer.writeContent(value).writeEndElement();
+ }
+ }
+ if (propertiesWritten)
+ {
+ writer.writeEndElement();
+ }
+ }
+
+ Container container = portalConfig.getPortalLayout();
+ if (container != null)
+ {
+ writer.writeStartElement(Element.PORTAL_LAYOUT);
+ List<ModelObject> children = container.getChildren();
+ if (children != null && !children.isEmpty())
+ {
+ for (ModelObject child : children)
+ {
+ marshalModelObject(writer, child);
+ }
+ }
+ writer.writeEndElement();
+ }
+ }
+
+ private PortalConfig unmarshalPortalConfig(StaxNavigator<Element> navigator)
throws XMLStreamException
+ {
+ PortalConfig portalConfig = new PortalConfig();
+
+ Container portalLayout = null;
+ Element current = navigator.child();
+ while (current != null)
+ {
+ switch (current)
+ {
+ case PORTAL_NAME:
+ portalConfig.setName(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case LOCALE:
+ portalConfig.setLocale(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case LABEL:
+ portalConfig.setLabel(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case DESCRIPTION:
+ portalConfig.setDescription(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case SKIN:
+ portalConfig.setSkin(navigator.getContent());
+ current = navigator.sibling();
+ break;
+ case PROPERTIES:
+ Properties properties = new Properties();
+ if (navigator.navigate(Axis.CHILD, Element.PROPERTIES_ENTRY))
+ {
+ for (StaxNavigator<Element> fork :
navigator.fork(Element.PROPERTIES_ENTRY))
+ {
+ String key = getRequiredAttribute(fork,
Attribute.PROPERTIES_KEY.getLocalName());
+ String value = getRequiredContent(fork, false);
+ properties.put(key, value);
+ }
+ }
+ else
+ {
+ throw expectedElement(navigator, Element.PROPERTIES_ENTRY);
+ }
+ portalConfig.setProperties(properties);
+ current = navigator.next();
+ break;
+ case ACCESS_PERMISSIONS:
+ portalConfig.setAccessPermissions(unmarshalAccessPermissions(navigator,
false));
+ current = navigator.sibling();
+ break;
+ case EDIT_PERMISSION:
+ portalConfig.setEditPermission(unmarshalEditPermission(navigator));
+ current = navigator.sibling();
+ break;
+ case PORTAL_LAYOUT:
+ portalLayout = new Container();
+ current = navigator.child();
+ break;
+ case PAGE_BODY:
+ if (portalLayout == null)
+ {
+ throw expectedElement(navigator, Element.PORTAL_LAYOUT);
+ }
+ portalLayout.getChildren().add(new PageBody());
+ current = navigator.sibling();
+ break;
+ case PORTLET_APPLICATION:
+ if (portalLayout == null)
+ {
+ throw expectedElement(navigator, Element.PORTAL_LAYOUT);
+ }
+
portalLayout.getChildren().add(unmarshalPortletApplication(navigator.fork()));
+ current = navigator.sibling();
+ break;
+ case GADGET_APPLICATION:
+ if (portalLayout == null)
+ {
+ throw expectedElement(navigator, Element.PORTAL_LAYOUT);
+ }
+
portalLayout.getChildren().add(unmarshalGadgetApplication(navigator.fork()));
+ current = navigator.sibling();
+ break;
+ case CONTAINER:
+ if (portalLayout == null)
+ {
+ throw expectedElement(navigator, Element.PORTAL_LAYOUT);
+ }
+ portalLayout.getChildren().add(unmarshalContainer(navigator.fork()));
+ current = navigator.sibling();
+ break;
+ case UNKNOWN:
+ throw unknownElement(navigator);
+ default:
+ throw unexpectedElement(navigator);
+ }
+ }
+
+ //TODO: We should raise this exception as soon as we know so location is accurate
+ if (portalConfig.getAccessPermissions() == null) throw expectedElement(navigator,
Element.ACCESS_PERMISSIONS);
+ if (portalLayout == null)
+ {
+ portalLayout = PortalConfig.DEFAULT_LAYOUT;
+ }
+
+ portalConfig.setPortalLayout(portalLayout);
+
+ return portalConfig;
+ }
+
+ private static enum Attribute
+ {
+ PROPERTIES_KEY("key");
+
+ private final String name;
+
+ Attribute(final String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Get the local name of this element.
+ *
+ * @return the local name
+ */
+ public String getLocalName()
+ {
+ return name;
+ }
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Utils.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Utils.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Utils.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,91 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.binding.xml;
-
-import org.exoplatform.portal.config.model.LocalizedString;
-import org.gatein.common.xml.stax.navigator.StaxNavUtils;
-import org.gatein.common.xml.stax.writer.StaxWriter;
-import org.staxnav.StaxNavException;
-import org.staxnav.StaxNavigator;
-
-import javax.xml.XMLConstants;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import java.util.Locale;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-class Utils
-{
- private static final Pattern XMLLANG_PATTERN =
Pattern.compile("^([a-zA-Z]{2})(?:-([a-zA-Z]{2}))?$");
-
- public static <N> void writeGateinObjectsNamespace(StaxWriter<N> writer)
throws XMLStreamException
- {
- String gatein_object_ns = Namespace.CURRENT.getUri();
- String location = new StringBuilder().append(gatein_object_ns).append("
").append(gatein_object_ns).toString();
-
- writer.writeDefaultNamespace(gatein_object_ns);
- writer.writeNamespace("xsi",
XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
- writer.writeAttribute(new QName(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,
"schemaLocation"), location);
- }
-
- public static <N> LocalizedString parseLocalizedString(StaxNavigator<N>
navigator) throws StaxNavException
- {
- String attribute = navigator.getAttribute(new QName(XMLConstants.XML_NS_URI,
"lang", XMLConstants.XML_NS_PREFIX));
- if (attribute == null)
- {
- attribute = navigator.getAttribute("lang");
- }
-
- Locale lang = null;
- if (attribute != null)
- {
- Matcher matcher = XMLLANG_PATTERN.matcher(attribute);
- if (matcher.matches())
- {
- String langISO = matcher.group(1);
- String countryISO = matcher.group(2);
- if (countryISO == null)
- {
- lang = new Locale(langISO.toLowerCase());
- }
- else
- {
- lang = new Locale(langISO.toLowerCase(), countryISO.toLowerCase());
- }
- }
- else
- {
- throw new StaxNavException(navigator.getLocation(), "The attribute
xml:lang='" + attribute + "' does not represent a valid language pattern
(ie: en, en-us).");
- }
- }
-
- String value = StaxNavUtils.getRequiredContent(navigator, false);
-
- return new LocalizedString(value, lang);
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Utils.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Utils.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Utils.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/Utils.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.binding.xml;
+
+import org.exoplatform.portal.config.model.LocalizedString;
+import org.gatein.common.xml.stax.navigator.StaxNavUtils;
+import org.gatein.common.xml.stax.writer.StaxWriter;
+import org.staxnav.StaxNavException;
+import org.staxnav.StaxNavigator;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+class Utils
+{
+ private static final Pattern XMLLANG_PATTERN =
Pattern.compile("^([a-zA-Z]{2})(?:-([a-zA-Z]{2}))?$");
+
+ public static <N> void writeGateinObjectsNamespace(StaxWriter<N> writer)
throws XMLStreamException
+ {
+ String gatein_object_ns = Namespace.CURRENT.getUri();
+ String location = new StringBuilder().append(gatein_object_ns).append("
").append(gatein_object_ns).toString();
+
+ writer.writeDefaultNamespace(gatein_object_ns);
+ writer.writeNamespace("xsi",
XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
+ writer.writeAttribute(new QName(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,
"schemaLocation"), location);
+ }
+
+ public static <N> LocalizedString parseLocalizedString(StaxNavigator<N>
navigator) throws StaxNavException
+ {
+ String attribute = navigator.getAttribute(new QName(XMLConstants.XML_NS_URI,
"lang", XMLConstants.XML_NS_PREFIX));
+ if (attribute == null)
+ {
+ attribute = navigator.getAttribute("lang");
+ }
+
+ Locale lang = null;
+ if (attribute != null)
+ {
+ Matcher matcher = XMLLANG_PATTERN.matcher(attribute);
+ if (matcher.matches())
+ {
+ String langISO = matcher.group(1);
+ String countryISO = matcher.group(2);
+ if (countryISO == null)
+ {
+ lang = new Locale(langISO.toLowerCase());
+ }
+ else
+ {
+ lang = new Locale(langISO.toLowerCase(), countryISO.toLowerCase());
+ }
+ }
+ else
+ {
+ throw new StaxNavException(navigator.getLocation(), "The attribute
xml:lang='" + attribute + "' does not represent a valid language pattern
(ie: en, en-us).");
+ }
+ }
+
+ String value = StaxNavUtils.getRequiredContent(navigator, false);
+
+ return new LocalizedString(value, lang);
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractExportTask.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractExportTask.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractExportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.exportimport;
-
-import org.exoplatform.portal.mop.SiteKey;
-import org.gatein.management.api.operation.model.ExportTask;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public abstract class AbstractExportTask implements ExportTask
-{
- protected SiteKey siteKey;
-
- protected AbstractExportTask(SiteKey siteKey)
- {
- this.siteKey = siteKey;
- }
-
- @Override
- public String getEntry()
- {
- String siteType = siteKey.getTypeName();
-
- String siteName = siteKey.getName();
- if (siteName.charAt(0) == '/') siteName = siteName.substring(1,
siteName.length());
-
- return new StringBuilder().
-
append(siteType).append("/").append(siteName).append("/").append(getXmlFileName()).toString();
- }
-
- protected abstract String getXmlFileName();
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractExportTask.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractExportTask.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractExportTask.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractExportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.exportimport;
+
+import org.exoplatform.portal.mop.SiteKey;
+import org.gatein.management.api.operation.model.ExportTask;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class AbstractExportTask implements ExportTask
+{
+ protected SiteKey siteKey;
+
+ protected AbstractExportTask(SiteKey siteKey)
+ {
+ this.siteKey = siteKey;
+ }
+
+ @Override
+ public String getEntry()
+ {
+ String siteType = siteKey.getTypeName();
+
+ String siteName = siteKey.getName();
+ if (siteName.charAt(0) == '/') siteName = siteName.substring(1,
siteName.length());
+
+ return new StringBuilder().
+
append(siteType).append("/").append(siteName).append("/").append(getXmlFileName()).toString();
+ }
+
+ protected abstract String getXmlFileName();
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractImportTask.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractImportTask.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractImportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.exportimport;
-
-import org.exoplatform.portal.mop.SiteKey;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public abstract class AbstractImportTask<T> extends ImportTask<T>
-{
- protected final SiteKey siteKey;
-
- public AbstractImportTask(T data, SiteKey siteKey)
- {
- super(data);
- this.siteKey = siteKey;
- }
-
- public SiteKey getSiteKey()
- {
- return siteKey;
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractImportTask.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractImportTask.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractImportTask.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/AbstractImportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.exportimport;
+
+import org.exoplatform.portal.mop.SiteKey;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class AbstractImportTask<T> extends ImportTask<T>
+{
+ protected final SiteKey siteKey;
+
+ public AbstractImportTask(T data, SiteKey siteKey)
+ {
+ super(data);
+ this.siteKey = siteKey;
+ }
+
+ public SiteKey getSiteKey()
+ {
+ return siteKey;
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportStrategy.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportStrategy.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportStrategy.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.exportimport;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public enum ImportStrategy
-{
- /**
- * Import when data does not exist. Otherwise do nothing.
- */
- CONSERVE("conserve"),
-
- /**
- * Import when data does not exist. Otherwise perform a merge
- */
- MERGE("merge"),
-
- /**
- * Delete existing data, import new data.
- */
- OVERWRITE("overwrite");
-
- private String name;
-
- ImportStrategy(String name)
- {
- this.name = name;
- }
-
- private static final Map<String, ImportStrategy> MAP;
-
- static
- {
- Map<String, ImportStrategy> tmp = new HashMap<String,
ImportStrategy>(3);
- for (ImportStrategy strategy : ImportStrategy.values())
- {
- tmp.put(strategy.name, strategy);
- }
-
- MAP = tmp;
- }
-
- public String getName()
- {
- return name;
- }
-
- public static ImportStrategy forName(String name)
- {
- return MAP.get(name);
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportStrategy.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportStrategy.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportStrategy.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportStrategy.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.exportimport;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public enum ImportStrategy
+{
+ /**
+ * Import when data does not exist. Otherwise do nothing.
+ */
+ CONSERVE("conserve"),
+
+ /**
+ * Import when data does not exist. Otherwise perform a merge
+ */
+ MERGE("merge"),
+
+ /**
+ * Delete existing data, import new data.
+ */
+ OVERWRITE("overwrite");
+
+ private String name;
+
+ ImportStrategy(String name)
+ {
+ this.name = name;
+ }
+
+ private static final Map<String, ImportStrategy> MAP;
+
+ static
+ {
+ Map<String, ImportStrategy> tmp = new HashMap<String,
ImportStrategy>(3);
+ for (ImportStrategy strategy : ImportStrategy.values())
+ {
+ tmp.put(strategy.name, strategy);
+ }
+
+ MAP = tmp;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public static ImportStrategy forName(String name)
+ {
+ return MAP.get(name);
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportTask.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportTask.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.exportimport;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public abstract class ImportTask<T>
-{
- protected final T data;
- protected ImportTask(T data)
- {
- this.data = data;
- }
-
- public abstract void importData(ImportStrategy importStrategy) throws Exception;
-
- public abstract void rollback() throws Exception;
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportTask.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportTask.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportTask.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/ImportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.exportimport;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class ImportTask<T>
+{
+ protected final T data;
+ protected ImportTask(T data)
+ {
+ this.data = data;
+ }
+
+ public abstract void importData(ImportStrategy importStrategy) throws Exception;
+
+ public abstract void rollback() throws Exception;
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.exportimport;
-
-import org.exoplatform.portal.config.model.PageNavigation;
-import org.exoplatform.portal.mop.description.DescriptionService;
-import org.exoplatform.portal.mop.management.operations.navigation.NavigationKey;
-import org.exoplatform.portal.mop.management.operations.navigation.NavigationUtils;
-import org.exoplatform.portal.mop.navigation.NavigationService;
-import org.gatein.management.api.binding.Marshaller;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class NavigationExportTask extends AbstractExportTask
-{
- public static final String FILE = "navigation.xml";
-
- private NavigationKey navigationKey;
- private Marshaller<PageNavigation> marshaller;
- private NavigationService navigationService;
- private DescriptionService descriptionService;
-
- public NavigationExportTask(NavigationKey navigationKey, NavigationService
navigationService,
- DescriptionService descriptionService,
Marshaller<PageNavigation> marshaller)
- {
- super(navigationKey.getSiteKey());
- this.navigationKey = navigationKey;
- this.navigationService = navigationService;
- this.descriptionService = descriptionService;
- this.marshaller = marshaller;
- }
-
- @Override
- protected String getXmlFileName()
- {
- return FILE;
- }
-
- @Override
- public void export(OutputStream outputStream) throws IOException
- {
- PageNavigation navigation = NavigationUtils.loadPageNavigation(navigationKey,
navigationService, descriptionService);
- marshaller.marshal(navigation, outputStream);
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.exportimport;
+
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.mop.description.DescriptionService;
+import org.exoplatform.portal.mop.management.operations.navigation.NavigationKey;
+import org.exoplatform.portal.mop.management.operations.navigation.NavigationUtils;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.gatein.management.api.binding.Marshaller;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationExportTask extends AbstractExportTask
+{
+ public static final String FILE = "navigation.xml";
+
+ private NavigationKey navigationKey;
+ private Marshaller<PageNavigation> marshaller;
+ private NavigationService navigationService;
+ private DescriptionService descriptionService;
+
+ public NavigationExportTask(NavigationKey navigationKey, NavigationService
navigationService,
+ DescriptionService descriptionService,
Marshaller<PageNavigation> marshaller)
+ {
+ super(navigationKey.getSiteKey());
+ this.navigationKey = navigationKey;
+ this.navigationService = navigationService;
+ this.descriptionService = descriptionService;
+ this.marshaller = marshaller;
+ }
+
+ @Override
+ protected String getXmlFileName()
+ {
+ return FILE;
+ }
+
+ @Override
+ public void export(OutputStream outputStream) throws IOException
+ {
+ PageNavigation navigation = NavigationUtils.loadPageNavigation(navigationKey,
navigationService, descriptionService);
+ marshaller.marshal(navigation, outputStream);
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationImportTask.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationImportTask.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationImportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,130 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.exportimport;
-
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.model.PageNavigation;
-import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.description.DescriptionService;
-import org.exoplatform.portal.mop.importer.ImportMode;
-import org.exoplatform.portal.mop.importer.NavigationImporter;
-import org.exoplatform.portal.mop.navigation.NavigationContext;
-import org.exoplatform.portal.mop.navigation.NavigationService;
-import org.exoplatform.portal.pom.data.ModelDataStorage;
-import org.exoplatform.portal.pom.data.PortalData;
-import org.exoplatform.portal.pom.data.PortalKey;
-import org.gatein.common.logging.Logger;
-import org.gatein.common.logging.LoggerFactory;
-
-import java.util.Locale;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class NavigationImportTask extends AbstractImportTask<PageNavigation>
-{
- private static final Logger log =
LoggerFactory.getLogger(NavigationImportTask.class);
-
- private NavigationService navigationService;
- private DescriptionService descriptionService;
- private DataStorage dataStorage;
- private RollbackTask rollbackTask;
-
- public NavigationImportTask(PageNavigation data, SiteKey siteKey,
- NavigationService navigationService, DescriptionService
descriptionService, DataStorage dataStorage)
- {
- super(data, siteKey);
- this.navigationService = navigationService;
- this.descriptionService = descriptionService;
- this.dataStorage = dataStorage;
- }
-
- @Override
- public void importData(ImportStrategy importStrategy) throws Exception
- {
- ImportMode mode;
- switch (importStrategy)
- {
- case CONSERVE:
- mode = ImportMode.INSERT;
- break;
- case MERGE:
- mode = ImportMode.MERGE;
- break;
- case OVERWRITE:
- mode = ImportMode.OVERWRITE;
- break;
- default:
- throw new Exception("Could not map import strategy " +
importStrategy.getName() + " to import mode.");
- }
-
- PortalConfig portalConfig = dataStorage.getPortalConfig(siteKey.getTypeName(),
siteKey.getName());
- if (portalConfig == null) throw new Exception("Cannot import navigation
because site does not exist for " + siteKey);
-
- Locale locale = (portalConfig.getLocale() == null) ? Locale.ENGLISH : new
Locale(portalConfig.getLocale());
-
- final NavigationContext navContext = navigationService.loadNavigation(siteKey);
- if (navContext == null)
- {
- rollbackTask = new RollbackTask()
- {
- @Override
- public void rollback() throws Exception
- {
- navigationService.destroyNavigation(navContext);
- }
- };
- }
- else
- {
- //TODO: Rollback updates.
- rollbackTask = new RollbackTask()
- {
- @Override
- public void rollback() throws Exception
- {
- log.warn("Rollback for existing navigation not supported at the
moment.");
- }
- };
- }
-
- NavigationImporter importer = new NavigationImporter(locale, mode, data,
navigationService, descriptionService);
- importer.perform();
- }
-
- @Override
- public void rollback() throws Exception
- {
- if (rollbackTask != null)
- {
- rollbackTask.rollback();
- }
- }
-
- private static interface RollbackTask
- {
- void rollback() throws Exception;
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationImportTask.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationImportTask.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationImportTask.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationImportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.exportimport;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.description.DescriptionService;
+import org.exoplatform.portal.mop.importer.ImportMode;
+import org.exoplatform.portal.mop.importer.NavigationImporter;
+import org.exoplatform.portal.mop.navigation.NavigationContext;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.exoplatform.portal.pom.data.ModelDataStorage;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.exoplatform.portal.pom.data.PortalKey;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationImportTask extends AbstractImportTask<PageNavigation>
+{
+ private static final Logger log =
LoggerFactory.getLogger(NavigationImportTask.class);
+
+ private NavigationService navigationService;
+ private DescriptionService descriptionService;
+ private DataStorage dataStorage;
+ private RollbackTask rollbackTask;
+
+ public NavigationImportTask(PageNavigation data, SiteKey siteKey,
+ NavigationService navigationService, DescriptionService
descriptionService, DataStorage dataStorage)
+ {
+ super(data, siteKey);
+ this.navigationService = navigationService;
+ this.descriptionService = descriptionService;
+ this.dataStorage = dataStorage;
+ }
+
+ @Override
+ public void importData(ImportStrategy importStrategy) throws Exception
+ {
+ ImportMode mode;
+ switch (importStrategy)
+ {
+ case CONSERVE:
+ mode = ImportMode.INSERT;
+ break;
+ case MERGE:
+ mode = ImportMode.MERGE;
+ break;
+ case OVERWRITE:
+ mode = ImportMode.OVERWRITE;
+ break;
+ default:
+ throw new Exception("Could not map import strategy " +
importStrategy.getName() + " to import mode.");
+ }
+
+ PortalConfig portalConfig = dataStorage.getPortalConfig(siteKey.getTypeName(),
siteKey.getName());
+ if (portalConfig == null) throw new Exception("Cannot import navigation
because site does not exist for " + siteKey);
+
+ Locale locale = (portalConfig.getLocale() == null) ? Locale.ENGLISH : new
Locale(portalConfig.getLocale());
+
+ final NavigationContext navContext = navigationService.loadNavigation(siteKey);
+ if (navContext == null)
+ {
+ rollbackTask = new RollbackTask()
+ {
+ @Override
+ public void rollback() throws Exception
+ {
+ navigationService.destroyNavigation(navContext);
+ }
+ };
+ }
+ else
+ {
+ //TODO: Rollback updates.
+ rollbackTask = new RollbackTask()
+ {
+ @Override
+ public void rollback() throws Exception
+ {
+ log.warn("Rollback for existing navigation not supported at the
moment.");
+ }
+ };
+ }
+
+ NavigationImporter importer = new NavigationImporter(locale, mode, data,
navigationService, descriptionService);
+ importer.perform();
+ }
+
+ @Override
+ public void rollback() throws Exception
+ {
+ if (rollbackTask != null)
+ {
+ rollbackTask.rollback();
+ }
+ }
+
+ private static interface RollbackTask
+ {
+ void rollback() throws Exception;
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/POMSessionExportTask.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/POMSessionExportTask.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/POMSessionExportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.exportimport;
-
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.pom.config.POMSession;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public abstract class POMSessionExportTask extends AbstractExportTask
-{
- protected POMSession session;
-
- public POMSessionExportTask(SiteKey siteKey, POMSession session)
- {
- super(siteKey);
- this.session = session;
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/POMSessionExportTask.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/POMSessionExportTask.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/POMSessionExportTask.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/POMSessionExportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.exportimport;
+
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.pom.config.POMSession;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class POMSessionExportTask extends AbstractExportTask
+{
+ protected POMSession session;
+
+ public POMSessionExportTask(SiteKey siteKey, POMSession session)
+ {
+ super(siteKey);
+ this.session = session;
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageExportTask.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageExportTask.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageExportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,95 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.exportimport;
-
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.model.Page;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.pom.config.POMSession;
-import org.exoplatform.portal.pom.config.Utils;
-import org.gatein.management.api.binding.Marshaller;
-import org.gatein.management.api.operation.model.ExportTask;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PageExportTask extends AbstractExportTask implements ExportTask
-{
- public static final String FILE = "pages.xml";
-
- private final DataStorage dataStorage;
- private final Marshaller<Page.PageSet> marshaller;
- private final List<String> pageNames;
-
- public PageExportTask(SiteKey siteKey, DataStorage dataStorage,
Marshaller<Page.PageSet> marshaller)
- {
- super(siteKey);
- this.dataStorage = dataStorage;
- this.marshaller = marshaller;
- pageNames = new ArrayList<String>();
- }
-
- @Override
- public void export(OutputStream outputStream) throws IOException
- {
- Page.PageSet pages = new Page.PageSet();
- pages.setPages(new ArrayList<Page>(pageNames.size()));
- for (String pageName : pageNames)
- {
- try
- {
- Page page = dataStorage.getPage(Utils.join("::",
siteKey.getTypeName(), siteKey.getName(), pageName));
- pages.getPages().add(page);
- }
- catch (Exception e)
- {
- throw new IOException("Could not retrieve page name " + pageName +
" for site " + siteKey, e);
- }
- }
-
- marshaller.marshal(pages, outputStream);
- }
-
- @Override
- protected String getXmlFileName()
- {
- return FILE;
- }
-
- public void addPageName(String pageName)
- {
- pageNames.add(pageName);
- }
-
- public List<String> getPageNames()
- {
- return Collections.unmodifiableList(pageNames);
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageExportTask.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageExportTask.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageExportTask.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageExportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.exportimport;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.Utils;
+import org.gatein.management.api.binding.Marshaller;
+import org.gatein.management.api.operation.model.ExportTask;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageExportTask extends AbstractExportTask implements ExportTask
+{
+ public static final String FILE = "pages.xml";
+
+ private final DataStorage dataStorage;
+ private final Marshaller<Page.PageSet> marshaller;
+ private final List<String> pageNames;
+
+ public PageExportTask(SiteKey siteKey, DataStorage dataStorage,
Marshaller<Page.PageSet> marshaller)
+ {
+ super(siteKey);
+ this.dataStorage = dataStorage;
+ this.marshaller = marshaller;
+ pageNames = new ArrayList<String>();
+ }
+
+ @Override
+ public void export(OutputStream outputStream) throws IOException
+ {
+ Page.PageSet pages = new Page.PageSet();
+ pages.setPages(new ArrayList<Page>(pageNames.size()));
+ for (String pageName : pageNames)
+ {
+ try
+ {
+ Page page = dataStorage.getPage(Utils.join("::",
siteKey.getTypeName(), siteKey.getName(), pageName));
+ pages.getPages().add(page);
+ }
+ catch (Exception e)
+ {
+ throw new IOException("Could not retrieve page name " + pageName +
" for site " + siteKey, e);
+ }
+ }
+
+ marshaller.marshal(pages, outputStream);
+ }
+
+ @Override
+ protected String getXmlFileName()
+ {
+ return FILE;
+ }
+
+ public void addPageName(String pageName)
+ {
+ pageNames.add(pageName);
+ }
+
+ public List<String> getPageNames()
+ {
+ return Collections.unmodifiableList(pageNames);
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageImportTask.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageImportTask.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageImportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,203 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.exportimport;
-
-import org.exoplatform.commons.utils.LazyPageList;
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.Query;
-import org.exoplatform.portal.config.model.Page;
-import org.exoplatform.portal.mop.SiteKey;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PageImportTask extends AbstractImportTask<Page.PageSet>
-{
- private final DataStorage dataStorage;
- private Page.PageSet rollbackSaves;
- private Page.PageSet rollbackDeletes;
-
- public PageImportTask(Page.PageSet data, SiteKey siteKey, DataStorage dataStorage)
- {
- super(data, siteKey);
- this.dataStorage = dataStorage;
- }
-
- @Override
- public void importData(ImportStrategy strategy) throws Exception
- {
- if (data == null || data.getPages() == null || data.getPages().isEmpty()) return;
-
- Query<Page> query = new Query<Page>(siteKey.getTypeName(),
siteKey.getName(), Page.class);
- LazyPageList<Page> list = dataStorage.find(query);
- int size = list.getAvailable();
-
- Page.PageSet dst = null;
- switch (strategy)
- {
- case CONSERVE:
- if (size == 0)
- {
- dst = data; // No pages exist yet.
- rollbackDeletes = data;
- }
- else
- {
- dst = new Page.PageSet();
- dst.setPages(new ArrayList<Page>());
- List<Page> existingPages = list.getAll();
- rollbackDeletes = new Page.PageSet();
- rollbackDeletes.setPages(new ArrayList<Page>());
- for (Page src : data.getPages())
- {
- Page found = findPage(existingPages, src);
- if (found == null)
- {
- dst.getPages().add(src);
- rollbackDeletes.getPages().add(src);
- }
- }
- }
- break;
- case MERGE:
- if (size == 0) // No pages exist yet.
- {
- dst = data;
- rollbackDeletes = data;
- }
- else
- {
- dst = new Page.PageSet();
- dst.setPages(new ArrayList<Page>(data.getPages().size()));
- List<Page> existingPages = list.getAll();
- rollbackSaves = new Page.PageSet();
- rollbackSaves.setPages(new ArrayList<Page>(size));
- rollbackDeletes = new Page.PageSet();
- rollbackDeletes.setPages(new ArrayList<Page>());
- for (Page src : data.getPages())
- {
- dst.getPages().add(src);
-
- Page found = findPage(existingPages, src);
- if (found == null)
- {
- rollbackDeletes.getPages().add(src);
- }
- else
- {
- rollbackSaves.getPages().add(found);
- }
- }
- }
- break;
- case OVERWRITE:
- if (size == 0)
- {
- dst = data;
- rollbackDeletes = data;
- }
- else
- {
- List<Page> existingPages = list.getAll();
- rollbackSaves = new Page.PageSet();
- rollbackSaves.setPages(new ArrayList<Page>(size));
- rollbackDeletes = new Page.PageSet();
- rollbackDeletes.setPages(new ArrayList<Page>());
- for (Page page : existingPages)
- {
- dataStorage.remove(page);
- dataStorage.save();
- rollbackSaves.getPages().add(page);
- }
- for (Page src : data.getPages())
- {
- Page found = findPage(rollbackSaves.getPages(), src);
- if (found == null)
- {
- rollbackDeletes.getPages().add(src);
- }
- }
-
- dst = data;
- }
- break;
- }
-
- if (dst != null)
- {
- for (Page page : dst.getPages())
- {
- dataStorage.save(page);
- dataStorage.save();
- }
- }
- }
-
- @Override
- public void rollback() throws Exception
- {
- if (rollbackDeletes != null && !rollbackDeletes.getPages().isEmpty())
- {
- for (Page page : rollbackDeletes.getPages())
- {
- dataStorage.remove(page);
- dataStorage.save();
- }
- }
- if (rollbackSaves != null && !rollbackSaves.getPages().isEmpty())
- {
- for (Page page : rollbackSaves.getPages())
- {
- dataStorage.save(page);
- dataStorage.save();
- }
- }
- }
-
- Page.PageSet getRollbackSaves()
- {
- return rollbackSaves;
- }
-
- Page.PageSet getRollbackDeletes()
- {
- return rollbackDeletes;
- }
-
- private Page findPage(List<Page> pages, Page src)
- {
- Page found = null;
- for (Page page : pages)
- {
- if (src.getName().equals(page.getName()))
- {
- found = page;
- }
- }
- return found;
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageImportTask.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageImportTask.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageImportTask.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/PageImportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,203 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.exportimport;
+
+import org.exoplatform.commons.utils.LazyPageList;
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.Query;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.mop.SiteKey;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageImportTask extends AbstractImportTask<Page.PageSet>
+{
+ private final DataStorage dataStorage;
+ private Page.PageSet rollbackSaves;
+ private Page.PageSet rollbackDeletes;
+
+ public PageImportTask(Page.PageSet data, SiteKey siteKey, DataStorage dataStorage)
+ {
+ super(data, siteKey);
+ this.dataStorage = dataStorage;
+ }
+
+ @Override
+ public void importData(ImportStrategy strategy) throws Exception
+ {
+ if (data == null || data.getPages() == null || data.getPages().isEmpty()) return;
+
+ Query<Page> query = new Query<Page>(siteKey.getTypeName(),
siteKey.getName(), Page.class);
+ LazyPageList<Page> list = dataStorage.find(query);
+ int size = list.getAvailable();
+
+ Page.PageSet dst = null;
+ switch (strategy)
+ {
+ case CONSERVE:
+ if (size == 0)
+ {
+ dst = data; // No pages exist yet.
+ rollbackDeletes = data;
+ }
+ else
+ {
+ dst = new Page.PageSet();
+ dst.setPages(new ArrayList<Page>());
+ List<Page> existingPages = list.getAll();
+ rollbackDeletes = new Page.PageSet();
+ rollbackDeletes.setPages(new ArrayList<Page>());
+ for (Page src : data.getPages())
+ {
+ Page found = findPage(existingPages, src);
+ if (found == null)
+ {
+ dst.getPages().add(src);
+ rollbackDeletes.getPages().add(src);
+ }
+ }
+ }
+ break;
+ case MERGE:
+ if (size == 0) // No pages exist yet.
+ {
+ dst = data;
+ rollbackDeletes = data;
+ }
+ else
+ {
+ dst = new Page.PageSet();
+ dst.setPages(new ArrayList<Page>(data.getPages().size()));
+ List<Page> existingPages = list.getAll();
+ rollbackSaves = new Page.PageSet();
+ rollbackSaves.setPages(new ArrayList<Page>(size));
+ rollbackDeletes = new Page.PageSet();
+ rollbackDeletes.setPages(new ArrayList<Page>());
+ for (Page src : data.getPages())
+ {
+ dst.getPages().add(src);
+
+ Page found = findPage(existingPages, src);
+ if (found == null)
+ {
+ rollbackDeletes.getPages().add(src);
+ }
+ else
+ {
+ rollbackSaves.getPages().add(found);
+ }
+ }
+ }
+ break;
+ case OVERWRITE:
+ if (size == 0)
+ {
+ dst = data;
+ rollbackDeletes = data;
+ }
+ else
+ {
+ List<Page> existingPages = list.getAll();
+ rollbackSaves = new Page.PageSet();
+ rollbackSaves.setPages(new ArrayList<Page>(size));
+ rollbackDeletes = new Page.PageSet();
+ rollbackDeletes.setPages(new ArrayList<Page>());
+ for (Page page : existingPages)
+ {
+ dataStorage.remove(page);
+ dataStorage.save();
+ rollbackSaves.getPages().add(page);
+ }
+ for (Page src : data.getPages())
+ {
+ Page found = findPage(rollbackSaves.getPages(), src);
+ if (found == null)
+ {
+ rollbackDeletes.getPages().add(src);
+ }
+ }
+
+ dst = data;
+ }
+ break;
+ }
+
+ if (dst != null)
+ {
+ for (Page page : dst.getPages())
+ {
+ dataStorage.save(page);
+ dataStorage.save();
+ }
+ }
+ }
+
+ @Override
+ public void rollback() throws Exception
+ {
+ if (rollbackDeletes != null && !rollbackDeletes.getPages().isEmpty())
+ {
+ for (Page page : rollbackDeletes.getPages())
+ {
+ dataStorage.remove(page);
+ dataStorage.save();
+ }
+ }
+ if (rollbackSaves != null && !rollbackSaves.getPages().isEmpty())
+ {
+ for (Page page : rollbackSaves.getPages())
+ {
+ dataStorage.save(page);
+ dataStorage.save();
+ }
+ }
+ }
+
+ Page.PageSet getRollbackSaves()
+ {
+ return rollbackSaves;
+ }
+
+ Page.PageSet getRollbackDeletes()
+ {
+ return rollbackDeletes;
+ }
+
+ private Page findPage(List<Page> pages, Page src)
+ {
+ Page found = null;
+ for (Page page : pages)
+ {
+ if (src.getName().equals(page.getName()))
+ {
+ found = page;
+ }
+ }
+ return found;
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutExportTask.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutExportTask.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutExportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.exportimport;
-
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.pom.config.POMSession;
-import org.exoplatform.portal.pom.config.tasks.PortalConfigTask;
-import org.exoplatform.portal.pom.data.PortalData;
-import org.exoplatform.portal.pom.data.PortalKey;
-import org.gatein.management.api.binding.Marshaller;
-import org.gatein.management.api.operation.model.ExportTask;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class SiteLayoutExportTask extends AbstractExportTask implements ExportTask
-{
- public static final String FILE = "portal.xml";
-
- private final DataStorage dataStorage;
- private final Marshaller<PortalConfig> marshaller;
-
- public SiteLayoutExportTask(SiteKey siteKey, DataStorage dataStorage,
Marshaller<PortalConfig> marshaller)
- {
- super(siteKey);
- this.dataStorage = dataStorage;
- this.marshaller = marshaller;
- }
-
- @Override
- protected String getXmlFileName()
- {
- return FILE;
- }
-
- @Override
- public void export(OutputStream outputStream) throws IOException
- {
- PortalConfig portalConfig;
- try
- {
- portalConfig = dataStorage.getPortalConfig(siteKey.getTypeName(),
siteKey.getName());
- }
- catch (Exception e)
- {
- throw new IOException("Could not retrieve site " + siteKey, e);
- }
-
- marshaller.marshal(portalConfig, outputStream);
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutExportTask.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutExportTask.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutExportTask.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutExportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.exportimport;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.tasks.PortalConfigTask;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.exoplatform.portal.pom.data.PortalKey;
+import org.gatein.management.api.binding.Marshaller;
+import org.gatein.management.api.operation.model.ExportTask;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SiteLayoutExportTask extends AbstractExportTask implements ExportTask
+{
+ public static final String FILE = "portal.xml";
+
+ private final DataStorage dataStorage;
+ private final Marshaller<PortalConfig> marshaller;
+
+ public SiteLayoutExportTask(SiteKey siteKey, DataStorage dataStorage,
Marshaller<PortalConfig> marshaller)
+ {
+ super(siteKey);
+ this.dataStorage = dataStorage;
+ this.marshaller = marshaller;
+ }
+
+ @Override
+ protected String getXmlFileName()
+ {
+ return FILE;
+ }
+
+ @Override
+ public void export(OutputStream outputStream) throws IOException
+ {
+ PortalConfig portalConfig;
+ try
+ {
+ portalConfig = dataStorage.getPortalConfig(siteKey.getTypeName(),
siteKey.getName());
+ }
+ catch (Exception e)
+ {
+ throw new IOException("Could not retrieve site " + siteKey, e);
+ }
+
+ marshaller.marshal(portalConfig, outputStream);
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutImportTask.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutImportTask.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutImportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,106 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.exportimport;
-
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.pom.data.ModelDataStorage;
-import org.exoplatform.portal.pom.data.PortalData;
-import org.exoplatform.portal.pom.data.PortalKey;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class SiteLayoutImportTask extends AbstractImportTask<PortalConfig>
-{
- private final DataStorage dataStorage;
- private PortalConfig rollbackDelete;
- private PortalConfig rollbackSave;
-
- public SiteLayoutImportTask(PortalConfig data, SiteKey siteKey, DataStorage
dataStorage)
- {
- super(data, siteKey);
- this.dataStorage = dataStorage;
- }
-
- @Override
- public void importData(ImportStrategy importStrategy) throws Exception
- {
- PortalConfig dst = dataStorage.getPortalConfig(siteKey.getTypeName(),
siteKey.getName());
-
- switch (importStrategy)
- {
- // Really doesn't make sense to "merge" site layout data. Really
two modes, conserve (keep) and overwrite.
- case CONSERVE:
- if (dst == null)
- {
- dst = data;
- rollbackDelete = data;
- }
- else
- {
- dst = null;
- }
- break;
- case MERGE:
- case OVERWRITE:
- if (dst == null)
- {
- rollbackDelete = data;
- }
- else
- {
- rollbackSave = dst;
- }
- dst = data;
- break;
- }
-
- if (dst != null)
- {
- if (rollbackDelete == null)
- {
- dataStorage.save(dst);
- }
- else
- {
- dataStorage.create(dst);
- }
- }
- }
-
- @Override
- public void rollback() throws Exception
- {
- if (rollbackDelete != null)
- {
- dataStorage.remove(rollbackDelete);
- }
- else if (rollbackSave != null)
- {
- dataStorage.save(rollbackSave);
- }
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutImportTask.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutImportTask.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutImportTask.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutImportTask.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.exportimport;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.pom.data.ModelDataStorage;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.exoplatform.portal.pom.data.PortalKey;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SiteLayoutImportTask extends AbstractImportTask<PortalConfig>
+{
+ private final DataStorage dataStorage;
+ private PortalConfig rollbackDelete;
+ private PortalConfig rollbackSave;
+
+ public SiteLayoutImportTask(PortalConfig data, SiteKey siteKey, DataStorage
dataStorage)
+ {
+ super(data, siteKey);
+ this.dataStorage = dataStorage;
+ }
+
+ @Override
+ public void importData(ImportStrategy importStrategy) throws Exception
+ {
+ PortalConfig dst = dataStorage.getPortalConfig(siteKey.getTypeName(),
siteKey.getName());
+
+ switch (importStrategy)
+ {
+ // Really doesn't make sense to "merge" site layout data. Really
two modes, conserve (keep) and overwrite.
+ case CONSERVE:
+ if (dst == null)
+ {
+ dst = data;
+ rollbackDelete = data;
+ }
+ else
+ {
+ dst = null;
+ }
+ break;
+ case MERGE:
+ case OVERWRITE:
+ if (dst == null)
+ {
+ rollbackDelete = data;
+ }
+ else
+ {
+ rollbackSave = dst;
+ }
+ dst = data;
+ break;
+ }
+
+ if (dst != null)
+ {
+ if (rollbackDelete == null)
+ {
+ dataStorage.save(dst);
+ }
+ else
+ {
+ dataStorage.create(dst);
+ }
+ }
+ }
+
+ @Override
+ public void rollback() throws Exception
+ {
+ if (rollbackDelete != null)
+ {
+ dataStorage.remove(rollbackDelete);
+ }
+ else if (rollbackSave != null)
+ {
+ dataStorage.save(rollbackSave);
+ }
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/AbstractMopOperationHandler.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/AbstractMopOperationHandler.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/AbstractMopOperationHandler.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,88 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.operations;
-
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.SiteType;
-import org.exoplatform.portal.pom.config.POMSession;
-import org.exoplatform.portal.pom.config.POMSessionManager;
-import org.gatein.management.api.PathAddress;
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.OperationHandler;
-import org.gatein.management.api.operation.ResultHandler;
-import org.gatein.mop.api.workspace.ObjectType;
-import org.gatein.mop.api.workspace.Site;
-import org.gatein.mop.api.workspace.Workspace;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public abstract class AbstractMopOperationHandler implements OperationHandler
-{
- @Override
- public final void execute(OperationContext operationContext, ResultHandler
resultHandler) throws ResourceNotFoundException, OperationException
- {
- String operationName = operationContext.getOperationName();
- PathAddress address = operationContext.getAddress();
-
- String siteType = address.resolvePathTemplate("site-type");
- if (siteType == null) throw new OperationException(operationName, "Site type
was not specified.");
-
- ObjectType<Site> objectType =
Utils.getObjectType(Utils.getSiteType(siteType));
- if (objectType == null)
- {
- throw new ResourceNotFoundException("No site type found for " +
siteType);
- }
-
- POMSessionManager mgr =
operationContext.getRuntimeContext().getRuntimeComponent(POMSessionManager.class);
- POMSession session = mgr.getSession();
- if (session == null) throw new OperationException(operationName, "MOP session
was null");
-
- Workspace workspace = session.getWorkspace();
- if (workspace == null) throw new OperationException(operationName, "MOP
workspace was null");
-
- execute(operationContext, resultHandler, workspace, objectType);
- }
-
- protected abstract void execute(OperationContext operationContext, ResultHandler
resultHandler,
- Workspace workspace, ObjectType<Site> siteType)
throws ResourceNotFoundException, OperationException;
-
-
- protected SiteType getSiteType(ObjectType<? extends Site> objectType)
- {
- return Utils.getSiteType(objectType);
- }
-
- protected SiteKey getSiteKey(ObjectType<? extends Site> objectType, String
name)
- {
- return Utils.siteKey(Utils.getSiteType(objectType), name);
- }
-
- protected SiteKey getSiteKey(Site site)
- {
- return getSiteKey(site.getObjectType(), site.getName());
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/AbstractMopOperationHandler.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/AbstractMopOperationHandler.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/AbstractMopOperationHandler.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/AbstractMopOperationHandler.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.operations;
+
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.SiteType;
+import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.POMSessionManager;
+import org.gatein.management.api.PathAddress;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.OperationHandler;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.mop.api.workspace.ObjectType;
+import org.gatein.mop.api.workspace.Site;
+import org.gatein.mop.api.workspace.Workspace;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class AbstractMopOperationHandler implements OperationHandler
+{
+ @Override
+ public final void execute(OperationContext operationContext, ResultHandler
resultHandler) throws ResourceNotFoundException, OperationException
+ {
+ String operationName = operationContext.getOperationName();
+ PathAddress address = operationContext.getAddress();
+
+ String siteType = address.resolvePathTemplate("site-type");
+ if (siteType == null) throw new OperationException(operationName, "Site type
was not specified.");
+
+ ObjectType<Site> objectType =
Utils.getObjectType(Utils.getSiteType(siteType));
+ if (objectType == null)
+ {
+ throw new ResourceNotFoundException("No site type found for " +
siteType);
+ }
+
+ POMSessionManager mgr =
operationContext.getRuntimeContext().getRuntimeComponent(POMSessionManager.class);
+ POMSession session = mgr.getSession();
+ if (session == null) throw new OperationException(operationName, "MOP session
was null");
+
+ Workspace workspace = session.getWorkspace();
+ if (workspace == null) throw new OperationException(operationName, "MOP
workspace was null");
+
+ execute(operationContext, resultHandler, workspace, objectType);
+ }
+
+ protected abstract void execute(OperationContext operationContext, ResultHandler
resultHandler,
+ Workspace workspace, ObjectType<Site> siteType)
throws ResourceNotFoundException, OperationException;
+
+
+ protected SiteType getSiteType(ObjectType<? extends Site> objectType)
+ {
+ return Utils.getSiteType(objectType);
+ }
+
+ protected SiteKey getSiteKey(ObjectType<? extends Site> objectType, String
name)
+ {
+ return Utils.siteKey(Utils.getSiteType(objectType), name);
+ }
+
+ protected SiteKey getSiteKey(Site site)
+ {
+ return getSiteKey(site.getObjectType(), site.getName());
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopImportResource.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopImportResource.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopImportResource.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,343 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.operations;
-
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.model.Page;
-import org.exoplatform.portal.config.model.PageNavigation;
-import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.description.DescriptionService;
-import org.exoplatform.portal.mop.management.exportimport.ImportStrategy;
-import org.exoplatform.portal.mop.management.exportimport.NavigationExportTask;
-import org.exoplatform.portal.mop.management.exportimport.NavigationImportTask;
-import org.exoplatform.portal.mop.management.exportimport.PageExportTask;
-import org.exoplatform.portal.mop.management.exportimport.PageImportTask;
-import org.exoplatform.portal.mop.management.exportimport.SiteLayoutExportTask;
-import org.exoplatform.portal.mop.management.exportimport.SiteLayoutImportTask;
-import org.exoplatform.portal.mop.navigation.NavigationService;
-import org.exoplatform.portal.pom.config.POMSession;
-import org.exoplatform.portal.pom.config.POMSessionManager;
-import org.gatein.common.logging.Logger;
-import org.gatein.common.logging.LoggerFactory;
-import org.gatein.management.api.ContentType;
-import org.gatein.management.api.binding.Marshaller;
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationAttachment;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.OperationHandler;
-import org.gatein.management.api.operation.ResultHandler;
-import org.gatein.management.api.operation.model.NoResultModel;
-import org.gatein.mop.api.workspace.Workspace;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class MopImportResource implements OperationHandler
-{
- private static final Logger log = LoggerFactory.getLogger(MopImportResource.class);
-
- //TODO: Would like to see the step operations be handled by mgmt core.
-
- //TODO: Clean this up when we have time
- @Override
- public void execute(final OperationContext operationContext, ResultHandler
resultHandler) throws ResourceNotFoundException, OperationException
- {
- final String operationName = operationContext.getOperationName();
-
- OperationAttachment attachment = operationContext.getAttachment(true);
- if (attachment == null) throw new
OperationException(operationContext.getOperationName(), "No attachment available for
MOP import.");
-
- InputStream inputStream = attachment.getStream();
- if (inputStream == null) throw new
OperationException(operationContext.getOperationName(), "No data stream available for
import.");
-
- POMSessionManager mgr =
operationContext.getRuntimeContext().getRuntimeComponent(POMSessionManager.class);
- POMSession session = mgr.getSession();
- if (session == null) throw new OperationException(operationName, "MOP session
was null");
-
- Workspace workspace = session.getWorkspace();
- if (workspace == null) throw new OperationException(operationName, "MOP
workspace was null");
-
- DataStorage dataStorage =
operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
- if (dataStorage == null) throw new OperationException(operationName,
"DataStorage was null");
-
- NavigationService navigationService =
operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
- if (navigationService == null) throw new OperationException(operationName,
"Navigation service was null");
-
- DescriptionService descriptionService =
operationContext.getRuntimeContext().getRuntimeComponent(DescriptionService.class);
- if (descriptionService == null) throw new OperationException(operationName,
"Description service was null");
-
- String strategyAttribute =
operationContext.getAttributes().getValue("import-strategy");
- ImportStrategy strategy = ImportStrategy.MERGE;
- if (strategyAttribute != null)
- {
- strategy = ImportStrategy.forName(strategyAttribute);
- if (strategy == null) throw new OperationException(operationName, "Unknown
import strategy " + strategyAttribute);
- }
-
- Map<SiteKey, MopImport> importMap = new HashMap<SiteKey, MopImport>();
- final NonCloseableZipInputStream zis = new
NonCloseableZipInputStream(inputStream);
- ZipEntry entry;
- try
- {
- log.info("Preparing data for import.");
- while ( (entry = zis.getNextEntry()) != null)
- {
- // Skip directories
- if (entry.isDirectory()) continue;
-
- // Parse zip entry
- String[] parts = parseEntry(entry);
- SiteKey siteKey = Utils.siteKey(parts[0], parts[1]);
- String file = parts[2];
-
- MopImport mopImport = importMap.get(siteKey);
- if (mopImport == null)
- {
- mopImport = new MopImport();
- importMap.put(siteKey, mopImport);
- }
-
- if (file.equals(SiteLayoutExportTask.FILE))
- {
- // Unmarshal site layout data
- Marshaller<PortalConfig> marshaller =
operationContext.getBindingProvider().getMarshaller(PortalConfig.class, ContentType.XML);
- PortalConfig portalConfig = marshaller.unmarshal(zis);
- portalConfig.setType(siteKey.getTypeName());
- if (!portalConfig.getName().equals(siteKey.getName()))
- {
- throw new OperationException(operationName, "Name of site does not
match that of the zip entry site name.");
- }
-
- // Add import task to run later
- mopImport.siteTask = new SiteLayoutImportTask(portalConfig, siteKey,
dataStorage);
- }
- else if (file.equals(PageExportTask.FILE))
- {
- // Unmarshal page data
- Marshaller<Page.PageSet> marshaller =
operationContext.getBindingProvider().getMarshaller(Page.PageSet.class, ContentType.XML);
- Page.PageSet pages = marshaller.unmarshal(zis);
- for (Page page : pages.getPages())
- {
- page.setOwnerType(siteKey.getTypeName());
- page.setOwnerId(siteKey.getName());
- }
-
- // Add import task to run later.
- mopImport.pageTask = new PageImportTask(pages, siteKey, dataStorage);
- }
- else if (file.equals(NavigationExportTask.FILE))
- {
- // Unmarshal navigation data
- Marshaller<PageNavigation> marshaller =
operationContext.getBindingProvider().getMarshaller(PageNavigation.class,
ContentType.XML);
- PageNavigation navigation = marshaller.unmarshal(zis);
- navigation.setOwnerType(siteKey.getTypeName());
- navigation.setOwnerId(siteKey.getName());
-
- // Add import task to run later
- mopImport.navigationTask = new NavigationImportTask(navigation, siteKey,
navigationService, descriptionService, dataStorage);
- }
- }
-
- resultHandler.completed(NoResultModel.INSTANCE);
- }
- catch (Throwable t)
- {
- throw new OperationException(operationContext.getOperationName(),
"Exception reading data for import.", t);
- }
- finally
- {
- try
- {
- zis.reallyClose();
- }
- catch (IOException e)
- {
- log.warn("Exception closing underlying data stream from import.");
- }
- }
-
- // Perform import
- Map<SiteKey, MopImport> completedImportMap = new HashMap<SiteKey,
MopImport>();
- try
- {
- log.info("Performing import using strategy '" + strategy.getName()
+ "'");
- for (Map.Entry<SiteKey, MopImport> mopImportEntry : importMap.entrySet())
- {
- SiteKey siteKey = mopImportEntry.getKey();
- MopImport mopImport = mopImportEntry.getValue();
- MopImport completed = new MopImport();
-
- if (completedImportMap.containsKey(siteKey))
- {
- throw new IllegalStateException("Multiple site imports for same
operation.");
- }
- completedImportMap.put(siteKey, completed);
-
- log.debug("Importing data for site " + siteKey);
-
- // Site layout import
- if (mopImport.siteTask != null)
- {
- log.debug("Importing site layout data.");
- mopImport.siteTask.importData(strategy);
- completed.siteTask = mopImport.siteTask;
- }
-
- // Page import
- if (mopImport.pageTask != null)
- {
- log.debug("Importing page data.");
- mopImport.pageTask.importData(strategy);
- completed.pageTask = mopImport.pageTask;
- }
-
- // Navigation import
- if (mopImport.navigationTask != null)
- {
- log.debug("Importing navigation data.");
- mopImport.navigationTask.importData(strategy);
- completed.navigationTask = mopImport.navigationTask;
- }
- }
- log.info("Import successful !");
- }
- catch (Throwable t)
- {
- boolean rollbackSuccess = true;
- log.error("Exception importing data.", t);
- log.info("Attempting to rollback data modified by import.");
- for (Map.Entry<SiteKey, MopImport> mopImportEntry :
completedImportMap.entrySet())
- {
- SiteKey siteKey = mopImportEntry.getKey();
- MopImport mopImport = mopImportEntry.getValue();
-
- log.debug("Rolling back imported data for site " + siteKey);
- if (mopImport.navigationTask != null)
- {
- log.debug("Rolling back navigation modified during import...");
- try
- {
- mopImport.navigationTask.rollback();
- }
- catch (Throwable t1) // Continue rolling back even though there are
exceptions.
- {
- rollbackSuccess = false;
- log.error("Error rolling back navigation data for site " +
siteKey, t1);
- }
- }
- if (mopImport.pageTask != null)
- {
- log.debug("Rolling back pages modified during import...");
- try
- {
- mopImport.pageTask.rollback();
- }
- catch (Throwable t1) // Continue rolling back even though there are
exceptions.
- {
- rollbackSuccess = false;
- log.error("Error rolling back page data for site " + siteKey,
t1);
- }
- }
- if (mopImport.siteTask != null)
- {
- log.debug("Rolling back site layout modified during
import...");
- try
- {
- mopImport.siteTask.rollback();
- }
- catch (Throwable t1) // Continue rolling back even though there are
exceptions.
- {
- rollbackSuccess = false;
- log.error("Error rolling back site layout for site " +
siteKey, t1);
- }
- }
- }
-
- String message = (rollbackSuccess) ?
- "Error during import. Tasks successfully rolled back. Portal should be
back to consistent state." :
- "Error during import. Errors in rollback as well. Portal may be in an
inconsistent state.";
-
- throw new OperationException(operationName, message, t);
- }
- finally
- {
- importMap.clear();
- completedImportMap.clear();
- }
- }
-
- private static String[] parseEntry(ZipEntry entry) throws IOException
- {
- String name = entry.getName();
- if (name.endsWith(SiteLayoutExportTask.FILE) || name.endsWith(PageExportTask.FILE)
|| name.endsWith(NavigationExportTask.FILE))
- {
- String[] parts = new String[3];
- parts[0] = name.substring(0, name.indexOf("/"));
- parts[1] = name.substring(parts[0].length() + 1,
name.lastIndexOf("/"));
- parts[2] = name.substring(name.lastIndexOf("/") + 1);
- return parts;
- }
- else
- {
- throw new IOException("Unknown entry " + name + " in zip
file.");
- }
- }
-
- // Bug in SUN's JDK XMLStreamReader implementation closes the underlying stream
when
- // it finishes reading an XML document. This is no good when we are using a
ZipInputStream.
- // See
http://bugs.sun.com/view_bug.do?bug_id=6539065 for more information.
- private static class NonCloseableZipInputStream extends ZipInputStream
- {
- private NonCloseableZipInputStream(InputStream inputStream)
- {
- super(inputStream);
- }
-
- @Override
- public void close() throws IOException
- {
- }
-
- private void reallyClose() throws IOException
- {
- super.close();
- }
- }
-
- private static class MopImport
- {
- private SiteLayoutImportTask siteTask;
- private PageImportTask pageTask;
- private NavigationImportTask navigationTask;
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopImportResource.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopImportResource.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopImportResource.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopImportResource.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,343 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.operations;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.description.DescriptionService;
+import org.exoplatform.portal.mop.management.exportimport.ImportStrategy;
+import org.exoplatform.portal.mop.management.exportimport.NavigationExportTask;
+import org.exoplatform.portal.mop.management.exportimport.NavigationImportTask;
+import org.exoplatform.portal.mop.management.exportimport.PageExportTask;
+import org.exoplatform.portal.mop.management.exportimport.PageImportTask;
+import org.exoplatform.portal.mop.management.exportimport.SiteLayoutExportTask;
+import org.exoplatform.portal.mop.management.exportimport.SiteLayoutImportTask;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.POMSessionManager;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+import org.gatein.management.api.ContentType;
+import org.gatein.management.api.binding.Marshaller;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationAttachment;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.OperationHandler;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.management.api.operation.model.NoResultModel;
+import org.gatein.mop.api.workspace.Workspace;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class MopImportResource implements OperationHandler
+{
+ private static final Logger log = LoggerFactory.getLogger(MopImportResource.class);
+
+ //TODO: Would like to see the step operations be handled by mgmt core.
+
+ //TODO: Clean this up when we have time
+ @Override
+ public void execute(final OperationContext operationContext, ResultHandler
resultHandler) throws ResourceNotFoundException, OperationException
+ {
+ final String operationName = operationContext.getOperationName();
+
+ OperationAttachment attachment = operationContext.getAttachment(true);
+ if (attachment == null) throw new
OperationException(operationContext.getOperationName(), "No attachment available for
MOP import.");
+
+ InputStream inputStream = attachment.getStream();
+ if (inputStream == null) throw new
OperationException(operationContext.getOperationName(), "No data stream available for
import.");
+
+ POMSessionManager mgr =
operationContext.getRuntimeContext().getRuntimeComponent(POMSessionManager.class);
+ POMSession session = mgr.getSession();
+ if (session == null) throw new OperationException(operationName, "MOP session
was null");
+
+ Workspace workspace = session.getWorkspace();
+ if (workspace == null) throw new OperationException(operationName, "MOP
workspace was null");
+
+ DataStorage dataStorage =
operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
+ if (dataStorage == null) throw new OperationException(operationName,
"DataStorage was null");
+
+ NavigationService navigationService =
operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
+ if (navigationService == null) throw new OperationException(operationName,
"Navigation service was null");
+
+ DescriptionService descriptionService =
operationContext.getRuntimeContext().getRuntimeComponent(DescriptionService.class);
+ if (descriptionService == null) throw new OperationException(operationName,
"Description service was null");
+
+ String strategyAttribute =
operationContext.getAttributes().getValue("import-strategy");
+ ImportStrategy strategy = ImportStrategy.MERGE;
+ if (strategyAttribute != null)
+ {
+ strategy = ImportStrategy.forName(strategyAttribute);
+ if (strategy == null) throw new OperationException(operationName, "Unknown
import strategy " + strategyAttribute);
+ }
+
+ Map<SiteKey, MopImport> importMap = new HashMap<SiteKey, MopImport>();
+ final NonCloseableZipInputStream zis = new
NonCloseableZipInputStream(inputStream);
+ ZipEntry entry;
+ try
+ {
+ log.info("Preparing data for import.");
+ while ( (entry = zis.getNextEntry()) != null)
+ {
+ // Skip directories
+ if (entry.isDirectory()) continue;
+
+ // Parse zip entry
+ String[] parts = parseEntry(entry);
+ SiteKey siteKey = Utils.siteKey(parts[0], parts[1]);
+ String file = parts[2];
+
+ MopImport mopImport = importMap.get(siteKey);
+ if (mopImport == null)
+ {
+ mopImport = new MopImport();
+ importMap.put(siteKey, mopImport);
+ }
+
+ if (file.equals(SiteLayoutExportTask.FILE))
+ {
+ // Unmarshal site layout data
+ Marshaller<PortalConfig> marshaller =
operationContext.getBindingProvider().getMarshaller(PortalConfig.class, ContentType.XML);
+ PortalConfig portalConfig = marshaller.unmarshal(zis);
+ portalConfig.setType(siteKey.getTypeName());
+ if (!portalConfig.getName().equals(siteKey.getName()))
+ {
+ throw new OperationException(operationName, "Name of site does not
match that of the zip entry site name.");
+ }
+
+ // Add import task to run later
+ mopImport.siteTask = new SiteLayoutImportTask(portalConfig, siteKey,
dataStorage);
+ }
+ else if (file.equals(PageExportTask.FILE))
+ {
+ // Unmarshal page data
+ Marshaller<Page.PageSet> marshaller =
operationContext.getBindingProvider().getMarshaller(Page.PageSet.class, ContentType.XML);
+ Page.PageSet pages = marshaller.unmarshal(zis);
+ for (Page page : pages.getPages())
+ {
+ page.setOwnerType(siteKey.getTypeName());
+ page.setOwnerId(siteKey.getName());
+ }
+
+ // Add import task to run later.
+ mopImport.pageTask = new PageImportTask(pages, siteKey, dataStorage);
+ }
+ else if (file.equals(NavigationExportTask.FILE))
+ {
+ // Unmarshal navigation data
+ Marshaller<PageNavigation> marshaller =
operationContext.getBindingProvider().getMarshaller(PageNavigation.class,
ContentType.XML);
+ PageNavigation navigation = marshaller.unmarshal(zis);
+ navigation.setOwnerType(siteKey.getTypeName());
+ navigation.setOwnerId(siteKey.getName());
+
+ // Add import task to run later
+ mopImport.navigationTask = new NavigationImportTask(navigation, siteKey,
navigationService, descriptionService, dataStorage);
+ }
+ }
+
+ resultHandler.completed(NoResultModel.INSTANCE);
+ }
+ catch (Throwable t)
+ {
+ throw new OperationException(operationContext.getOperationName(),
"Exception reading data for import.", t);
+ }
+ finally
+ {
+ try
+ {
+ zis.reallyClose();
+ }
+ catch (IOException e)
+ {
+ log.warn("Exception closing underlying data stream from import.");
+ }
+ }
+
+ // Perform import
+ Map<SiteKey, MopImport> completedImportMap = new HashMap<SiteKey,
MopImport>();
+ try
+ {
+ log.info("Performing import using strategy '" + strategy.getName()
+ "'");
+ for (Map.Entry<SiteKey, MopImport> mopImportEntry : importMap.entrySet())
+ {
+ SiteKey siteKey = mopImportEntry.getKey();
+ MopImport mopImport = mopImportEntry.getValue();
+ MopImport completed = new MopImport();
+
+ if (completedImportMap.containsKey(siteKey))
+ {
+ throw new IllegalStateException("Multiple site imports for same
operation.");
+ }
+ completedImportMap.put(siteKey, completed);
+
+ log.debug("Importing data for site " + siteKey);
+
+ // Site layout import
+ if (mopImport.siteTask != null)
+ {
+ log.debug("Importing site layout data.");
+ mopImport.siteTask.importData(strategy);
+ completed.siteTask = mopImport.siteTask;
+ }
+
+ // Page import
+ if (mopImport.pageTask != null)
+ {
+ log.debug("Importing page data.");
+ mopImport.pageTask.importData(strategy);
+ completed.pageTask = mopImport.pageTask;
+ }
+
+ // Navigation import
+ if (mopImport.navigationTask != null)
+ {
+ log.debug("Importing navigation data.");
+ mopImport.navigationTask.importData(strategy);
+ completed.navigationTask = mopImport.navigationTask;
+ }
+ }
+ log.info("Import successful !");
+ }
+ catch (Throwable t)
+ {
+ boolean rollbackSuccess = true;
+ log.error("Exception importing data.", t);
+ log.info("Attempting to rollback data modified by import.");
+ for (Map.Entry<SiteKey, MopImport> mopImportEntry :
completedImportMap.entrySet())
+ {
+ SiteKey siteKey = mopImportEntry.getKey();
+ MopImport mopImport = mopImportEntry.getValue();
+
+ log.debug("Rolling back imported data for site " + siteKey);
+ if (mopImport.navigationTask != null)
+ {
+ log.debug("Rolling back navigation modified during import...");
+ try
+ {
+ mopImport.navigationTask.rollback();
+ }
+ catch (Throwable t1) // Continue rolling back even though there are
exceptions.
+ {
+ rollbackSuccess = false;
+ log.error("Error rolling back navigation data for site " +
siteKey, t1);
+ }
+ }
+ if (mopImport.pageTask != null)
+ {
+ log.debug("Rolling back pages modified during import...");
+ try
+ {
+ mopImport.pageTask.rollback();
+ }
+ catch (Throwable t1) // Continue rolling back even though there are
exceptions.
+ {
+ rollbackSuccess = false;
+ log.error("Error rolling back page data for site " + siteKey,
t1);
+ }
+ }
+ if (mopImport.siteTask != null)
+ {
+ log.debug("Rolling back site layout modified during
import...");
+ try
+ {
+ mopImport.siteTask.rollback();
+ }
+ catch (Throwable t1) // Continue rolling back even though there are
exceptions.
+ {
+ rollbackSuccess = false;
+ log.error("Error rolling back site layout for site " +
siteKey, t1);
+ }
+ }
+ }
+
+ String message = (rollbackSuccess) ?
+ "Error during import. Tasks successfully rolled back. Portal should be
back to consistent state." :
+ "Error during import. Errors in rollback as well. Portal may be in an
inconsistent state.";
+
+ throw new OperationException(operationName, message, t);
+ }
+ finally
+ {
+ importMap.clear();
+ completedImportMap.clear();
+ }
+ }
+
+ private static String[] parseEntry(ZipEntry entry) throws IOException
+ {
+ String name = entry.getName();
+ if (name.endsWith(SiteLayoutExportTask.FILE) || name.endsWith(PageExportTask.FILE)
|| name.endsWith(NavigationExportTask.FILE))
+ {
+ String[] parts = new String[3];
+ parts[0] = name.substring(0, name.indexOf("/"));
+ parts[1] = name.substring(parts[0].length() + 1,
name.lastIndexOf("/"));
+ parts[2] = name.substring(name.lastIndexOf("/") + 1);
+ return parts;
+ }
+ else
+ {
+ throw new IOException("Unknown entry " + name + " in zip
file.");
+ }
+ }
+
+ // Bug in SUN's JDK XMLStreamReader implementation closes the underlying stream
when
+ // it finishes reading an XML document. This is no good when we are using a
ZipInputStream.
+ // See
http://bugs.sun.com/view_bug.do?bug_id=6539065 for more information.
+ private static class NonCloseableZipInputStream extends ZipInputStream
+ {
+ private NonCloseableZipInputStream(InputStream inputStream)
+ {
+ super(inputStream);
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ }
+
+ private void reallyClose() throws IOException
+ {
+ super.close();
+ }
+ }
+
+ private static class MopImport
+ {
+ private SiteLayoutImportTask siteTask;
+ private PageImportTask pageTask;
+ private NavigationImportTask navigationTask;
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopReadResource.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopReadResource.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopReadResource.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.operations;
-
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.operation.model.ReadResourceModel;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.OperationHandler;
-import org.gatein.management.api.operation.ResultHandler;
-
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class MopReadResource implements OperationHandler
-{
- @Override
- public void execute(OperationContext operationContext, ResultHandler resultHandler)
throws OperationException
- {
- Set<String> children = new LinkedHashSet<String>(3);
- children.add("portalsites");
- children.add("groupsites");
- children.add("usersites");
-
- resultHandler.completed(new ReadResourceModel("Available site types.",
children));
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopReadResource.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopReadResource.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopReadResource.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopReadResource.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.operations;
+
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.operation.model.ReadResourceModel;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.OperationHandler;
+import org.gatein.management.api.operation.ResultHandler;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class MopReadResource implements OperationHandler
+{
+ @Override
+ public void execute(OperationContext operationContext, ResultHandler resultHandler)
throws OperationException
+ {
+ Set<String> children = new LinkedHashSet<String>(3);
+ children.add("portalsites");
+ children.add("groupsites");
+ children.add("usersites");
+
+ resultHandler.completed(new ReadResourceModel("Available site types.",
children));
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/Utils.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/Utils.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/Utils.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,111 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.operations;
-
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.SiteType;
-import org.gatein.mop.api.workspace.ObjectType;
-import org.gatein.mop.api.workspace.Site;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class Utils
-{
-
- private Utils()
- {
- }
-
- public static ObjectType<Site> getObjectType(SiteType siteType)
- {
- switch (siteType)
- {
- case PORTAL:
- return ObjectType.PORTAL_SITE;
- case GROUP:
- return ObjectType.GROUP_SITE;
- case USER:
- return ObjectType.USER_SITE;
- default:
- return null;
- }
- }
-
- public static SiteType getSiteType(ObjectType<? extends Site> objectType)
- {
- if (ObjectType.PORTAL_SITE == objectType)
- {
- return SiteType.PORTAL;
- }
- else if (ObjectType.GROUP_SITE == objectType)
- {
- return SiteType.GROUP;
- }
- else if (ObjectType.USER_SITE == objectType)
- {
- return SiteType.USER;
- }
- else
- {
- return null;
- }
- }
-
- public static SiteType getSiteType(String siteType)
- {
- if (siteType == null) return null;
-
- return SiteType.valueOf(siteType.toUpperCase());
- }
-
-
- public static SiteKey siteKey(String siteType, String siteName)
- {
- SiteType st = getSiteType(siteType);
- return siteKey(st, siteName);
- }
-
- public static SiteKey siteKey(SiteType siteType, String siteName)
- {
- switch (siteType)
- {
- case PORTAL:
- return SiteKey.portal(siteName);
- case GROUP:
- if (siteName.charAt(0) != '/') siteName = "/" + siteName;
- return SiteKey.group(siteName);
- case USER:
- return SiteKey.user(siteName);
- default:
- return null;
-
- }
- }
-
- public static SiteKey siteKey(Site site)
- {
- return siteKey(getSiteType(site.getObjectType()), site.getName());
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/Utils.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/Utils.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/Utils.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/Utils.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.operations;
+
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.SiteType;
+import org.gatein.mop.api.workspace.ObjectType;
+import org.gatein.mop.api.workspace.Site;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class Utils
+{
+
+ private Utils()
+ {
+ }
+
+ public static ObjectType<Site> getObjectType(SiteType siteType)
+ {
+ switch (siteType)
+ {
+ case PORTAL:
+ return ObjectType.PORTAL_SITE;
+ case GROUP:
+ return ObjectType.GROUP_SITE;
+ case USER:
+ return ObjectType.USER_SITE;
+ default:
+ return null;
+ }
+ }
+
+ public static SiteType getSiteType(ObjectType<? extends Site> objectType)
+ {
+ if (ObjectType.PORTAL_SITE == objectType)
+ {
+ return SiteType.PORTAL;
+ }
+ else if (ObjectType.GROUP_SITE == objectType)
+ {
+ return SiteType.GROUP;
+ }
+ else if (ObjectType.USER_SITE == objectType)
+ {
+ return SiteType.USER;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public static SiteType getSiteType(String siteType)
+ {
+ if (siteType == null) return null;
+
+ return SiteType.valueOf(siteType.toUpperCase());
+ }
+
+
+ public static SiteKey siteKey(String siteType, String siteName)
+ {
+ SiteType st = getSiteType(siteType);
+ return siteKey(st, siteName);
+ }
+
+ public static SiteKey siteKey(SiteType siteType, String siteName)
+ {
+ switch (siteType)
+ {
+ case PORTAL:
+ return SiteKey.portal(siteName);
+ case GROUP:
+ if (siteName.charAt(0) != '/') siteName = "/" + siteName;
+ return SiteKey.group(siteName);
+ case USER:
+ return SiteKey.user(siteName);
+ default:
+ return null;
+
+ }
+ }
+
+ public static SiteKey siteKey(Site site)
+ {
+ return siteKey(getSiteType(site.getObjectType()), site.getName());
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/AbstractNavigationOperationHandler.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/AbstractNavigationOperationHandler.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/AbstractNavigationOperationHandler.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.operations.navigation;
-
-import
org.exoplatform.portal.mop.management.operations.site.AbstractSiteOperationHandler;
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.ResultHandler;
-import org.gatein.mop.api.workspace.Navigation;
-import org.gatein.mop.api.workspace.Site;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public abstract class AbstractNavigationOperationHandler extends
AbstractSiteOperationHandler
-{
- @Override
- protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Site site) throws ResourceNotFoundException, OperationException
- {
- Navigation navigation = site.getRootNavigation().getChild("default");
- if (navigation == null) throw new ResourceNotFoundException("Navigation does
not exist for site " + getSiteKey(site));
-
- execute(operationContext, resultHandler, navigation);
- }
-
- protected abstract void execute(OperationContext operationContext, ResultHandler
resultHandler, Navigation defaultNavigation);
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/AbstractNavigationOperationHandler.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/AbstractNavigationOperationHandler.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/AbstractNavigationOperationHandler.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/AbstractNavigationOperationHandler.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.operations.navigation;
+
+import
org.exoplatform.portal.mop.management.operations.site.AbstractSiteOperationHandler;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.mop.api.workspace.Navigation;
+import org.gatein.mop.api.workspace.Site;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class AbstractNavigationOperationHandler extends
AbstractSiteOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Site site) throws ResourceNotFoundException, OperationException
+ {
+ Navigation navigation = site.getRootNavigation().getChild("default");
+ if (navigation == null) throw new ResourceNotFoundException("Navigation does
not exist for site " + getSiteKey(site));
+
+ execute(operationContext, resultHandler, navigation);
+ }
+
+ protected abstract void execute(OperationContext operationContext, ResultHandler
resultHandler, Navigation defaultNavigation);
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,63 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.operations.navigation;
-
-import org.exoplatform.portal.config.model.PageNavigation;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.description.DescriptionService;
-import org.exoplatform.portal.mop.management.exportimport.NavigationExportTask;
-import org.exoplatform.portal.mop.navigation.NavigationService;
-import org.gatein.management.api.ContentType;
-import org.gatein.management.api.binding.BindingProvider;
-import org.gatein.management.api.binding.Marshaller;
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.ResultHandler;
-import org.gatein.management.api.operation.model.ExportResourceModel;
-import org.gatein.mop.api.workspace.Navigation;
-import org.gatein.mop.api.workspace.Site;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class NavigationExportResource extends AbstractNavigationOperationHandler
-{
- @Override
- protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Navigation navigation) throws ResourceNotFoundException, OperationException
- {
- Site site = navigation.getSite();
- String navUri =
operationContext.getAddress().resolvePathTemplate("nav-uri");
- SiteKey siteKey = getSiteKey(site);
-
- DescriptionService descriptionService =
operationContext.getRuntimeContext().getRuntimeComponent(DescriptionService.class);
- NavigationService navigationService =
operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
- BindingProvider bindingProvider = operationContext.getBindingProvider();
- Marshaller<PageNavigation> marshaller =
bindingProvider.getMarshaller(PageNavigation.class, ContentType.XML);
-
- NavigationExportTask exportTask = new NavigationExportTask(new
NavigationKey(siteKey, navUri), navigationService, descriptionService, marshaller);
-
- resultHandler.completed(new ExportResourceModel(exportTask));
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.operations.navigation;
+
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.description.DescriptionService;
+import org.exoplatform.portal.mop.management.exportimport.NavigationExportTask;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.gatein.management.api.ContentType;
+import org.gatein.management.api.binding.BindingProvider;
+import org.gatein.management.api.binding.Marshaller;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.management.api.operation.model.ExportResourceModel;
+import org.gatein.mop.api.workspace.Navigation;
+import org.gatein.mop.api.workspace.Site;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationExportResource extends AbstractNavigationOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Navigation navigation) throws ResourceNotFoundException, OperationException
+ {
+ Site site = navigation.getSite();
+ String navUri =
operationContext.getAddress().resolvePathTemplate("nav-uri");
+ SiteKey siteKey = getSiteKey(site);
+
+ DescriptionService descriptionService =
operationContext.getRuntimeContext().getRuntimeComponent(DescriptionService.class);
+ NavigationService navigationService =
operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
+ BindingProvider bindingProvider = operationContext.getBindingProvider();
+ Marshaller<PageNavigation> marshaller =
bindingProvider.getMarshaller(PageNavigation.class, ContentType.XML);
+
+ NavigationExportTask exportTask = new NavigationExportTask(new
NavigationKey(siteKey, navUri), navigationService, descriptionService, marshaller);
+
+ resultHandler.completed(new ExportResourceModel(exportTask));
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationKey.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationKey.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationKey.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.operations.navigation;
-
-import org.exoplatform.portal.mop.SiteKey;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class NavigationKey
-{
- private SiteKey siteKey;
- private String navUri;
-
- public NavigationKey(SiteKey siteKey)
- {
- this.siteKey = siteKey;
- }
-
- public NavigationKey(SiteKey siteKey, String navUri)
- {
- this.siteKey = siteKey;
- this.navUri = navUri;
- }
-
- public SiteKey getSiteKey()
- {
- return siteKey;
- }
-
- public String getNavUri()
- {
- return navUri;
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationKey.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationKey.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationKey.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationKey.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.operations.navigation;
+
+import org.exoplatform.portal.mop.SiteKey;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationKey
+{
+ private SiteKey siteKey;
+ private String navUri;
+
+ public NavigationKey(SiteKey siteKey)
+ {
+ this.siteKey = siteKey;
+ }
+
+ public NavigationKey(SiteKey siteKey, String navUri)
+ {
+ this.siteKey = siteKey;
+ this.navUri = navUri;
+ }
+
+ public SiteKey getSiteKey()
+ {
+ return siteKey;
+ }
+
+ public String getNavUri()
+ {
+ return navUri;
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadConfigAsXml.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadConfigAsXml.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadConfigAsXml.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.operations.navigation;
-
-import org.exoplatform.portal.config.model.PageNavigation;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.description.DescriptionService;
-import org.exoplatform.portal.mop.navigation.NavigationService;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.ResultHandler;
-import org.gatein.mop.api.workspace.Navigation;
-import org.gatein.mop.api.workspace.Site;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class NavigationReadConfigAsXml extends AbstractNavigationOperationHandler
-{
- @Override
- protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Navigation defaultNavigation)
- {
- String navUri =
operationContext.getAddress().resolvePathTemplate("nav-uri");
-
- Site site = defaultNavigation.getSite();
- SiteKey siteKey = getSiteKey(site);
-
- //TODO: If there's any benefit in creating our own node model to use with
navigation service, lets do it
-
- DescriptionService descriptionService =
operationContext.getRuntimeContext().getRuntimeComponent(DescriptionService.class);
- NavigationService navigationService =
operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
-
- PageNavigation pageNavigation = NavigationUtils.loadPageNavigation(new
NavigationKey(siteKey, navUri), navigationService, descriptionService);
- if (pageNavigation == null) throw new ResourceNotFoundException("Navigation
node not found for navigation uri '" + navUri +"'");
-
- resultHandler.completed(pageNavigation);
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadConfigAsXml.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadConfigAsXml.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadConfigAsXml.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadConfigAsXml.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.operations.navigation;
+
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.description.DescriptionService;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.mop.api.workspace.Navigation;
+import org.gatein.mop.api.workspace.Site;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationReadConfigAsXml extends AbstractNavigationOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Navigation defaultNavigation)
+ {
+ String navUri =
operationContext.getAddress().resolvePathTemplate("nav-uri");
+
+ Site site = defaultNavigation.getSite();
+ SiteKey siteKey = getSiteKey(site);
+
+ //TODO: If there's any benefit in creating our own node model to use with
navigation service, lets do it
+
+ DescriptionService descriptionService =
operationContext.getRuntimeContext().getRuntimeComponent(DescriptionService.class);
+ NavigationService navigationService =
operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
+
+ PageNavigation pageNavigation = NavigationUtils.loadPageNavigation(new
NavigationKey(siteKey, navUri), navigationService, descriptionService);
+ if (pageNavigation == null) throw new ResourceNotFoundException("Navigation
node not found for navigation uri '" + navUri +"'");
+
+ resultHandler.completed(pageNavigation);
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,47 +0,0 @@
-package org.exoplatform.portal.mop.management.operations.navigation;
-
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.navigation.NavigationContext;
-import org.exoplatform.portal.mop.navigation.NavigationService;
-import org.exoplatform.portal.mop.navigation.NodeContext;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.ResultHandler;
-import org.gatein.management.api.operation.model.ReadResourceModel;
-import org.gatein.mop.api.workspace.Navigation;
-
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class NavigationReadResource extends AbstractNavigationOperationHandler
-{
- @Override
- protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Navigation defaultNavigation)
- {
- SiteKey siteKey = getSiteKey(defaultNavigation.getSite());
- String navUri =
operationContext.getAddress().resolvePathTemplate("nav-uri");
-
- NavigationService navigationService =
operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
- NavigationContext navigation = navigationService.loadNavigation(siteKey);
-
- Set<String> children = new LinkedHashSet<String>();
-
- NodeContext<NodeContext<?>> node =
NavigationUtils.loadNode(navigationService, navigation, navUri);
- if (node == null)
- {
- throw new ResourceNotFoundException("Navigation node not found for
navigation uri '" + navUri +"'");
- }
-
- for (NodeContext child : node.getNodes())
- {
- children.add(child.getName());
- }
-
- ReadResourceModel model = new ReadResourceModel("Navigation nodes available at
this resource.", children);
- resultHandler.completed(model);
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,47 @@
+package org.exoplatform.portal.mop.management.operations.navigation;
+
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.navigation.NavigationContext;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.exoplatform.portal.mop.navigation.NodeContext;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.management.api.operation.model.ReadResourceModel;
+import org.gatein.mop.api.workspace.Navigation;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationReadResource extends AbstractNavigationOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Navigation defaultNavigation)
+ {
+ SiteKey siteKey = getSiteKey(defaultNavigation.getSite());
+ String navUri =
operationContext.getAddress().resolvePathTemplate("nav-uri");
+
+ NavigationService navigationService =
operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
+ NavigationContext navigation = navigationService.loadNavigation(siteKey);
+
+ Set<String> children = new LinkedHashSet<String>();
+
+ NodeContext<NodeContext<?>> node =
NavigationUtils.loadNode(navigationService, navigation, navUri);
+ if (node == null)
+ {
+ throw new ResourceNotFoundException("Navigation node not found for
navigation uri '" + navUri +"'");
+ }
+
+ for (NodeContext child : node.getNodes())
+ {
+ children.add(child.getName());
+ }
+
+ ReadResourceModel model = new ReadResourceModel("Navigation nodes available at
this resource.", children);
+ resultHandler.completed(model);
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationUtils.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationUtils.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationUtils.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,218 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.operations.navigation;
-
-import org.exoplatform.portal.config.model.I18NString;
-import org.exoplatform.portal.config.model.LocalizedString;
-import org.exoplatform.portal.config.model.NavigationFragment;
-import org.exoplatform.portal.config.model.PageNavigation;
-import org.exoplatform.portal.config.model.PageNode;
-import org.exoplatform.portal.mop.Described;
-import org.exoplatform.portal.mop.description.DescriptionService;
-import org.exoplatform.portal.mop.navigation.GenericScope;
-import org.exoplatform.portal.mop.navigation.NavigationContext;
-import org.exoplatform.portal.mop.navigation.NavigationService;
-import org.exoplatform.portal.mop.navigation.NodeContext;
-import org.exoplatform.portal.mop.navigation.NodeModel;
-import org.exoplatform.portal.mop.navigation.Scope;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class NavigationUtils
-{
- private NavigationUtils(){}
-
- public static PageNavigation loadPageNavigation(NavigationKey key, NavigationService
navigationService, DescriptionService descriptionService)
- {
- NavigationContext navigation = navigationService.loadNavigation(key.getSiteKey());
- if (navigation == null) return null;
-
- NodeContext<NodeContext<?>> node = loadNode(navigationService,
navigation, key.getNavUri());
- if (node == null) return null;
-
- if (key.getNavUri() != null)
- {
- return createFragmentedPageNavigation(descriptionService, navigation, node);
- }
- else
- {
- return createPageNavigation(descriptionService, navigation, node);
- }
- }
-
- public static NodeContext<NodeContext<?>> loadNode(NavigationService
navigationService, NavigationContext navigation, String navUri)
- {
- if (navigation == null) return null;
-
- if (navUri != null)
- {
- String[] path = trim(navUri.split("/"));
- NodeContext<NodeContext<?>> node =
navigationService.loadNode(NodeModel.SELF_MODEL, navigation,
GenericScope.branchShape(path, Scope.ALL), null);
- for (String name : path)
- {
- node = node.get(name);
- if (node == null) break;
- }
-
- return node;
- }
- else
- {
- return navigationService.loadNode(NodeModel.SELF_MODEL, navigation, Scope.ALL,
null);
- }
- }
-
- public static PageNavigation createPageNavigation(DescriptionService service,
NavigationContext navigation, NodeContext<NodeContext<?>> node)
- {
- PageNavigation pageNavigation = new PageNavigation();
- pageNavigation.setPriority(navigation.getState().getPriority());
- pageNavigation.setOwnerType(navigation.getKey().getTypeName());
- pageNavigation.setOwnerId(navigation.getKey().getName());
-
- ArrayList<PageNode> children = new
ArrayList<PageNode>(node.getNodeCount());
- for (NodeContext<?> child : node.getNodes())
- {
- @SuppressWarnings("unchecked")
- NodeContext<NodeContext<?>> childNode =
(NodeContext<NodeContext<?>>) child;
- children.add(createPageNode(service, childNode));
- }
-
- NavigationFragment fragment = new NavigationFragment();
- fragment.setNodes(children);
- pageNavigation.addFragment(fragment);
-
- return pageNavigation;
- }
-
- private static PageNavigation createFragmentedPageNavigation(DescriptionService
service, NavigationContext navigation, NodeContext<NodeContext<?>> node)
- {
- PageNavigation pageNavigation = new PageNavigation();
- pageNavigation.setPriority(navigation.getState().getPriority());
- pageNavigation.setOwnerType(navigation.getKey().getTypeName());
- pageNavigation.setOwnerId(navigation.getKey().getName());
-
- ArrayList<PageNode> children = new ArrayList<PageNode>(1);
- children.add(createPageNode(service, node));
-
- NavigationFragment fragment = new NavigationFragment();
- StringBuilder parentUri = new StringBuilder("/");
- getPath(node.getParent(), parentUri);
- fragment.setParentURI(parentUri.toString());
- fragment.setNodes(children);
-
- pageNavigation.addFragment(fragment);
-
- return pageNavigation;
- }
-
- private static void getPath(NodeContext<NodeContext<?>> node,
StringBuilder parentUri)
- {
- if (node == null) return;
- if (node.getParent() == null) return; // since "default" is the root
node, we ignore it
-
- parentUri.insert(0, node.getName()).append("/");
- getPath(node.getParent(), parentUri);
- }
-
- private static PageNode createPageNode(DescriptionService service,
NodeContext<NodeContext<?>> node)
- {
- PageNode pageNode = new PageNode();
- pageNode.setName(node.getName());
-
- if (node.getState().getLabel() == null)
- {
- Map<Locale, Described.State> descriptions =
service.getDescriptions(node.getId());
- if (descriptions != null && !descriptions.isEmpty())
- {
- I18NString labels = new I18NString();
- for (Map.Entry<Locale, Described.State> entry :
descriptions.entrySet())
- {
- labels.add(new LocalizedString(entry.getValue().getName(),
entry.getKey()));
- }
-
- pageNode.setLabels(labels);
- }
- }
- else
- {
- pageNode.setLabel(node.getState().getLabel());
- }
-
- pageNode.setIcon(node.getState().getIcon());
- long startPublicationTime = node.getState().getStartPublicationTime();
- if (startPublicationTime != -1)
- {
- pageNode.setStartPublicationDate(new Date(startPublicationTime));
- }
-
- long endPublicationTime = node.getState().getEndPublicationTime();
- if (endPublicationTime != -1)
- {
- pageNode.setEndPublicationDate(new Date(endPublicationTime));
- }
-
- pageNode.setVisibility(node.getState().getVisibility());
- pageNode.setPageReference(node.getState().getPageRef());
-
- if (node.getNodes() != null)
- {
- ArrayList<PageNode> children = new
ArrayList<PageNode>(node.getNodeCount());
- for (NodeContext<?> child : node.getNodes())
- {
- @SuppressWarnings("unchecked")
- NodeContext<NodeContext<?>> childNode =
(NodeContext<NodeContext<?>>) child;
- children.add(createPageNode(service, childNode));
- }
-
- pageNode.setChildren(children);
- }
- else
- {
- pageNode.setChildren(new ArrayList<PageNode>(0));
- }
-
- return pageNode;
- }
-
- private static String[] trim(String[] array)
- {
- List<String> trimmed = new ArrayList<String>(array.length);
- for (String s : array)
- {
- if (s != null && !"".equals(s))
- {
- trimmed.add(s);
- }
- }
-
- return trimmed.toArray(new String[trimmed.size()]);
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationUtils.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationUtils.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationUtils.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationUtils.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,218 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.operations.navigation;
+
+import org.exoplatform.portal.config.model.I18NString;
+import org.exoplatform.portal.config.model.LocalizedString;
+import org.exoplatform.portal.config.model.NavigationFragment;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PageNode;
+import org.exoplatform.portal.mop.Described;
+import org.exoplatform.portal.mop.description.DescriptionService;
+import org.exoplatform.portal.mop.navigation.GenericScope;
+import org.exoplatform.portal.mop.navigation.NavigationContext;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.exoplatform.portal.mop.navigation.NodeContext;
+import org.exoplatform.portal.mop.navigation.NodeModel;
+import org.exoplatform.portal.mop.navigation.Scope;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationUtils
+{
+ private NavigationUtils(){}
+
+ public static PageNavigation loadPageNavigation(NavigationKey key, NavigationService
navigationService, DescriptionService descriptionService)
+ {
+ NavigationContext navigation = navigationService.loadNavigation(key.getSiteKey());
+ if (navigation == null) return null;
+
+ NodeContext<NodeContext<?>> node = loadNode(navigationService,
navigation, key.getNavUri());
+ if (node == null) return null;
+
+ if (key.getNavUri() != null)
+ {
+ return createFragmentedPageNavigation(descriptionService, navigation, node);
+ }
+ else
+ {
+ return createPageNavigation(descriptionService, navigation, node);
+ }
+ }
+
+ public static NodeContext<NodeContext<?>> loadNode(NavigationService
navigationService, NavigationContext navigation, String navUri)
+ {
+ if (navigation == null) return null;
+
+ if (navUri != null)
+ {
+ String[] path = trim(navUri.split("/"));
+ NodeContext<NodeContext<?>> node =
navigationService.loadNode(NodeModel.SELF_MODEL, navigation,
GenericScope.branchShape(path, Scope.ALL), null);
+ for (String name : path)
+ {
+ node = node.get(name);
+ if (node == null) break;
+ }
+
+ return node;
+ }
+ else
+ {
+ return navigationService.loadNode(NodeModel.SELF_MODEL, navigation, Scope.ALL,
null);
+ }
+ }
+
+ public static PageNavigation createPageNavigation(DescriptionService service,
NavigationContext navigation, NodeContext<NodeContext<?>> node)
+ {
+ PageNavigation pageNavigation = new PageNavigation();
+ pageNavigation.setPriority(navigation.getState().getPriority());
+ pageNavigation.setOwnerType(navigation.getKey().getTypeName());
+ pageNavigation.setOwnerId(navigation.getKey().getName());
+
+ ArrayList<PageNode> children = new
ArrayList<PageNode>(node.getNodeCount());
+ for (NodeContext<?> child : node.getNodes())
+ {
+ @SuppressWarnings("unchecked")
+ NodeContext<NodeContext<?>> childNode =
(NodeContext<NodeContext<?>>) child;
+ children.add(createPageNode(service, childNode));
+ }
+
+ NavigationFragment fragment = new NavigationFragment();
+ fragment.setNodes(children);
+ pageNavigation.addFragment(fragment);
+
+ return pageNavigation;
+ }
+
+ private static PageNavigation createFragmentedPageNavigation(DescriptionService
service, NavigationContext navigation, NodeContext<NodeContext<?>> node)
+ {
+ PageNavigation pageNavigation = new PageNavigation();
+ pageNavigation.setPriority(navigation.getState().getPriority());
+ pageNavigation.setOwnerType(navigation.getKey().getTypeName());
+ pageNavigation.setOwnerId(navigation.getKey().getName());
+
+ ArrayList<PageNode> children = new ArrayList<PageNode>(1);
+ children.add(createPageNode(service, node));
+
+ NavigationFragment fragment = new NavigationFragment();
+ StringBuilder parentUri = new StringBuilder("/");
+ getPath(node.getParent(), parentUri);
+ fragment.setParentURI(parentUri.toString());
+ fragment.setNodes(children);
+
+ pageNavigation.addFragment(fragment);
+
+ return pageNavigation;
+ }
+
+ private static void getPath(NodeContext<NodeContext<?>> node,
StringBuilder parentUri)
+ {
+ if (node == null) return;
+ if (node.getParent() == null) return; // since "default" is the root
node, we ignore it
+
+ parentUri.insert(0, node.getName()).append("/");
+ getPath(node.getParent(), parentUri);
+ }
+
+ private static PageNode createPageNode(DescriptionService service,
NodeContext<NodeContext<?>> node)
+ {
+ PageNode pageNode = new PageNode();
+ pageNode.setName(node.getName());
+
+ if (node.getState().getLabel() == null)
+ {
+ Map<Locale, Described.State> descriptions =
service.getDescriptions(node.getId());
+ if (descriptions != null && !descriptions.isEmpty())
+ {
+ I18NString labels = new I18NString();
+ for (Map.Entry<Locale, Described.State> entry :
descriptions.entrySet())
+ {
+ labels.add(new LocalizedString(entry.getValue().getName(),
entry.getKey()));
+ }
+
+ pageNode.setLabels(labels);
+ }
+ }
+ else
+ {
+ pageNode.setLabel(node.getState().getLabel());
+ }
+
+ pageNode.setIcon(node.getState().getIcon());
+ long startPublicationTime = node.getState().getStartPublicationTime();
+ if (startPublicationTime != -1)
+ {
+ pageNode.setStartPublicationDate(new Date(startPublicationTime));
+ }
+
+ long endPublicationTime = node.getState().getEndPublicationTime();
+ if (endPublicationTime != -1)
+ {
+ pageNode.setEndPublicationDate(new Date(endPublicationTime));
+ }
+
+ pageNode.setVisibility(node.getState().getVisibility());
+ pageNode.setPageReference(node.getState().getPageRef());
+
+ if (node.getNodes() != null)
+ {
+ ArrayList<PageNode> children = new
ArrayList<PageNode>(node.getNodeCount());
+ for (NodeContext<?> child : node.getNodes())
+ {
+ @SuppressWarnings("unchecked")
+ NodeContext<NodeContext<?>> childNode =
(NodeContext<NodeContext<?>>) child;
+ children.add(createPageNode(service, childNode));
+ }
+
+ pageNode.setChildren(children);
+ }
+ else
+ {
+ pageNode.setChildren(new ArrayList<PageNode>(0));
+ }
+
+ return pageNode;
+ }
+
+ private static String[] trim(String[] array)
+ {
+ List<String> trimmed = new ArrayList<String>(array.length);
+ for (String s : array)
+ {
+ if (s != null && !"".equals(s))
+ {
+ trimmed.add(s);
+ }
+ }
+
+ return trimmed.toArray(new String[trimmed.size()]);
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageOperationHandler.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageOperationHandler.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageOperationHandler.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.operations.page;
-
-import
org.exoplatform.portal.mop.management.operations.site.AbstractSiteOperationHandler;
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.ResultHandler;
-import org.gatein.mop.api.workspace.Page;
-import org.gatein.mop.api.workspace.Site;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public abstract class AbstractPageOperationHandler extends AbstractSiteOperationHandler
-{
- @Override
- protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Site site) throws ResourceNotFoundException, OperationException
- {
- Page pages = site.getRootPage().getChild("pages");
- if (pages == null || pages.getChildren().isEmpty()) throw new
ResourceNotFoundException("No pages found for site " + getSiteKey(site));
-
- execute(operationContext, resultHandler, pages);
- }
-
- protected abstract void execute(OperationContext operationContext, ResultHandler
resultHandler, Page page) throws ResourceNotFoundException, OperationException;
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageOperationHandler.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageOperationHandler.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageOperationHandler.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageOperationHandler.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.operations.page;
+
+import
org.exoplatform.portal.mop.management.operations.site.AbstractSiteOperationHandler;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.mop.api.workspace.Page;
+import org.gatein.mop.api.workspace.Site;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class AbstractPageOperationHandler extends AbstractSiteOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Site site) throws ResourceNotFoundException, OperationException
+ {
+ Page pages = site.getRootPage().getChild("pages");
+ if (pages == null || pages.getChildren().isEmpty()) throw new
ResourceNotFoundException("No pages found for site " + getSiteKey(site));
+
+ execute(operationContext, resultHandler, pages);
+ }
+
+ protected abstract void execute(OperationContext operationContext, ResultHandler
resultHandler, Page page) throws ResourceNotFoundException, OperationException;
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageExportResource.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageExportResource.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageExportResource.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,84 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.operations.page;
-
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.management.exportimport.PageExportTask;
-import org.gatein.management.api.ContentType;
-import org.gatein.management.api.binding.BindingProvider;
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.ResultHandler;
-import org.gatein.management.api.operation.model.ExportResourceModel;
-import org.gatein.management.api.operation.model.ExportTask;
-import org.gatein.mop.api.workspace.Page;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PageExportResource extends AbstractPageOperationHandler
-{
- @Override
- protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Page pages) throws ResourceNotFoundException, OperationException
- {
- SiteKey siteKey = getSiteKey(pages.getSite());
-
- DataStorage dataStorage =
operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
- BindingProvider bindingProvider = operationContext.getBindingProvider();
-
- Collection<Page> pagesList = pages.getChildren();
- List<ExportTask> tasks = new ArrayList<ExportTask>(pagesList.size());
- PageExportTask pageExportTask =
- new PageExportTask(siteKey, dataStorage, bindingProvider.getMarshaller(
- org.exoplatform.portal.config.model.Page.PageSet.class, ContentType.XML));
-
- String pageName =
operationContext.getAddress().resolvePathTemplate("page-name");
- for (Page page : pagesList)
- {
- if (pageName == null)
- {
- pageExportTask.addPageName(page.getName());
- }
- else if (pageName.equals(page.getName()))
- {
- pageExportTask.addPageName(page.getName());
- }
- }
-
- if (pageExportTask.getPageNames().isEmpty() && pageName != null)
- {
- throw new ResourceNotFoundException("No page found for " + new
PageKey(siteKey, pageName));
- }
-
- tasks.add(pageExportTask);
-
- resultHandler.completed(new ExportResourceModel(tasks));
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageExportResource.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageExportResource.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageExportResource.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageExportResource.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.operations.page;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.management.exportimport.PageExportTask;
+import org.gatein.management.api.ContentType;
+import org.gatein.management.api.binding.BindingProvider;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.management.api.operation.model.ExportResourceModel;
+import org.gatein.management.api.operation.model.ExportTask;
+import org.gatein.mop.api.workspace.Page;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageExportResource extends AbstractPageOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Page pages) throws ResourceNotFoundException, OperationException
+ {
+ SiteKey siteKey = getSiteKey(pages.getSite());
+
+ DataStorage dataStorage =
operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
+ BindingProvider bindingProvider = operationContext.getBindingProvider();
+
+ Collection<Page> pagesList = pages.getChildren();
+ List<ExportTask> tasks = new ArrayList<ExportTask>(pagesList.size());
+ PageExportTask pageExportTask =
+ new PageExportTask(siteKey, dataStorage, bindingProvider.getMarshaller(
+ org.exoplatform.portal.config.model.Page.PageSet.class, ContentType.XML));
+
+ String pageName =
operationContext.getAddress().resolvePathTemplate("page-name");
+ for (Page page : pagesList)
+ {
+ if (pageName == null)
+ {
+ pageExportTask.addPageName(page.getName());
+ }
+ else if (pageName.equals(page.getName()))
+ {
+ pageExportTask.addPageName(page.getName());
+ }
+ }
+
+ if (pageExportTask.getPageNames().isEmpty() && pageName != null)
+ {
+ throw new ResourceNotFoundException("No page found for " + new
PageKey(siteKey, pageName));
+ }
+
+ tasks.add(pageExportTask);
+
+ resultHandler.completed(new ExportResourceModel(tasks));
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageKey.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageKey.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageKey.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,43 +0,0 @@
-package org.exoplatform.portal.mop.management.operations.page;
-
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.pom.config.Utils;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PageKey
-{
- private final SiteKey siteKey;
- private final String pageName;
- private final String pageId;
-
- public PageKey(SiteKey siteKey, String pageName)
- {
- this.siteKey = siteKey;
- this.pageName = pageName;
- this.pageId = Utils.join("::", siteKey.getTypeName(), siteKey.getName(),
pageName);
- }
-
- public SiteKey getSiteKey()
- {
- return siteKey;
- }
-
- public String getPageName()
- {
- return pageName;
- }
-
- public String getPageId()
- {
- return pageId;
- }
-
- @Override
- public String toString()
- {
- return "PageKey{siteKey=" + siteKey + ", pageName='" +
pageName + "'}";
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageKey.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageKey.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageKey.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageKey.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,43 @@
+package org.exoplatform.portal.mop.management.operations.page;
+
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.pom.config.Utils;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageKey
+{
+ private final SiteKey siteKey;
+ private final String pageName;
+ private final String pageId;
+
+ public PageKey(SiteKey siteKey, String pageName)
+ {
+ this.siteKey = siteKey;
+ this.pageName = pageName;
+ this.pageId = Utils.join("::", siteKey.getTypeName(), siteKey.getName(),
pageName);
+ }
+
+ public SiteKey getSiteKey()
+ {
+ return siteKey;
+ }
+
+ public String getPageName()
+ {
+ return pageName;
+ }
+
+ public String getPageId()
+ {
+ return pageId;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "PageKey{siteKey=" + siteKey + ", pageName='" +
pageName + "'}";
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadConfigAsXml.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadConfigAsXml.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadConfigAsXml.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,68 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.operations.page;
-
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.Query;
-import org.exoplatform.portal.config.model.Page;
-import org.exoplatform.portal.mop.SiteKey;
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.ResultHandler;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PageReadConfigAsXml extends AbstractPageOperationHandler
-{
- @Override
- protected void execute(OperationContext operationContext, ResultHandler resultHandler,
org.gatein.mop.api.workspace.Page rootPage) throws ResourceNotFoundException,
OperationException
- {
- SiteKey siteKey = getSiteKey(rootPage.getSite());
- DataStorage dataStorage =
operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
-
- String pageName =
operationContext.getAddress().resolvePathTemplate("page-name");
- if (pageName == null)
- {
- resultHandler.completed(PageUtils.getAllPages(dataStorage, siteKey,
operationContext.getOperationName()));
- }
- else
- {
- PageKey key = new PageKey(siteKey, pageName);
- Page page = PageUtils.getPage(dataStorage, key,
operationContext.getOperationName());
- if (page == null)
- {
- throw new ResourceNotFoundException("No page found for " + key);
- }
- else
- {
- resultHandler.completed(page);
- }
- }
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadConfigAsXml.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadConfigAsXml.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadConfigAsXml.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadConfigAsXml.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.operations.page;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.Query;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.mop.SiteKey;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageReadConfigAsXml extends AbstractPageOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler,
org.gatein.mop.api.workspace.Page rootPage) throws ResourceNotFoundException,
OperationException
+ {
+ SiteKey siteKey = getSiteKey(rootPage.getSite());
+ DataStorage dataStorage =
operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
+
+ String pageName =
operationContext.getAddress().resolvePathTemplate("page-name");
+ if (pageName == null)
+ {
+ resultHandler.completed(PageUtils.getAllPages(dataStorage, siteKey,
operationContext.getOperationName()));
+ }
+ else
+ {
+ PageKey key = new PageKey(siteKey, pageName);
+ Page page = PageUtils.getPage(dataStorage, key,
operationContext.getOperationName());
+ if (page == null)
+ {
+ throw new ResourceNotFoundException("No page found for " + key);
+ }
+ else
+ {
+ resultHandler.completed(page);
+ }
+ }
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,50 +0,0 @@
-package org.exoplatform.portal.mop.management.operations.page;
-
-import org.exoplatform.portal.config.DataStorage;
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.ResultHandler;
-import org.gatein.management.api.operation.model.ReadResourceModel;
-import org.gatein.mop.api.workspace.Page;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PageReadResource extends AbstractPageOperationHandler
-{
- @Override
- protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Page rootPage) throws ResourceNotFoundException, OperationException
- {
- String pageName =
operationContext.getAddress().resolvePathTemplate("page-name");
- if (pageName == null)
- {
- Collection<Page> pageList = rootPage.getChildren();
- Set<String> children = new LinkedHashSet<String>(pageList.size());
- for (Page page : pageList)
- {
- children.add(page.getName());
- }
-
- resultHandler.completed(new ReadResourceModel("List of all available pages
for site '" + rootPage.getSite().getName() +"'", children));
- }
- else
- {
- DataStorage dataStorage =
operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
- PageKey pageKey = new PageKey(getSiteKey(rootPage.getSite()), pageName);
-
- if (PageUtils.getPage(dataStorage, pageKey, operationContext.getOperationName())
== null)
- {
- throw new ResourceNotFoundException("No page found for " +
pageKey);
- }
-
- resultHandler.completed(new ReadResourceModel("List of child pages for page
'" + pageName +"'", Collections.<String>emptySet()));
- }
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,50 @@
+package org.exoplatform.portal.mop.management.operations.page;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.management.api.operation.model.ReadResourceModel;
+import org.gatein.mop.api.workspace.Page;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageReadResource extends AbstractPageOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Page rootPage) throws ResourceNotFoundException, OperationException
+ {
+ String pageName =
operationContext.getAddress().resolvePathTemplate("page-name");
+ if (pageName == null)
+ {
+ Collection<Page> pageList = rootPage.getChildren();
+ Set<String> children = new LinkedHashSet<String>(pageList.size());
+ for (Page page : pageList)
+ {
+ children.add(page.getName());
+ }
+
+ resultHandler.completed(new ReadResourceModel("List of all available pages
for site '" + rootPage.getSite().getName() +"'", children));
+ }
+ else
+ {
+ DataStorage dataStorage =
operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
+ PageKey pageKey = new PageKey(getSiteKey(rootPage.getSite()), pageName);
+
+ if (PageUtils.getPage(dataStorage, pageKey, operationContext.getOperationName())
== null)
+ {
+ throw new ResourceNotFoundException("No page found for " +
pageKey);
+ }
+
+ resultHandler.completed(new ReadResourceModel("List of child pages for page
'" + pageName +"'", Collections.<String>emptySet()));
+ }
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUtils.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUtils.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUtils.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,48 +0,0 @@
-package org.exoplatform.portal.mop.management.operations.page;
-
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.Query;
-import org.exoplatform.portal.config.model.Page;
-import org.exoplatform.portal.mop.SiteKey;
-import org.gatein.management.api.exceptions.OperationException;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PageUtils
-{
- private PageUtils(){}
-
- public static Page getPage(DataStorage dataStorage, PageKey pageKey, String
operationName)
- {
- try
- {
- return dataStorage.getPage(pageKey.getPageId());
- }
- catch (Exception e)
- {
- throw new OperationException(operationName, "Operation failed getting page
for " + pageKey, e);
- }
- }
-
- public static Page.PageSet getAllPages(DataStorage dataStorage, SiteKey siteKey,
String operationName)
- {
- Query<Page> query = new Query<Page>(siteKey.getTypeName(),
siteKey.getName(), Page.class);
- try
- {
- List<Page> pageList = dataStorage.find(query).getAll();
- Page.PageSet pages = new Page.PageSet();
- pages.setPages(new ArrayList<Page>(pageList));
-
- return pages;
- }
- catch (Exception e)
- {
- throw new OperationException(operationName, "Could not retrieve pages for
site " + siteKey);
- }
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUtils.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUtils.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUtils.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUtils.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,48 @@
+package org.exoplatform.portal.mop.management.operations.page;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.Query;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.mop.SiteKey;
+import org.gatein.management.api.exceptions.OperationException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageUtils
+{
+ private PageUtils(){}
+
+ public static Page getPage(DataStorage dataStorage, PageKey pageKey, String
operationName)
+ {
+ try
+ {
+ return dataStorage.getPage(pageKey.getPageId());
+ }
+ catch (Exception e)
+ {
+ throw new OperationException(operationName, "Operation failed getting page
for " + pageKey, e);
+ }
+ }
+
+ public static Page.PageSet getAllPages(DataStorage dataStorage, SiteKey siteKey,
String operationName)
+ {
+ Query<Page> query = new Query<Page>(siteKey.getTypeName(),
siteKey.getName(), Page.class);
+ try
+ {
+ List<Page> pageList = dataStorage.find(query).getAll();
+ Page.PageSet pages = new Page.PageSet();
+ pages.setPages(new ArrayList<Page>(pageList));
+
+ return pages;
+ }
+ catch (Exception e)
+ {
+ throw new OperationException(operationName, "Could not retrieve pages for
site " + siteKey);
+ }
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/AbstractSiteOperationHandler.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/AbstractSiteOperationHandler.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/AbstractSiteOperationHandler.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.operations.site;
-
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.management.operations.AbstractMopOperationHandler;
-import org.gatein.management.api.PathAddress;
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.ResultHandler;
-import org.gatein.mop.api.workspace.ObjectType;
-import org.gatein.mop.api.workspace.Site;
-import org.gatein.mop.api.workspace.Workspace;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public abstract class AbstractSiteOperationHandler extends AbstractMopOperationHandler
-{
- @Override
- protected final void execute(OperationContext operationContext, ResultHandler
resultHandler, Workspace workspace, ObjectType<Site> siteType) throws
ResourceNotFoundException, OperationException
- {
- String operationName = operationContext.getOperationName();
- PathAddress address = operationContext.getAddress();
-
- String siteName = address.resolvePathTemplate("site-name");
- if (siteName == null) throw new OperationException(operationName, "No site
name specified.");
-
- SiteKey siteKey = getSiteKey(siteType, siteName);
-
- Site site = workspace.getSite(siteType, siteKey.getName());
- if (site == null) throw new ResourceNotFoundException("No site found for site
" + siteKey);
-
- execute(operationContext, resultHandler, site);
- }
-
- protected abstract void execute(OperationContext operationContext, ResultHandler
resultHandler, Site site) throws ResourceNotFoundException, OperationException;
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/AbstractSiteOperationHandler.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/AbstractSiteOperationHandler.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/AbstractSiteOperationHandler.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/AbstractSiteOperationHandler.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.operations.site;
+
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.management.operations.AbstractMopOperationHandler;
+import org.gatein.management.api.PathAddress;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.mop.api.workspace.ObjectType;
+import org.gatein.mop.api.workspace.Site;
+import org.gatein.mop.api.workspace.Workspace;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class AbstractSiteOperationHandler extends AbstractMopOperationHandler
+{
+ @Override
+ protected final void execute(OperationContext operationContext, ResultHandler
resultHandler, Workspace workspace, ObjectType<Site> siteType) throws
ResourceNotFoundException, OperationException
+ {
+ String operationName = operationContext.getOperationName();
+ PathAddress address = operationContext.getAddress();
+
+ String siteName = address.resolvePathTemplate("site-name");
+ if (siteName == null) throw new OperationException(operationName, "No site
name specified.");
+
+ SiteKey siteKey = getSiteKey(siteType, siteName);
+
+ Site site = workspace.getSite(siteType, siteKey.getName());
+ if (site == null) throw new ResourceNotFoundException("No site found for site
" + siteKey);
+
+ execute(operationContext, resultHandler, site);
+ }
+
+ protected abstract void execute(OperationContext operationContext, ResultHandler
resultHandler, Site site) throws ResourceNotFoundException, OperationException;
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutExportResource.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutExportResource.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutExportResource.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.operations.site;
-
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.management.exportimport.SiteLayoutExportTask;
-import org.exoplatform.portal.pom.config.POMSession;
-import org.exoplatform.portal.pom.config.POMSessionManager;
-import org.exoplatform.portal.pom.data.PortalData;
-import org.gatein.management.api.ContentType;
-import org.gatein.management.api.binding.BindingProvider;
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.ResultHandler;
-import org.gatein.management.api.operation.model.ExportResourceModel;
-import org.gatein.mop.api.workspace.Site;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class SiteLayoutExportResource extends AbstractSiteOperationHandler
-{
- @Override
- protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Site site) throws ResourceNotFoundException, OperationException
- {
- BindingProvider bindingProvider = operationContext.getBindingProvider();
- DataStorage dataStorage =
operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
-
- SiteKey siteKey = getSiteKey(site);
-
- resultHandler.completed(new ExportResourceModel(new SiteLayoutExportTask(siteKey,
dataStorage, bindingProvider.getMarshaller(PortalConfig.class, ContentType.XML))));
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutExportResource.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutExportResource.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutExportResource.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutExportResource.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.operations.site;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.management.exportimport.SiteLayoutExportTask;
+import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.POMSessionManager;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.gatein.management.api.ContentType;
+import org.gatein.management.api.binding.BindingProvider;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.management.api.operation.model.ExportResourceModel;
+import org.gatein.mop.api.workspace.Site;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SiteLayoutExportResource extends AbstractSiteOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Site site) throws ResourceNotFoundException, OperationException
+ {
+ BindingProvider bindingProvider = operationContext.getBindingProvider();
+ DataStorage dataStorage =
operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
+
+ SiteKey siteKey = getSiteKey(site);
+
+ resultHandler.completed(new ExportResourceModel(new SiteLayoutExportTask(siteKey,
dataStorage, bindingProvider.getMarshaller(PortalConfig.class, ContentType.XML))));
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadConfigAsXml.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadConfigAsXml.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadConfigAsXml.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.operations.site;
-
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.pom.config.POMSessionManager;
-import org.exoplatform.portal.pom.config.tasks.PortalConfigTask;
-import org.exoplatform.portal.pom.data.PortalData;
-import org.exoplatform.portal.pom.data.PortalKey;
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.ResultHandler;
-import org.gatein.mop.api.workspace.Site;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class SiteLayoutReadConfigAsXml extends AbstractSiteOperationHandler
-{
- @Override
- protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Site site) throws ResourceNotFoundException, OperationException
- {
- DataStorage dataStorage =
operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
- SiteKey siteKey = getSiteKey(site);
-
- try
- {
- PortalConfig portalConfig = dataStorage.getPortalConfig(siteKey.getTypeName(),
siteKey.getName());
- resultHandler.completed(portalConfig);
- }
- catch (Exception e)
- {
- throw new OperationException(operationContext.getOperationName(), "Could
not retrieve site layout for site " + site, e);
- }
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadConfigAsXml.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadConfigAsXml.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadConfigAsXml.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadConfigAsXml.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.operations.site;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.pom.config.POMSessionManager;
+import org.exoplatform.portal.pom.config.tasks.PortalConfigTask;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.exoplatform.portal.pom.data.PortalKey;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.mop.api.workspace.Site;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SiteLayoutReadConfigAsXml extends AbstractSiteOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Site site) throws ResourceNotFoundException, OperationException
+ {
+ DataStorage dataStorage =
operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
+ SiteKey siteKey = getSiteKey(site);
+
+ try
+ {
+ PortalConfig portalConfig = dataStorage.getPortalConfig(siteKey.getTypeName(),
siteKey.getName());
+ resultHandler.completed(portalConfig);
+ }
+ catch (Exception e)
+ {
+ throw new OperationException(operationContext.getOperationName(), "Could
not retrieve site layout for site " + site, e);
+ }
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,91 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.operations.site;
-
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.ResultHandler;
-import org.gatein.management.api.operation.model.ReadResourceModel;
-import org.gatein.mop.api.workspace.Navigation;
-import org.gatein.mop.api.workspace.ObjectType;
-import org.gatein.mop.api.workspace.Page;
-import org.gatein.mop.api.workspace.Site;
-
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class SiteReadResource extends AbstractSiteOperationHandler
-{
- @Override
- protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Site site) throws ResourceNotFoundException, OperationException
- {
- boolean pageOrNav = false;
- Set<String> children = new LinkedHashSet<String>(3);
-
- Page pages = site.getRootPage().getChild("pages");
- if (pages != null && !pages.getChildren().isEmpty())
- {
- children.add("pages");
- pageOrNav = true;
- }
-
- Navigation defaultNav = site.getRootNavigation().getChild("default");
- if (defaultNav != null && !defaultNav.getChildren().isEmpty())
- {
- children.add("navigation");
- pageOrNav = true;
- }
-
- if (pageOrNav)
- {
- children.add("portal");
- }
- else
- {
- if (site.getObjectType() == ObjectType.GROUP_SITE)
- {
- Collection<? extends Site> groupsites =
site.getWorkspace().getSites(site.getObjectType());
- for (Site groupsite : groupsites)
- {
- String siteName = site.getName();
- String groupName = groupsite.getName();
- if (siteName.equals(groupName)) continue;
-
- int index = groupName.indexOf(siteName);
- if (index == 0)
- {
- children.add(groupName.substring(siteName.length(),
groupName.length()));
- }
- }
- }
- }
-
- resultHandler.completed(new ReadResourceModel("Available artifacts for site
" + getSiteKey(site), children));
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.operations.site;
+
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.management.api.operation.model.ReadResourceModel;
+import org.gatein.mop.api.workspace.Navigation;
+import org.gatein.mop.api.workspace.ObjectType;
+import org.gatein.mop.api.workspace.Page;
+import org.gatein.mop.api.workspace.Site;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SiteReadResource extends AbstractSiteOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Site site) throws ResourceNotFoundException, OperationException
+ {
+ boolean pageOrNav = false;
+ Set<String> children = new LinkedHashSet<String>(3);
+
+ Page pages = site.getRootPage().getChild("pages");
+ if (pages != null && !pages.getChildren().isEmpty())
+ {
+ children.add("pages");
+ pageOrNav = true;
+ }
+
+ Navigation defaultNav = site.getRootNavigation().getChild("default");
+ if (defaultNav != null && !defaultNav.getChildren().isEmpty())
+ {
+ children.add("navigation");
+ pageOrNav = true;
+ }
+
+ if (pageOrNav)
+ {
+ children.add("portal");
+ }
+ else
+ {
+ if (site.getObjectType() == ObjectType.GROUP_SITE)
+ {
+ Collection<? extends Site> groupsites =
site.getWorkspace().getSites(site.getObjectType());
+ for (Site groupsite : groupsites)
+ {
+ String siteName = site.getName();
+ String groupName = groupsite.getName();
+ if (siteName.equals(groupName)) continue;
+
+ int index = groupName.indexOf(siteName);
+ if (index == 0)
+ {
+ children.add(groupName.substring(siteName.length(),
groupName.length()));
+ }
+ }
+ }
+ }
+
+ resultHandler.completed(new ReadResourceModel("Available artifacts for site
" + getSiteKey(site), children));
+ }
+}
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteTypeReadResource.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteTypeReadResource.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteTypeReadResource.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,82 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.operations.site;
-
-import org.exoplatform.portal.mop.management.operations.AbstractMopOperationHandler;
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.ResultHandler;
-import org.gatein.management.api.operation.model.ReadResourceModel;
-import org.gatein.mop.api.workspace.Navigation;
-import org.gatein.mop.api.workspace.ObjectType;
-import org.gatein.mop.api.workspace.Page;
-import org.gatein.mop.api.workspace.Site;
-import org.gatein.mop.api.workspace.Workspace;
-
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class SiteTypeReadResource extends AbstractMopOperationHandler
-{
- @Override
- protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Workspace workspace, ObjectType<Site> siteType) throws ResourceNotFoundException,
OperationException
- {
- Collection<Site> sites = workspace.getSites(siteType);
- Set<String> children = new LinkedHashSet<String>(sites.size());
- for (Site site : sites)
- {
- boolean pageOrNav = false;
- Page pages = site.getRootPage().getChild("pages");
- if (pages != null && !pages.getChildren().isEmpty())
- {
- pageOrNav = true;
- }
- Navigation defaultNav = site.getRootNavigation().getChild("default");
- if (defaultNav != null && !defaultNav.getChildren().isEmpty())
- {
- pageOrNav = true;
- }
-
- //TODO: Until invalid site entries without a leading slash is corrected, this is
needed to ignore them.
- if (siteType == ObjectType.GROUP_SITE)
- {
- String name = site.getName();
- if (name.charAt(0) == '/' && pageOrNav)
- {
- children.add(site.getName());
- }
- }
- else if (pageOrNav)
- {
- children.add(site.getName());
- }
- }
- resultHandler.completed(new ReadResourceModel("Available sites for site type
'" + getSiteType(siteType).getName() + "'", children));
- }
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteTypeReadResource.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteTypeReadResource.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteTypeReadResource.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteTypeReadResource.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.operations.site;
+
+import org.exoplatform.portal.mop.management.operations.AbstractMopOperationHandler;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.management.api.operation.model.ReadResourceModel;
+import org.gatein.mop.api.workspace.Navigation;
+import org.gatein.mop.api.workspace.ObjectType;
+import org.gatein.mop.api.workspace.Page;
+import org.gatein.mop.api.workspace.Site;
+import org.gatein.mop.api.workspace.Workspace;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SiteTypeReadResource extends AbstractMopOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Workspace workspace, ObjectType<Site> siteType) throws ResourceNotFoundException,
OperationException
+ {
+ Collection<Site> sites = workspace.getSites(siteType);
+ Set<String> children = new LinkedHashSet<String>(sites.size());
+ for (Site site : sites)
+ {
+ boolean pageOrNav = false;
+ Page pages = site.getRootPage().getChild("pages");
+ if (pages != null && !pages.getChildren().isEmpty())
+ {
+ pageOrNav = true;
+ }
+ Navigation defaultNav = site.getRootNavigation().getChild("default");
+ if (defaultNav != null && !defaultNav.getChildren().isEmpty())
+ {
+ pageOrNav = true;
+ }
+
+ //TODO: Until invalid site entries without a leading slash is corrected, this is
needed to ignore them.
+ if (siteType == ObjectType.GROUP_SITE)
+ {
+ String name = site.getName();
+ if (name.charAt(0) == '/' && pageOrNav)
+ {
+ children.add(site.getName());
+ }
+ }
+ else if (pageOrNav)
+ {
+ children.add(site.getName());
+ }
+ }
+ resultHandler.completed(new ReadResourceModel("Available sites for site type
'" + getSiteType(siteType).getName() + "'", children));
+ }
+}
Copied:
portal/trunk/component/portal/src/main/resources/META-INF/services/org.gatein.management.spi.ManagementExtension
(from rev 6958,
portal/branches/gatein-management/component/portal/src/main/resources/META-INF/services/org.gatein.management.spi.ManagementExtension)
===================================================================
---
portal/trunk/component/portal/src/main/resources/META-INF/services/org.gatein.management.spi.ManagementExtension
(rev 0)
+++
portal/trunk/component/portal/src/main/resources/META-INF/services/org.gatein.management.spi.ManagementExtension 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1 @@
+org.exoplatform.portal.mop.management.MopManagementExtension
\ No newline at end of file
Deleted:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshallerTest.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshallerTest.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshallerTest.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,169 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.binding.xml;
-
-import junit.framework.TestCase;
-import org.exoplatform.portal.config.model.Application;
-import org.exoplatform.portal.config.model.ApplicationState;
-import org.exoplatform.portal.config.model.Container;
-import org.exoplatform.portal.config.model.ModelObject;
-import org.exoplatform.portal.config.model.PageBody;
-import org.exoplatform.portal.config.model.TransientApplicationState;
-import org.exoplatform.portal.pom.data.ApplicationData;
-import org.exoplatform.portal.pom.data.ContainerData;
-import org.exoplatform.portal.pom.spi.gadget.Gadget;
-import org.exoplatform.portal.pom.spi.portlet.Portlet;
-import org.exoplatform.portal.pom.spi.portlet.Preference;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public abstract class AbstractMarshallerTest extends TestCase
-{
- protected void compareComponents(List<ModelObject> expectedComponents,
List<ModelObject> actualComponents)
- {
- assertEquals(expectedComponents.size(), actualComponents.size());
- for (int i=0; i<expectedComponents.size(); i++)
- {
- ModelObject expected = expectedComponents.get(i);
- ModelObject actual = actualComponents.get(i);
- assertEquals(expected.getClass(), actual.getClass());
-
- if (expected instanceof Application)
- {
- compareApplication((Application) expected, (Application) actual);
- }
- else if (expected instanceof PageBody)
- {
- assertTrue(actual instanceof PageBody);
- }
- else if (expected instanceof Container)
- {
- compareContainer((Container) expected, (Container) actual);
- }
- }
- }
-
- protected void compareContainer(Container expected, Container actual)
- {
- assertNull(actual.getStorageId());
- assertNull(actual.getStorageName());
- assertEquals(expected.getId(), actual.getId());
- assertEquals(expected.getName(), actual.getName());
- assertEquals(expected.getIcon(), actual.getIcon());
- assertEquals(expected.getTemplate(), actual.getTemplate());
- assertEquals(expected.getFactoryId(), actual.getFactoryId());
- assertEquals(expected.getTitle(), actual.getTitle());
- assertEquals(expected.getDescription(), actual.getDescription());
- assertEquals(expected.getWidth(), actual.getWidth());
- assertEquals(expected.getHeight(), actual.getHeight());
- assertEquals(Arrays.asList(expected.getAccessPermissions()),
Arrays.asList(actual.getAccessPermissions()));
-
- compareComponents(expected.getChildren(), actual.getChildren());
- }
-
- protected void compareApplication(Application expected, Application actual)
- {
- assertNull(actual.getStorageId());
- assertNull(actual.getStorageName());
- assertEquals(expected.getType(), actual.getType());
- if (expected.getState() == null)
- {
- assertNull(actual.getState());
- }
- else
- {
- assertNotNull(actual.getState());
- compareApplicationState(expected.getState(), actual.getState());
- }
-
- assertNull(actual.getStorageId());
- assertNull(actual.getStorageName());
- assertNull(actual.getId());
- assertEquals(expected.getTitle(), actual.getTitle());
- assertEquals(expected.getIcon(), actual.getIcon());
- assertEquals(expected.getDescription(), actual.getDescription());
- assertEquals(expected.getShowInfoBar(), actual.getShowInfoBar());
- assertEquals(expected.getShowApplicationState(),
actual.getShowApplicationState());
- assertEquals(expected.getShowApplicationMode(), actual.getShowApplicationMode());
- assertEquals(expected.getTheme(), actual.getTheme());
- assertEquals(expected.getWidth(), actual.getWidth());
- assertEquals(expected.getHeight(), actual.getHeight());
- assertEquals(expected.getProperties(), actual.getProperties());
- assertEquals(Arrays.asList(expected.getAccessPermissions()),
Arrays.asList(actual.getAccessPermissions()));
- }
-
- protected void compareApplicationState(ApplicationState expected, ApplicationState
actual)
- {
- assertEquals(expected.getClass(), actual.getClass());
- if (expected instanceof TransientApplicationState)
- {
- TransientApplicationState expectedTas = (TransientApplicationState) expected;
- TransientApplicationState actualTas = (TransientApplicationState) actual;
- assertEquals(expectedTas.getContentId(), actualTas.getContentId());
- assertNull(actualTas.getOwnerType());
- assertNull(actualTas.getOwnerId());
- assertNull(actualTas.getUniqueId());
- if (expectedTas.getContentState() == null)
- {
- assertNull(actualTas.getContentState());
- }
- else
- {
- assertEquals(expectedTas.getContentState().getClass(),
actualTas.getContentState().getClass());
- if (expectedTas.getContentState() instanceof Portlet)
- {
- comparePortlet((Portlet) expectedTas.getContentState(), (Portlet)
actualTas.getContentState());
- }
- else if (expectedTas.getContentState() instanceof Gadget)
- {
- compareGadget((Gadget) expectedTas.getContentState(), (Gadget)
actualTas.getContentState());
- }
- }
- }
- }
-
- protected void comparePortlet(Portlet expected, Portlet actual)
- {
- for (Preference expectedPref : expected)
- {
- Preference actualPref = actual.getPreference(expectedPref.getName());
- assertNotNull(actualPref);
- assertEquals(expectedPref.getName(), actualPref.getName());
- assertEquals(expectedPref.getValues(), actualPref.getValues());
- assertEquals(expectedPref.isReadOnly(), actualPref.isReadOnly());
- }
- }
-
- private void compareGadget(Gadget expected, Gadget actual)
- {
- assertNotNull(expected);
- assertNotNull(actual);
- // When gadget user prefs are supported in gatein_objects, uncomment.
- //assertEquals(expected.getUserPref(), actual.getUserPref());
- }
-}
Copied:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshallerTest.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshallerTest.java)
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshallerTest.java
(rev 0)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/AbstractMarshallerTest.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,169 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.binding.xml;
+
+import junit.framework.TestCase;
+import org.exoplatform.portal.config.model.Application;
+import org.exoplatform.portal.config.model.ApplicationState;
+import org.exoplatform.portal.config.model.Container;
+import org.exoplatform.portal.config.model.ModelObject;
+import org.exoplatform.portal.config.model.PageBody;
+import org.exoplatform.portal.config.model.TransientApplicationState;
+import org.exoplatform.portal.pom.data.ApplicationData;
+import org.exoplatform.portal.pom.data.ContainerData;
+import org.exoplatform.portal.pom.spi.gadget.Gadget;
+import org.exoplatform.portal.pom.spi.portlet.Portlet;
+import org.exoplatform.portal.pom.spi.portlet.Preference;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class AbstractMarshallerTest extends TestCase
+{
+ protected void compareComponents(List<ModelObject> expectedComponents,
List<ModelObject> actualComponents)
+ {
+ assertEquals(expectedComponents.size(), actualComponents.size());
+ for (int i=0; i<expectedComponents.size(); i++)
+ {
+ ModelObject expected = expectedComponents.get(i);
+ ModelObject actual = actualComponents.get(i);
+ assertEquals(expected.getClass(), actual.getClass());
+
+ if (expected instanceof Application)
+ {
+ compareApplication((Application) expected, (Application) actual);
+ }
+ else if (expected instanceof PageBody)
+ {
+ assertTrue(actual instanceof PageBody);
+ }
+ else if (expected instanceof Container)
+ {
+ compareContainer((Container) expected, (Container) actual);
+ }
+ }
+ }
+
+ protected void compareContainer(Container expected, Container actual)
+ {
+ assertNull(actual.getStorageId());
+ assertNull(actual.getStorageName());
+ assertEquals(expected.getId(), actual.getId());
+ assertEquals(expected.getName(), actual.getName());
+ assertEquals(expected.getIcon(), actual.getIcon());
+ assertEquals(expected.getTemplate(), actual.getTemplate());
+ assertEquals(expected.getFactoryId(), actual.getFactoryId());
+ assertEquals(expected.getTitle(), actual.getTitle());
+ assertEquals(expected.getDescription(), actual.getDescription());
+ assertEquals(expected.getWidth(), actual.getWidth());
+ assertEquals(expected.getHeight(), actual.getHeight());
+ assertEquals(Arrays.asList(expected.getAccessPermissions()),
Arrays.asList(actual.getAccessPermissions()));
+
+ compareComponents(expected.getChildren(), actual.getChildren());
+ }
+
+ protected void compareApplication(Application expected, Application actual)
+ {
+ assertNull(actual.getStorageId());
+ assertNull(actual.getStorageName());
+ assertEquals(expected.getType(), actual.getType());
+ if (expected.getState() == null)
+ {
+ assertNull(actual.getState());
+ }
+ else
+ {
+ assertNotNull(actual.getState());
+ compareApplicationState(expected.getState(), actual.getState());
+ }
+
+ assertNull(actual.getStorageId());
+ assertNull(actual.getStorageName());
+ assertNull(actual.getId());
+ assertEquals(expected.getTitle(), actual.getTitle());
+ assertEquals(expected.getIcon(), actual.getIcon());
+ assertEquals(expected.getDescription(), actual.getDescription());
+ assertEquals(expected.getShowInfoBar(), actual.getShowInfoBar());
+ assertEquals(expected.getShowApplicationState(),
actual.getShowApplicationState());
+ assertEquals(expected.getShowApplicationMode(), actual.getShowApplicationMode());
+ assertEquals(expected.getTheme(), actual.getTheme());
+ assertEquals(expected.getWidth(), actual.getWidth());
+ assertEquals(expected.getHeight(), actual.getHeight());
+ assertEquals(expected.getProperties(), actual.getProperties());
+ assertEquals(Arrays.asList(expected.getAccessPermissions()),
Arrays.asList(actual.getAccessPermissions()));
+ }
+
+ protected void compareApplicationState(ApplicationState expected, ApplicationState
actual)
+ {
+ assertEquals(expected.getClass(), actual.getClass());
+ if (expected instanceof TransientApplicationState)
+ {
+ TransientApplicationState expectedTas = (TransientApplicationState) expected;
+ TransientApplicationState actualTas = (TransientApplicationState) actual;
+ assertEquals(expectedTas.getContentId(), actualTas.getContentId());
+ assertNull(actualTas.getOwnerType());
+ assertNull(actualTas.getOwnerId());
+ assertNull(actualTas.getUniqueId());
+ if (expectedTas.getContentState() == null)
+ {
+ assertNull(actualTas.getContentState());
+ }
+ else
+ {
+ assertEquals(expectedTas.getContentState().getClass(),
actualTas.getContentState().getClass());
+ if (expectedTas.getContentState() instanceof Portlet)
+ {
+ comparePortlet((Portlet) expectedTas.getContentState(), (Portlet)
actualTas.getContentState());
+ }
+ else if (expectedTas.getContentState() instanceof Gadget)
+ {
+ compareGadget((Gadget) expectedTas.getContentState(), (Gadget)
actualTas.getContentState());
+ }
+ }
+ }
+ }
+
+ protected void comparePortlet(Portlet expected, Portlet actual)
+ {
+ for (Preference expectedPref : expected)
+ {
+ Preference actualPref = actual.getPreference(expectedPref.getName());
+ assertNotNull(actualPref);
+ assertEquals(expectedPref.getName(), actualPref.getName());
+ assertEquals(expectedPref.getValues(), actualPref.getValues());
+ assertEquals(expectedPref.isReadOnly(), actualPref.isReadOnly());
+ }
+ }
+
+ private void compareGadget(Gadget expected, Gadget actual)
+ {
+ assertNotNull(expected);
+ assertNotNull(actual);
+ // When gadget user prefs are supported in gatein_objects, uncomment.
+ //assertEquals(expected.getUserPref(), actual.getUserPref());
+ }
+}
Deleted:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshallerTest.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshallerTest.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshallerTest.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,323 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.binding.xml;
-
-import junit.framework.TestCase;
-import org.exoplatform.portal.config.model.I18NString;
-import org.exoplatform.portal.config.model.LocalizedString;
-import org.exoplatform.portal.config.model.NavigationFragment;
-import org.exoplatform.portal.config.model.PageNavigation;
-import org.exoplatform.portal.config.model.PageNode;
-import org.exoplatform.portal.mop.Visibility;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Locale;
-import java.util.TimeZone;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class NavigationMarshallerTest extends TestCase
-{
- public void testNavigationUnmarshalling()
- {
- NavigationMarshaller marshaller = new NavigationMarshaller();
- PageNavigation data =
marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/navigation.xml"));
- assertNotNull(data);
- assertEquals(111, data.getPriority());
- assertNotNull(data.getFragment());
- assertEquals(7, data.getFragment().getNodes().size());
- PageNode node = data.getFragment().getNodes().get(0);
- verifyNode(node, "home", "#{portal.classic.home}",
"home", Visibility.DISPLAYED, "portal::classic::homepage", null, null,
null, 1);
- node = node.getNodes().get(0);
- Date start = createDate(2011, 1, 10, 12, 13, 55);
- Date end = createDate(2011, 1, 17, 17, 14, 0);
- verifyNode(node, "home-1", "Home 1", "home/home-1",
Visibility.TEMPORAL, null, start, end, "StarAward", 1);
- node = node.getNodes().get(0);
- verifyNode(node, "empty", "Empty",
"home/home-1/empty", Visibility.HIDDEN, "portal::classic::empty-page",
null, null, null, 0);
-
- node = data.getFragment().getNodes().get(5);
- verifyNode(node, "notfound", "NotFound", "notfound",
Visibility.SYSTEM, null, null, null, null, 0);
-
- node = data.getFragment().getNodes().get(6);
- verifyNode(node, "n0", "n0", "n0",
Visibility.DISPLAYED, "portal::classic::n0", null, null, null, 1);
- node = node.getNodes().get(0);
- verifyNode(node, "n0", "n0", "n0/n0",
Visibility.DISPLAYED, "portal::classic::n0_n0", null, null, null, 10);
- for (int i=0; i<10; i++)
- {
- String name = "n" + i;
- String uri = "n0/n0/n" + i;
- String pageref = uri.replace("/", "_");
-
- PageNode child = node.getNodes().get(i);
- verifyNode(child, name, name, uri, Visibility.DISPLAYED,
"portal::classic::" + pageref, null, null, null, 0);
- }
- }
-
- public void testEmptyNavigationUnmarshalling()
- {
- NavigationMarshaller marshaller = new NavigationMarshaller();
- PageNavigation data =
marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/navigation-empty.xml"));
- assertNotNull(data);
- assertEquals(3, data.getPriority());
- assertNotNull(data.getFragment().getNodes());
- assertTrue(data.getFragment().getNodes().isEmpty());
- }
-
- public void testFragmentedNavigationUnmarshalling()
- {
- NavigationMarshaller marshaller = new NavigationMarshaller();
- PageNavigation data =
marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/navigation-fragment.xml"));
- assertNotNull(data);
- assertNotNull(data.getFragments());
- assertEquals(2, data.getFragments().size());
-
- NavigationFragment fragment = data.getFragments().get(0);
- assertNotNull(fragment);
- assertEquals("home", fragment.getParentURI());
- assertNotNull(fragment.getNodes());
- assertEquals(1, fragment.getNodes().size());
- PageNode node = fragment.getNode("home-1");
- assertNotNull(node);
- assertNotNull(node.getNodes());
- assertEquals(2, node.getNodes().size());
- assertNotNull(node.getNode("home-1-1"));
- assertNotNull(node.getNode("home-1-2"));
-
- fragment = data.getFragments().get(1);
- assertNotNull(fragment);
- assertEquals("foo-bar", fragment.getParentURI());
- assertNotNull(fragment.getNodes());
- assertEquals(2, fragment.getNodes().size());
- assertNotNull(fragment.getNode("foo"));
- assertNotNull(fragment.getNode("bar"));
- }
-
- public void testLocaleNavigationUnmarshalling()
- {
- NavigationMarshaller marshaller = new NavigationMarshaller();
- PageNavigation data =
marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/navigation-extended.xml"));
- assertNotNull(data);
- assertNotNull(data.getFragment().getNodes());
-
- PageNode node = data.getFragment().getNode("hello-node");
- assertNotNull(node);
- assertNotNull(node.getLabels());
- assertEquals(8, node.getLabels().size());
-
- Locale locale = Locale.getDefault();
-
- String cn = "Dobrý den";
- String fr = "Bonjour";
- String en = "Hello";
- String es = "Hola";
- String ja = "こんにちは";
- String it = "Ciào";
- String zh = "你好";
- String zh_tw = "Li-ho";
-
- assertEquals(cn, node.getLabels().getExtended(locale).get(new
Locale("cn")));
- assertEquals(fr, node.getLabels().getExtended(locale).get(new
Locale("fr")));
- assertEquals(en, node.getLabels().getExtended(locale).get(new
Locale("en")));
- assertEquals(es, node.getLabels().getExtended(locale).get(new
Locale("es")));
- assertEquals(ja, node.getLabels().getExtended(locale).get(new
Locale("ja")));
- assertEquals(it, node.getLabels().getExtended(locale).get(new
Locale("it")));
- assertEquals(zh, node.getLabels().getExtended(locale).get(new
Locale("zh")));
- assertEquals(zh_tw, node.getLabels().getExtended(locale).get(Locale.TAIWAN));
-
- node = data.getFragment().getNode("hello-node2");
- assertNotNull(node);
- assertNotNull(node.getLabels());
- assertEquals(8, node.getLabels().size());
-
- assertEquals(cn, node.getLabels().getExtended(locale).get(new
Locale("cn")));
- assertEquals(fr, node.getLabels().getExtended(locale).get(new
Locale("fr")));
- assertEquals(en, node.getLabels().getExtended(locale).get(new
Locale("en")));
- assertEquals(es, node.getLabels().getExtended(locale).get(new
Locale("es")));
- assertEquals(ja, node.getLabels().getExtended(locale).get(new
Locale("ja")));
- assertEquals(it, node.getLabels().getExtended(locale).get(new
Locale("it")));
- assertEquals(zh, node.getLabels().getExtended(locale).get(new
Locale("zh")));
- assertEquals(zh_tw, node.getLabels().getExtended(locale).get(Locale.TAIWAN));
- }
-
- public void testNavigationMarshalling()
- {
- Calendar startCal = Calendar.getInstance();
- startCal.set(Calendar.MILLISECOND, 0);
- Date start = startCal.getTime();
- Calendar endCal = Calendar.getInstance();
- endCal.set(Calendar.MILLISECOND, 0);
- Date end = endCal.getTime();
-
- PageNode expectedChild1 = newPageNode("node-1", "Icon-1",
"Node 1",
- null, null, Visibility.DISPLAYED, null, new ArrayList<PageNode>());
-
- I18NString labels = new I18NString(
- new LocalizedString("Node 2", Locale.ENGLISH),
- new LocalizedString("Node 2", Locale.FRENCH),
- new LocalizedString("Node 2", Locale.TAIWAN));
-
- PageNode expectedChild2 = newPageNode("node-2", "Icon-2",
labels,
- createDate(2011, 7, 22, 10, 10, 10), createDate(2011, 7, 30, 12, 0, 0),
Visibility.SYSTEM, "some:page:ref", new ArrayList<PageNode>());
-
- ArrayList<PageNode> children = new ArrayList<PageNode>(2);
- children.add(expectedChild1);
- children.add(expectedChild2);
-
- PageNode expectedNode = newPageNode("node", "Icon",
"Node", start, end, Visibility.HIDDEN, "page-ref", children);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- NavigationMarshaller marshaller = new NavigationMarshaller();
- PageNavigation expected = newPageNavigation("", "", 123, new
ArrayList<PageNode>(Collections.singletonList(expectedNode)));
- marshaller.marshal(expected, baos);
-
- PageNavigation actual = marshaller.unmarshal(new
ByteArrayInputStream(baos.toByteArray()));
-
- assertNotNull(actual);
- assertNull(actual.getOwnerType());
- assertNull(actual.getOwnerId());
- assertEquals(expected.getPriority(), actual.getPriority());
- assertNotNull(expected.getFragment().getNodes());
- assertEquals(expected.getFragment().getNodes().size(),
actual.getFragment().getNodes().size());
-
- PageNode actualNode = actual.getFragment().getNodes().get(0);
- compareNode(expectedNode, actualNode);
-
- assertNotNull(actualNode.getNodes());
- assertEquals(expectedNode.getNodes().size(), actualNode.getNodes().size());
- compareNode(expectedChild1, actualNode.getNodes().get(0));
- compareNode(expectedChild2, actualNode.getNodes().get(1));
- }
-
- private PageNavigation newPageNavigation(String ownerType, String ownerId, int
priority, ArrayList<PageNode> children)
- {
- PageNavigation pageNavigation = new PageNavigation();
- pageNavigation.setOwnerType(ownerType);
- pageNavigation.setOwnerId(ownerId);
- pageNavigation.setPriority(priority);
- NavigationFragment fragment = new NavigationFragment();
- fragment.setNodes(children);
- pageNavigation.addFragment(fragment);
-
- return pageNavigation;
- }
-
- private void verifyNode(PageNode node, String name, String label, String uri,
Visibility visibility,
- String pageRef, Date start, Date end, String icon, int
children)
- {
- assertNotNull(node);
- assertEquals(name, node.getName());
- assertEquals(label, node.getLabel());
- assertEquals(visibility, node.getVisibility());
- assertEquals(pageRef, node.getPageReference());
- assertEquals(start, node.getStartPublicationDate());
- assertEquals(end, node.getEndPublicationDate());
- assertEquals(icon, node.getIcon());
- assertNotNull(node.getNodes());
- assertEquals(children, node.getNodes().size());
- }
-
- private void compareNode(PageNode expected, PageNode actual)
- {
- if (expected.getLabel() != null)
- {
- assertEquals(expected.getLabel(), actual.getLabel());
- }
- else if (expected.getLabels() != null)
- {
- assertNotNull(actual.getLabels());
- assertEquals(actual.getLabels().size(), expected.getLabels().size());
-
- for (int i=0; i<actual.getLabels().size(); i++)
- {
- LocalizedString actualLocalizedString = expected.getLabels().get(i);
- LocalizedString expectedLocalizedString = expected.getLabels().get(i);
- assertEquals(actualLocalizedString.getValue(),
expectedLocalizedString.getValue());
- assertEquals(actualLocalizedString.getLang(),
expectedLocalizedString.getLang());
- }
- }
- else
- {
- assertNull(actual.getLabel());
- assertNull(actual.getLabels());
- }
-
- assertEquals(expected.getIcon(), actual.getIcon());
- assertEquals(expected.getName(), actual.getName());
- assertEquals(expected.getStartPublicationDate(),
actual.getStartPublicationDate());
- assertEquals(expected.getEndPublicationDate(), actual.getEndPublicationDate());
- assertEquals(expected.getVisibility(), actual.getVisibility());
- assertEquals(expected.getPageReference(), actual.getPageReference());
- assertEquals(expected.getNodes().size(), actual.getNodes().size());
- }
-
- private Date createDate(int year, int month, int day, int hour, int minute, int
seconds)
- {
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("US/Eastern"));
- cal.set(Calendar.YEAR, year);
- cal.set(Calendar.MONTH, month-1);
- cal.set(Calendar.DAY_OF_MONTH, day);
- cal.set(Calendar.HOUR_OF_DAY, hour);
- cal.set(Calendar.MINUTE, minute);
- cal.set(Calendar.SECOND, seconds);
- cal.set(Calendar.MILLISECOND, 0);
-
- return cal.getTime();
- }
-
- private PageNode newPageNode(String name, String icon, String label, Date start, Date
end, Visibility visibility, String pageref, ArrayList<PageNode> pageNodes)
- {
- PageNode pageNode = new PageNode();
- pageNode.setName(name);
- pageNode.setIcon(icon);
- pageNode.setLabel(label);
- pageNode.setStartPublicationDate(start);
- pageNode.setEndPublicationDate(end);
- pageNode.setVisibility(visibility);
- pageNode.setPageReference(pageref);
- pageNode.setChildren(pageNodes);
-
- return pageNode;
- }
-
- private PageNode newPageNode(String name, String icon, I18NString labels, Date start,
Date end, Visibility visibility, String pageref, ArrayList<PageNode> pageNodes)
- {
- PageNode pageNode = new PageNode();
- pageNode.setName(name);
- pageNode.setIcon(icon);
- pageNode.setLabels(labels);
- pageNode.setStartPublicationDate(start);
- pageNode.setEndPublicationDate(end);
- pageNode.setVisibility(visibility);
- pageNode.setPageReference(pageref);
- pageNode.setChildren(pageNodes);
-
- return pageNode;
- }
-}
Copied:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshallerTest.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshallerTest.java)
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshallerTest.java
(rev 0)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshallerTest.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,323 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.binding.xml;
+
+import junit.framework.TestCase;
+import org.exoplatform.portal.config.model.I18NString;
+import org.exoplatform.portal.config.model.LocalizedString;
+import org.exoplatform.portal.config.model.NavigationFragment;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PageNode;
+import org.exoplatform.portal.mop.Visibility;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationMarshallerTest extends TestCase
+{
+ public void testNavigationUnmarshalling()
+ {
+ NavigationMarshaller marshaller = new NavigationMarshaller();
+ PageNavigation data =
marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/navigation.xml"));
+ assertNotNull(data);
+ assertEquals(111, data.getPriority());
+ assertNotNull(data.getFragment());
+ assertEquals(7, data.getFragment().getNodes().size());
+ PageNode node = data.getFragment().getNodes().get(0);
+ verifyNode(node, "home", "#{portal.classic.home}",
"home", Visibility.DISPLAYED, "portal::classic::homepage", null, null,
null, 1);
+ node = node.getNodes().get(0);
+ Date start = createDate(2011, 1, 10, 12, 13, 55);
+ Date end = createDate(2011, 1, 17, 17, 14, 0);
+ verifyNode(node, "home-1", "Home 1", "home/home-1",
Visibility.TEMPORAL, null, start, end, "StarAward", 1);
+ node = node.getNodes().get(0);
+ verifyNode(node, "empty", "Empty",
"home/home-1/empty", Visibility.HIDDEN, "portal::classic::empty-page",
null, null, null, 0);
+
+ node = data.getFragment().getNodes().get(5);
+ verifyNode(node, "notfound", "NotFound", "notfound",
Visibility.SYSTEM, null, null, null, null, 0);
+
+ node = data.getFragment().getNodes().get(6);
+ verifyNode(node, "n0", "n0", "n0",
Visibility.DISPLAYED, "portal::classic::n0", null, null, null, 1);
+ node = node.getNodes().get(0);
+ verifyNode(node, "n0", "n0", "n0/n0",
Visibility.DISPLAYED, "portal::classic::n0_n0", null, null, null, 10);
+ for (int i=0; i<10; i++)
+ {
+ String name = "n" + i;
+ String uri = "n0/n0/n" + i;
+ String pageref = uri.replace("/", "_");
+
+ PageNode child = node.getNodes().get(i);
+ verifyNode(child, name, name, uri, Visibility.DISPLAYED,
"portal::classic::" + pageref, null, null, null, 0);
+ }
+ }
+
+ public void testEmptyNavigationUnmarshalling()
+ {
+ NavigationMarshaller marshaller = new NavigationMarshaller();
+ PageNavigation data =
marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/navigation-empty.xml"));
+ assertNotNull(data);
+ assertEquals(3, data.getPriority());
+ assertNotNull(data.getFragment().getNodes());
+ assertTrue(data.getFragment().getNodes().isEmpty());
+ }
+
+ public void testFragmentedNavigationUnmarshalling()
+ {
+ NavigationMarshaller marshaller = new NavigationMarshaller();
+ PageNavigation data =
marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/navigation-fragment.xml"));
+ assertNotNull(data);
+ assertNotNull(data.getFragments());
+ assertEquals(2, data.getFragments().size());
+
+ NavigationFragment fragment = data.getFragments().get(0);
+ assertNotNull(fragment);
+ assertEquals("home", fragment.getParentURI());
+ assertNotNull(fragment.getNodes());
+ assertEquals(1, fragment.getNodes().size());
+ PageNode node = fragment.getNode("home-1");
+ assertNotNull(node);
+ assertNotNull(node.getNodes());
+ assertEquals(2, node.getNodes().size());
+ assertNotNull(node.getNode("home-1-1"));
+ assertNotNull(node.getNode("home-1-2"));
+
+ fragment = data.getFragments().get(1);
+ assertNotNull(fragment);
+ assertEquals("foo-bar", fragment.getParentURI());
+ assertNotNull(fragment.getNodes());
+ assertEquals(2, fragment.getNodes().size());
+ assertNotNull(fragment.getNode("foo"));
+ assertNotNull(fragment.getNode("bar"));
+ }
+
+ public void testLocaleNavigationUnmarshalling()
+ {
+ NavigationMarshaller marshaller = new NavigationMarshaller();
+ PageNavigation data =
marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/navigation-extended.xml"));
+ assertNotNull(data);
+ assertNotNull(data.getFragment().getNodes());
+
+ PageNode node = data.getFragment().getNode("hello-node");
+ assertNotNull(node);
+ assertNotNull(node.getLabels());
+ assertEquals(8, node.getLabels().size());
+
+ Locale locale = Locale.getDefault();
+
+ String cn = "Dobrý den";
+ String fr = "Bonjour";
+ String en = "Hello";
+ String es = "Hola";
+ String ja = "こんにちは";
+ String it = "Ciào";
+ String zh = "你好";
+ String zh_tw = "Li-ho";
+
+ assertEquals(cn, node.getLabels().getExtended(locale).get(new
Locale("cn")));
+ assertEquals(fr, node.getLabels().getExtended(locale).get(new
Locale("fr")));
+ assertEquals(en, node.getLabels().getExtended(locale).get(new
Locale("en")));
+ assertEquals(es, node.getLabels().getExtended(locale).get(new
Locale("es")));
+ assertEquals(ja, node.getLabels().getExtended(locale).get(new
Locale("ja")));
+ assertEquals(it, node.getLabels().getExtended(locale).get(new
Locale("it")));
+ assertEquals(zh, node.getLabels().getExtended(locale).get(new
Locale("zh")));
+ assertEquals(zh_tw, node.getLabels().getExtended(locale).get(Locale.TAIWAN));
+
+ node = data.getFragment().getNode("hello-node2");
+ assertNotNull(node);
+ assertNotNull(node.getLabels());
+ assertEquals(8, node.getLabels().size());
+
+ assertEquals(cn, node.getLabels().getExtended(locale).get(new
Locale("cn")));
+ assertEquals(fr, node.getLabels().getExtended(locale).get(new
Locale("fr")));
+ assertEquals(en, node.getLabels().getExtended(locale).get(new
Locale("en")));
+ assertEquals(es, node.getLabels().getExtended(locale).get(new
Locale("es")));
+ assertEquals(ja, node.getLabels().getExtended(locale).get(new
Locale("ja")));
+ assertEquals(it, node.getLabels().getExtended(locale).get(new
Locale("it")));
+ assertEquals(zh, node.getLabels().getExtended(locale).get(new
Locale("zh")));
+ assertEquals(zh_tw, node.getLabels().getExtended(locale).get(Locale.TAIWAN));
+ }
+
+ public void testNavigationMarshalling()
+ {
+ Calendar startCal = Calendar.getInstance();
+ startCal.set(Calendar.MILLISECOND, 0);
+ Date start = startCal.getTime();
+ Calendar endCal = Calendar.getInstance();
+ endCal.set(Calendar.MILLISECOND, 0);
+ Date end = endCal.getTime();
+
+ PageNode expectedChild1 = newPageNode("node-1", "Icon-1",
"Node 1",
+ null, null, Visibility.DISPLAYED, null, new ArrayList<PageNode>());
+
+ I18NString labels = new I18NString(
+ new LocalizedString("Node 2", Locale.ENGLISH),
+ new LocalizedString("Node 2", Locale.FRENCH),
+ new LocalizedString("Node 2", Locale.TAIWAN));
+
+ PageNode expectedChild2 = newPageNode("node-2", "Icon-2",
labels,
+ createDate(2011, 7, 22, 10, 10, 10), createDate(2011, 7, 30, 12, 0, 0),
Visibility.SYSTEM, "some:page:ref", new ArrayList<PageNode>());
+
+ ArrayList<PageNode> children = new ArrayList<PageNode>(2);
+ children.add(expectedChild1);
+ children.add(expectedChild2);
+
+ PageNode expectedNode = newPageNode("node", "Icon",
"Node", start, end, Visibility.HIDDEN, "page-ref", children);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ NavigationMarshaller marshaller = new NavigationMarshaller();
+ PageNavigation expected = newPageNavigation("", "", 123, new
ArrayList<PageNode>(Collections.singletonList(expectedNode)));
+ marshaller.marshal(expected, baos);
+
+ PageNavigation actual = marshaller.unmarshal(new
ByteArrayInputStream(baos.toByteArray()));
+
+ assertNotNull(actual);
+ assertNull(actual.getOwnerType());
+ assertNull(actual.getOwnerId());
+ assertEquals(expected.getPriority(), actual.getPriority());
+ assertNotNull(expected.getFragment().getNodes());
+ assertEquals(expected.getFragment().getNodes().size(),
actual.getFragment().getNodes().size());
+
+ PageNode actualNode = actual.getFragment().getNodes().get(0);
+ compareNode(expectedNode, actualNode);
+
+ assertNotNull(actualNode.getNodes());
+ assertEquals(expectedNode.getNodes().size(), actualNode.getNodes().size());
+ compareNode(expectedChild1, actualNode.getNodes().get(0));
+ compareNode(expectedChild2, actualNode.getNodes().get(1));
+ }
+
+ private PageNavigation newPageNavigation(String ownerType, String ownerId, int
priority, ArrayList<PageNode> children)
+ {
+ PageNavigation pageNavigation = new PageNavigation();
+ pageNavigation.setOwnerType(ownerType);
+ pageNavigation.setOwnerId(ownerId);
+ pageNavigation.setPriority(priority);
+ NavigationFragment fragment = new NavigationFragment();
+ fragment.setNodes(children);
+ pageNavigation.addFragment(fragment);
+
+ return pageNavigation;
+ }
+
+ private void verifyNode(PageNode node, String name, String label, String uri,
Visibility visibility,
+ String pageRef, Date start, Date end, String icon, int
children)
+ {
+ assertNotNull(node);
+ assertEquals(name, node.getName());
+ assertEquals(label, node.getLabel());
+ assertEquals(visibility, node.getVisibility());
+ assertEquals(pageRef, node.getPageReference());
+ assertEquals(start, node.getStartPublicationDate());
+ assertEquals(end, node.getEndPublicationDate());
+ assertEquals(icon, node.getIcon());
+ assertNotNull(node.getNodes());
+ assertEquals(children, node.getNodes().size());
+ }
+
+ private void compareNode(PageNode expected, PageNode actual)
+ {
+ if (expected.getLabel() != null)
+ {
+ assertEquals(expected.getLabel(), actual.getLabel());
+ }
+ else if (expected.getLabels() != null)
+ {
+ assertNotNull(actual.getLabels());
+ assertEquals(actual.getLabels().size(), expected.getLabels().size());
+
+ for (int i=0; i<actual.getLabels().size(); i++)
+ {
+ LocalizedString actualLocalizedString = expected.getLabels().get(i);
+ LocalizedString expectedLocalizedString = expected.getLabels().get(i);
+ assertEquals(actualLocalizedString.getValue(),
expectedLocalizedString.getValue());
+ assertEquals(actualLocalizedString.getLang(),
expectedLocalizedString.getLang());
+ }
+ }
+ else
+ {
+ assertNull(actual.getLabel());
+ assertNull(actual.getLabels());
+ }
+
+ assertEquals(expected.getIcon(), actual.getIcon());
+ assertEquals(expected.getName(), actual.getName());
+ assertEquals(expected.getStartPublicationDate(),
actual.getStartPublicationDate());
+ assertEquals(expected.getEndPublicationDate(), actual.getEndPublicationDate());
+ assertEquals(expected.getVisibility(), actual.getVisibility());
+ assertEquals(expected.getPageReference(), actual.getPageReference());
+ assertEquals(expected.getNodes().size(), actual.getNodes().size());
+ }
+
+ private Date createDate(int year, int month, int day, int hour, int minute, int
seconds)
+ {
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("US/Eastern"));
+ cal.set(Calendar.YEAR, year);
+ cal.set(Calendar.MONTH, month-1);
+ cal.set(Calendar.DAY_OF_MONTH, day);
+ cal.set(Calendar.HOUR_OF_DAY, hour);
+ cal.set(Calendar.MINUTE, minute);
+ cal.set(Calendar.SECOND, seconds);
+ cal.set(Calendar.MILLISECOND, 0);
+
+ return cal.getTime();
+ }
+
+ private PageNode newPageNode(String name, String icon, String label, Date start, Date
end, Visibility visibility, String pageref, ArrayList<PageNode> pageNodes)
+ {
+ PageNode pageNode = new PageNode();
+ pageNode.setName(name);
+ pageNode.setIcon(icon);
+ pageNode.setLabel(label);
+ pageNode.setStartPublicationDate(start);
+ pageNode.setEndPublicationDate(end);
+ pageNode.setVisibility(visibility);
+ pageNode.setPageReference(pageref);
+ pageNode.setChildren(pageNodes);
+
+ return pageNode;
+ }
+
+ private PageNode newPageNode(String name, String icon, I18NString labels, Date start,
Date end, Visibility visibility, String pageref, ArrayList<PageNode> pageNodes)
+ {
+ PageNode pageNode = new PageNode();
+ pageNode.setName(name);
+ pageNode.setIcon(icon);
+ pageNode.setLabels(labels);
+ pageNode.setStartPublicationDate(start);
+ pageNode.setEndPublicationDate(end);
+ pageNode.setVisibility(visibility);
+ pageNode.setPageReference(pageref);
+ pageNode.setChildren(pageNodes);
+
+ return pageNode;
+ }
+}
Deleted:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshallerTest.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshallerTest.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshallerTest.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,441 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.binding.xml;
-
-import org.exoplatform.portal.config.model.Application;
-import org.exoplatform.portal.config.model.ApplicationState;
-import org.exoplatform.portal.config.model.ApplicationType;
-import org.exoplatform.portal.config.model.Container;
-import org.exoplatform.portal.config.model.ModelObject;
-import org.exoplatform.portal.config.model.Page;
-import org.exoplatform.portal.config.model.TransientApplicationState;
-import org.exoplatform.portal.pom.config.Utils;
-import org.exoplatform.portal.pom.data.ApplicationData;
-import org.exoplatform.portal.pom.data.ComponentData;
-import org.exoplatform.portal.pom.data.ContainerData;
-import org.exoplatform.portal.pom.data.PageData;
-import org.exoplatform.portal.pom.spi.gadget.Gadget;
-import org.exoplatform.portal.pom.spi.portlet.Portlet;
-import org.exoplatform.portal.pom.spi.portlet.Preference;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PageMarshallerTest extends AbstractMarshallerTest
-{
- public void testHomePageUnMarshalling()
- {
- PageMarshaller marshaller = new PageMarshaller();
- Page.PageSet pages =
marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/pages-homepage.xml"));
- assertNotNull(pages);
- assertNotNull(pages.getPages());
- assertEquals(1, pages.getPages().size());
- Page page = pages.getPages().get(0);
-
- assertEquals("homepage", page.getName());
- assertEquals("Home Page", page.getTitle());
- assertEquals("Everyone", Utils.join(";",
page.getAccessPermissions()));
- assertEquals("*:/platform/administrators", page.getEditPermission());
- assertNotNull(page.getChildren());
- assertEquals(1, page.getChildren().size());
- ModelObject child = page.getChildren().get(0);
- assertTrue(child instanceof Application);
- @SuppressWarnings("unchecked")
- Application<Portlet> application = (Application<Portlet>) child;
- assertTrue(application.getType() == ApplicationType.PORTLET);
- ApplicationState<Portlet> state = application.getState();
- assertNotNull(state);
- assertTrue(state instanceof TransientApplicationState);
- TransientApplicationState<Portlet> tas =
(TransientApplicationState<Portlet>) state;
- assertEquals("web/HomePagePortlet", tas.getContentId());
- Portlet portlet = tas.getContentState();
- int count = 0;
- for (Preference pref : portlet)
- {
- count++;
- }
- assertEquals(1, count);
- Preference pref = portlet.getPreference("template");
- assertNotNull(pref);
- assertEquals("template", pref.getName());
-
assertEquals("system:/templates/groovy/webui/component/UIHomePagePortlet.gtmpl",
pref.getValue());
- assertFalse(pref.isReadOnly());
-
- assertNull(application.getTheme());
- assertEquals("Home Page portlet", application.getTitle());
- assertEquals("Everyone", Utils.join(";",
application.getAccessPermissions()));
- assertFalse(application.getShowInfoBar());
- assertFalse(application.getShowApplicationState());
- assertFalse(application.getShowApplicationMode());
- assertNull(application.getDescription());
- assertNull(application.getIcon());
- assertNull(application.getWidth());
- assertNull(application.getHeight());
- }
-
- public void testLoadedPageUnmarshalling()
- {
- PageMarshaller marshaller = new PageMarshaller();
- Page.PageSet pages =
marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/pages-loaded.xml"));
- assertNotNull(pages);
- assertNotNull(pages.getPages());
- assertEquals(1, pages.getPages().size());
- Page page = pages.getPages().get(0);
-
- // Verify page properties
- assertEquals("loaded-page", page.getName());
- assertEquals("Loaded Page", page.getTitle());
- assertEquals("manager:/platform/administrators;manager:/platform/users",
Utils.join(";", page.getAccessPermissions()));
- assertEquals("*:/platform/administrators", page.getEditPermission());
-
- // Verify page children
- assertNotNull(page.getChildren());
- assertEquals(1, page.getChildren().size());
- ModelObject child = page.getChildren().get(0);
- assertTrue(child instanceof Container);
-
- // Verify root container
- Container rootContainer = (Container) child;
- assertEquals("rootContainer", rootContainer.getId());
- assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl",
rootContainer.getTemplate());
- assertEquals("Everyone", Utils.join(";",
rootContainer.getAccessPermissions()));
-
- // Verify root container children
- List<ModelObject> rootChildren = rootContainer.getChildren();
- assertNotNull(rootChildren);
- assertEquals(3, rootChildren.size());
-
- // Verify container 1
- ModelObject c1 = rootChildren.get(0);
- assertNotNull(c1);
- assertTrue(c1 instanceof ModelObject);
- Container container1 = (Container) c1;
- assertEquals("c1", container1.getId());
- assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl",
container1.getTemplate());
- assertEquals("*:/platform/users", Utils.join(";",
container1.getAccessPermissions()));
- {
- // Verify homepage application
- assertNotNull(container1.getChildren());
- assertEquals(1, container1.getChildren().size());
- ModelObject homeComponent = container1.getChildren().get(0);
- assertTrue(homeComponent instanceof Application);
- @SuppressWarnings("unchecked")
- Application<Portlet> application = (Application<Portlet>)
homeComponent;
- assertTrue(application.getType() == ApplicationType.PORTLET);
- ApplicationState<Portlet> state = application.getState();
- assertNotNull(state);
- assertTrue(state instanceof TransientApplicationState);
- TransientApplicationState<Portlet> tas =
(TransientApplicationState<Portlet>) state;
- assertEquals("web/HomePagePortlet", tas.getContentId());
- Portlet portlet = tas.getContentState();
- int count = 0;
- for (Preference pref : portlet)
- {
- count++;
- }
- assertEquals(3, count);
- Preference pref = portlet.getPreference("template");
- assertNotNull(pref);
- assertEquals("template", pref.getName());
-
assertEquals("system:/templates/groovy/webui/component/UIHomePagePortlet.gtmpl",
pref.getValue());
- assertTrue(pref.isReadOnly());
-
- pref = portlet.getPreference("empty-preference-value");
- assertNotNull(pref);
- assertEquals("empty-preference-value", pref.getName());
- assertNull(pref.getValue());
- assertFalse(pref.isReadOnly());
-
- pref = portlet.getPreference("no-preference-value");
- assertNotNull(pref);
- assertEquals("no-preference-value", pref.getName());
- assertNull(pref.getValue());
- assertFalse(pref.isReadOnly());
-
- assertEquals("Mac:MacTheme::Default:DefaultTheme::Vista:VistaTheme",
application.getTheme());
- assertEquals("Home Page portlet", application.getTitle());
- assertEquals("Everyone", Utils.join(";",
application.getAccessPermissions()));
- assertTrue(application.getShowInfoBar());
- assertTrue(application.getShowApplicationState());
- assertTrue(application.getShowApplicationMode());
- assertNull(application.getDescription());
- assertNull(application.getIcon());
- assertNull(application.getWidth());
- assertNull(application.getHeight());
- }
-
- // Verify container 2
- ModelObject c2 = rootChildren.get(1);
- assertNotNull(c2);
- assertTrue(c2 instanceof Container);
- Container container2 = (Container) c2;
- assertEquals("c2", container2.getId());
-
assertEquals("system:/groovy/portal/webui/container/UITableColumnContainer.gtmpl",
container2.getTemplate());
- assertEquals("*:/platform/guests", Utils.join(";",
container2.getAccessPermissions()));
- assertEquals("TableColumnContainer", container2.getFactoryId());
- assertNotNull(container2.getChildren());
- assertEquals(2, container2.getChildren().size());
-
- {
- // Verify column 1 of container 2
- ModelObject appregComp = container2.getChildren().get(0);
- assertTrue(appregComp instanceof Container);
- Container appregContainer = (Container) appregComp;
- assertEquals("c2-1", appregContainer.getId());
-
assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl",
appregContainer.getTemplate());
- assertEquals("300px", appregContainer.getWidth());
- assertEquals("400px", appregContainer.getHeight());
- assertEquals("Everyone", Utils.join(";",
appregContainer.getAccessPermissions()));
- {
- // Verify app registry application
- assertNotNull(appregContainer.getChildren());
- assertEquals(1, appregContainer.getChildren().size());
- ModelObject appregComponent = appregContainer.getChildren().get(0);
- assertTrue(appregComponent instanceof Application);
- @SuppressWarnings("unchecked")
- Application<Portlet> application = (Application<Portlet>)
appregComponent;
- assertTrue(application.getType() == ApplicationType.PORTLET);
- ApplicationState<Portlet> state = application.getState();
- assertNotNull(state);
- assertTrue(state instanceof TransientApplicationState);
- TransientApplicationState<Portlet> tas =
(TransientApplicationState<Portlet>) state;
- assertEquals("exoadmin/ApplicationRegistryPortlet",
tas.getContentId());
- assertNull(tas.getContentState());
-
-
assertEquals("Default:DefaultTheme::Mac:MacTheme::Vista:VistaTheme",
application.getTheme());
- assertEquals("Application Registry", application.getTitle());
-
assertEquals("*:/platform/administrators;*:/organization/management/executive-board",
Utils.join(";", application.getAccessPermissions()));
- assertFalse(application.getShowInfoBar());
- assertTrue(application.getShowApplicationState());
- assertFalse(application.getShowApplicationMode());
- assertEquals("Application Registry",
application.getDescription());
- assertEquals("PortletIcon", application.getIcon());
- assertEquals("250px", application.getWidth());
- assertEquals("350px", application.getHeight());
- }
-
- // Verify column 2 of container 2
- ModelObject orgComp = container2.getChildren().get(1);
- assertTrue(orgComp instanceof Container);
- Container orgContainer = (Container) orgComp;
- assertEquals("c2-2", orgContainer.getId());
-
assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl",
orgContainer.getTemplate());
- assertEquals("200px", orgContainer.getWidth());
- assertEquals("300px", orgContainer.getHeight());
- assertEquals("/platform/users", Utils.join(";",
orgContainer.getAccessPermissions()));
- {
- // Verify calendar gadget application
- assertNotNull(orgContainer.getChildren());
- assertEquals(1, orgContainer.getChildren().size());
- ModelObject gadgetComponent = orgContainer.getChildren().get(0);
- assertTrue(gadgetComponent instanceof Application);
- @SuppressWarnings("unchecked")
- Application<Gadget> application = (Application<Gadget>)
gadgetComponent;
- assertTrue(application.getType() == ApplicationType.GADGET);
- ApplicationState<Gadget> state = application.getState();
- assertNotNull(state);
- assertTrue(state instanceof TransientApplicationState);
- TransientApplicationState<Gadget> tas =
(TransientApplicationState<Gadget>) state;
- assertEquals("Calendar", tas.getContentId());
- assertNull(tas.getContentState());
-
-
assertEquals("Vista:VistaTheme::Mac:MacTheme::Default:DefaultTheme",
application.getTheme());
- assertEquals("Calendar Title", application.getTitle());
-
assertEquals("*:/platform/administrators;*:/organization/management/executive-board",
Utils.join(";", application.getAccessPermissions()));
- assertTrue(application.getShowInfoBar());
- assertFalse(application.getShowApplicationState());
- assertFalse(application.getShowApplicationMode());
- assertEquals("Calendar Description",
application.getDescription());
- assertEquals("StarAwardIcon", application.getIcon());
- assertEquals("100px", application.getWidth());
- assertEquals("200px", application.getHeight());
- }
- }
-
- // Verify container 3
- ModelObject c3 = rootChildren.get(2);
- assertNotNull(c3);
- assertTrue(c3 instanceof Container);
- Container container3 = (Container) c3;
- assertEquals("c3", container3.getId());
- assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl",
container3.getTemplate());
- assertEquals(container3.getTemplate(),
"system:/groovy/portal/webui/container/UIContainer.gtmpl");
- assertEquals("Everyone", Utils.join(";",
container3.getAccessPermissions()));
- assertNull(container3.getFactoryId());
- {
- // Verify site map application
- assertNotNull(container3.getChildren());
- assertEquals(1, container3.getChildren().size());
- ModelObject sitemapcomponent = container3.getChildren().get(0);
- assertTrue(sitemapcomponent instanceof Application);
- @SuppressWarnings("unchecked")
- Application<Portlet> application = (Application<Portlet>)
sitemapcomponent;
- assertTrue(application.getType() == ApplicationType.PORTLET);
- ApplicationState<Portlet> state = application.getState();
- assertNotNull(state);
- assertTrue(state instanceof TransientApplicationState);
- TransientApplicationState<Portlet> tas =
(TransientApplicationState<Portlet>) state;
- assertEquals("web/SiteMapPortlet", tas.getContentId());
- assertNull(tas.getContentState());
-
- assertEquals("Default:DefaultTheme::Vista:VistaTheme::Mac:MacTheme",
application.getTheme());
- assertEquals("SiteMap", application.getTitle());
- assertEquals("*:/platform/users", Utils.join(";",
application.getAccessPermissions()));
- assertTrue(application.getShowInfoBar());
- assertTrue(application.getShowApplicationState());
- assertFalse(application.getShowApplicationMode());
- assertEquals("SiteMap", application.getDescription());
- assertNull(application.getIcon());
- assertNull(application.getWidth());
- assertNull(application.getHeight());
- }
- }
-
- public void testEmptyPageUnmarshalling()
- {
- PageMarshaller marshaller = new PageMarshaller();
- Page.PageSet pages =
marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/pages-empty.xml"));
- assertNotNull(pages);
- assertNotNull(pages.getPages());
- assertEquals(1, pages.getPages().size());
- Page page = pages.getPages().get(0);
- assertNotNull(page);
- assertEquals("empty-page", page.getName());
- assertEquals("Empty", page.getTitle());
- assertNotNull(page.getChildren());
- assertTrue(page.getChildren().isEmpty());
- }
-
- public void testPageMarshalling()
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- Portlet portlet = new Portlet();
- portlet.putPreference(new Preference("pref-1", "value-1",
true));
- portlet.putPreference(new Preference("pref-2", "value-2",
false));
- portlet.putPreference(new Preference("multi-value-pref",
Arrays.asList("one", "two", "three"), false));
- portlet.putPreference(new Preference("empty-value-pref", (String) null,
true));
-
- ApplicationState<Portlet> state = new
TransientApplicationState<Portlet>("app-ref/portlet-ref", portlet);
- ApplicationData<Portlet> applicationData = new
ApplicationData<Portlet>(null, null,
- ApplicationType.PORTLET, state, null, "app-title",
"app-icon", "app-description", false, true, false,
- "app-theme", "app-wdith", "app-height", new
HashMap<String,String>(),
- Collections.singletonList("app-edit-permissions"));
-
- ContainerData containerData = new ContainerData(null, "cd-id",
"cd-name", "cd-icon", "cd-template",
"cd-factoryId", "cd-title", "cd-description",
"cd-width", "cd-height",
Collections.singletonList("cd-access-permissions"),
Collections.singletonList((ComponentData) applicationData));
- List<ComponentData> children = Collections.singletonList((ComponentData)
containerData);
-
- PageData expectedData = new PageData(null, null, "page-name", null, null,
null, "Page Title", null, null, null,
- Collections.singletonList("access-permissions"), children,
"", "", "edit-permission", true);
-
- Page expected = new Page(expectedData);
-
- Page.PageSet expectedPages = new Page.PageSet();
- expectedPages.setPages(new ArrayList<Page>(1));
- expectedPages.getPages().add(expected);
-
- PageMarshaller marshaller = new PageMarshaller();
- marshaller.marshal(expectedPages, baos);
-
- //System.out.println(baos.toString());
-
- Page.PageSet actualPages = marshaller.unmarshal(new
ByteArrayInputStream(baos.toByteArray()));
-
- assertNotNull(actualPages);
- assertNotNull(actualPages.getPages());
- assertEquals(1, actualPages.getPages().size());
-
- comparePages(expected, actualPages.getPages().get(0));
- }
-
- public void testPageMarshallingWithGadget()
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- Gadget gadget = null;
- //TODO: Uncomment when gadget user-prefs are supported in gatein_objects
- //Gadget gadget = new Gadget();
- //gadget.setUserPref("user-pref");
-
- ApplicationState<Gadget> state = new
TransientApplicationState<Gadget>("gadget-ref", gadget);
- ApplicationData<Gadget> applicationData = new
ApplicationData<Gadget>(null, null,
- ApplicationType.GADGET, state, null, "app-title",
"app-icon", "app-description", false, true, false,
- "app-theme", "app-wdith", "app-height", new
HashMap<String,String>(),
- Collections.singletonList("app-edit-permissions"));
-
- List<ComponentData> children = Collections.singletonList((ComponentData)
applicationData);
- PageData expectedData = new PageData(null, null, "page-name", null, null,
null, "Page Title", null, null, null,
- Collections.singletonList("access-permissions"), children,
"", "", "edit-permission", true);
-
- Page expected = new Page(expectedData);
-
- Page.PageSet expectedPages = new Page.PageSet();
- expectedPages.setPages(new ArrayList<Page>(1));
- expectedPages.getPages().add(expected);
-
- PageMarshaller marshaller = new PageMarshaller();
- marshaller.marshal(expectedPages, baos);
-
- //System.out.println(baos.toString());
-
- Page.PageSet actualPages = marshaller.unmarshal(new
ByteArrayInputStream(baos.toByteArray()));
-
- assertNotNull(actualPages);
- assertNotNull(actualPages.getPages());
- assertEquals(1, actualPages.getPages().size());
-
- comparePages(expected, actualPages.getPages().get(0));
- }
-
- private void comparePages(Page expected, Page actual)
- {
- assertNull(actual.getStorageId());
- assertNull(actual.getStorageName());
- assertNull(actual.getId());
- assertNull(actual.getOwnerType());
- assertNull(actual.getOwnerId());
- assertEquals(expected.getName(), actual.getName());
- assertNull(actual.getIcon());
- assertNull(actual.getTemplate());
- assertNull(actual.getFactoryId());
- assertEquals(expected.getTitle(), actual.getTitle());
- assertNull(actual.getDescription());
- assertNull(actual.getWidth());
- assertNull(actual.getHeight());
- assertEquals(Arrays.asList(expected.getAccessPermissions()),
Arrays.asList(actual.getAccessPermissions()));
-
- compareComponents(expected.getChildren(), actual.getChildren());
-
- assertEquals(expected.getEditPermission(), actual.getEditPermission());
- assertEquals(expected.isShowMaxWindow(), actual.isShowMaxWindow());
- }
-}
Copied:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshallerTest.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshallerTest.java)
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshallerTest.java
(rev 0)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/PageMarshallerTest.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,441 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.binding.xml;
+
+import org.exoplatform.portal.config.model.Application;
+import org.exoplatform.portal.config.model.ApplicationState;
+import org.exoplatform.portal.config.model.ApplicationType;
+import org.exoplatform.portal.config.model.Container;
+import org.exoplatform.portal.config.model.ModelObject;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.config.model.TransientApplicationState;
+import org.exoplatform.portal.pom.config.Utils;
+import org.exoplatform.portal.pom.data.ApplicationData;
+import org.exoplatform.portal.pom.data.ComponentData;
+import org.exoplatform.portal.pom.data.ContainerData;
+import org.exoplatform.portal.pom.data.PageData;
+import org.exoplatform.portal.pom.spi.gadget.Gadget;
+import org.exoplatform.portal.pom.spi.portlet.Portlet;
+import org.exoplatform.portal.pom.spi.portlet.Preference;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageMarshallerTest extends AbstractMarshallerTest
+{
+ public void testHomePageUnMarshalling()
+ {
+ PageMarshaller marshaller = new PageMarshaller();
+ Page.PageSet pages =
marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/pages-homepage.xml"));
+ assertNotNull(pages);
+ assertNotNull(pages.getPages());
+ assertEquals(1, pages.getPages().size());
+ Page page = pages.getPages().get(0);
+
+ assertEquals("homepage", page.getName());
+ assertEquals("Home Page", page.getTitle());
+ assertEquals("Everyone", Utils.join(";",
page.getAccessPermissions()));
+ assertEquals("*:/platform/administrators", page.getEditPermission());
+ assertNotNull(page.getChildren());
+ assertEquals(1, page.getChildren().size());
+ ModelObject child = page.getChildren().get(0);
+ assertTrue(child instanceof Application);
+ @SuppressWarnings("unchecked")
+ Application<Portlet> application = (Application<Portlet>) child;
+ assertTrue(application.getType() == ApplicationType.PORTLET);
+ ApplicationState<Portlet> state = application.getState();
+ assertNotNull(state);
+ assertTrue(state instanceof TransientApplicationState);
+ TransientApplicationState<Portlet> tas =
(TransientApplicationState<Portlet>) state;
+ assertEquals("web/HomePagePortlet", tas.getContentId());
+ Portlet portlet = tas.getContentState();
+ int count = 0;
+ for (Preference pref : portlet)
+ {
+ count++;
+ }
+ assertEquals(1, count);
+ Preference pref = portlet.getPreference("template");
+ assertNotNull(pref);
+ assertEquals("template", pref.getName());
+
assertEquals("system:/templates/groovy/webui/component/UIHomePagePortlet.gtmpl",
pref.getValue());
+ assertFalse(pref.isReadOnly());
+
+ assertNull(application.getTheme());
+ assertEquals("Home Page portlet", application.getTitle());
+ assertEquals("Everyone", Utils.join(";",
application.getAccessPermissions()));
+ assertFalse(application.getShowInfoBar());
+ assertFalse(application.getShowApplicationState());
+ assertFalse(application.getShowApplicationMode());
+ assertNull(application.getDescription());
+ assertNull(application.getIcon());
+ assertNull(application.getWidth());
+ assertNull(application.getHeight());
+ }
+
+ public void testLoadedPageUnmarshalling()
+ {
+ PageMarshaller marshaller = new PageMarshaller();
+ Page.PageSet pages =
marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/pages-loaded.xml"));
+ assertNotNull(pages);
+ assertNotNull(pages.getPages());
+ assertEquals(1, pages.getPages().size());
+ Page page = pages.getPages().get(0);
+
+ // Verify page properties
+ assertEquals("loaded-page", page.getName());
+ assertEquals("Loaded Page", page.getTitle());
+ assertEquals("manager:/platform/administrators;manager:/platform/users",
Utils.join(";", page.getAccessPermissions()));
+ assertEquals("*:/platform/administrators", page.getEditPermission());
+
+ // Verify page children
+ assertNotNull(page.getChildren());
+ assertEquals(1, page.getChildren().size());
+ ModelObject child = page.getChildren().get(0);
+ assertTrue(child instanceof Container);
+
+ // Verify root container
+ Container rootContainer = (Container) child;
+ assertEquals("rootContainer", rootContainer.getId());
+ assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl",
rootContainer.getTemplate());
+ assertEquals("Everyone", Utils.join(";",
rootContainer.getAccessPermissions()));
+
+ // Verify root container children
+ List<ModelObject> rootChildren = rootContainer.getChildren();
+ assertNotNull(rootChildren);
+ assertEquals(3, rootChildren.size());
+
+ // Verify container 1
+ ModelObject c1 = rootChildren.get(0);
+ assertNotNull(c1);
+ assertTrue(c1 instanceof ModelObject);
+ Container container1 = (Container) c1;
+ assertEquals("c1", container1.getId());
+ assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl",
container1.getTemplate());
+ assertEquals("*:/platform/users", Utils.join(";",
container1.getAccessPermissions()));
+ {
+ // Verify homepage application
+ assertNotNull(container1.getChildren());
+ assertEquals(1, container1.getChildren().size());
+ ModelObject homeComponent = container1.getChildren().get(0);
+ assertTrue(homeComponent instanceof Application);
+ @SuppressWarnings("unchecked")
+ Application<Portlet> application = (Application<Portlet>)
homeComponent;
+ assertTrue(application.getType() == ApplicationType.PORTLET);
+ ApplicationState<Portlet> state = application.getState();
+ assertNotNull(state);
+ assertTrue(state instanceof TransientApplicationState);
+ TransientApplicationState<Portlet> tas =
(TransientApplicationState<Portlet>) state;
+ assertEquals("web/HomePagePortlet", tas.getContentId());
+ Portlet portlet = tas.getContentState();
+ int count = 0;
+ for (Preference pref : portlet)
+ {
+ count++;
+ }
+ assertEquals(3, count);
+ Preference pref = portlet.getPreference("template");
+ assertNotNull(pref);
+ assertEquals("template", pref.getName());
+
assertEquals("system:/templates/groovy/webui/component/UIHomePagePortlet.gtmpl",
pref.getValue());
+ assertTrue(pref.isReadOnly());
+
+ pref = portlet.getPreference("empty-preference-value");
+ assertNotNull(pref);
+ assertEquals("empty-preference-value", pref.getName());
+ assertNull(pref.getValue());
+ assertFalse(pref.isReadOnly());
+
+ pref = portlet.getPreference("no-preference-value");
+ assertNotNull(pref);
+ assertEquals("no-preference-value", pref.getName());
+ assertNull(pref.getValue());
+ assertFalse(pref.isReadOnly());
+
+ assertEquals("Mac:MacTheme::Default:DefaultTheme::Vista:VistaTheme",
application.getTheme());
+ assertEquals("Home Page portlet", application.getTitle());
+ assertEquals("Everyone", Utils.join(";",
application.getAccessPermissions()));
+ assertTrue(application.getShowInfoBar());
+ assertTrue(application.getShowApplicationState());
+ assertTrue(application.getShowApplicationMode());
+ assertNull(application.getDescription());
+ assertNull(application.getIcon());
+ assertNull(application.getWidth());
+ assertNull(application.getHeight());
+ }
+
+ // Verify container 2
+ ModelObject c2 = rootChildren.get(1);
+ assertNotNull(c2);
+ assertTrue(c2 instanceof Container);
+ Container container2 = (Container) c2;
+ assertEquals("c2", container2.getId());
+
assertEquals("system:/groovy/portal/webui/container/UITableColumnContainer.gtmpl",
container2.getTemplate());
+ assertEquals("*:/platform/guests", Utils.join(";",
container2.getAccessPermissions()));
+ assertEquals("TableColumnContainer", container2.getFactoryId());
+ assertNotNull(container2.getChildren());
+ assertEquals(2, container2.getChildren().size());
+
+ {
+ // Verify column 1 of container 2
+ ModelObject appregComp = container2.getChildren().get(0);
+ assertTrue(appregComp instanceof Container);
+ Container appregContainer = (Container) appregComp;
+ assertEquals("c2-1", appregContainer.getId());
+
assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl",
appregContainer.getTemplate());
+ assertEquals("300px", appregContainer.getWidth());
+ assertEquals("400px", appregContainer.getHeight());
+ assertEquals("Everyone", Utils.join(";",
appregContainer.getAccessPermissions()));
+ {
+ // Verify app registry application
+ assertNotNull(appregContainer.getChildren());
+ assertEquals(1, appregContainer.getChildren().size());
+ ModelObject appregComponent = appregContainer.getChildren().get(0);
+ assertTrue(appregComponent instanceof Application);
+ @SuppressWarnings("unchecked")
+ Application<Portlet> application = (Application<Portlet>)
appregComponent;
+ assertTrue(application.getType() == ApplicationType.PORTLET);
+ ApplicationState<Portlet> state = application.getState();
+ assertNotNull(state);
+ assertTrue(state instanceof TransientApplicationState);
+ TransientApplicationState<Portlet> tas =
(TransientApplicationState<Portlet>) state;
+ assertEquals("exoadmin/ApplicationRegistryPortlet",
tas.getContentId());
+ assertNull(tas.getContentState());
+
+
assertEquals("Default:DefaultTheme::Mac:MacTheme::Vista:VistaTheme",
application.getTheme());
+ assertEquals("Application Registry", application.getTitle());
+
assertEquals("*:/platform/administrators;*:/organization/management/executive-board",
Utils.join(";", application.getAccessPermissions()));
+ assertFalse(application.getShowInfoBar());
+ assertTrue(application.getShowApplicationState());
+ assertFalse(application.getShowApplicationMode());
+ assertEquals("Application Registry",
application.getDescription());
+ assertEquals("PortletIcon", application.getIcon());
+ assertEquals("250px", application.getWidth());
+ assertEquals("350px", application.getHeight());
+ }
+
+ // Verify column 2 of container 2
+ ModelObject orgComp = container2.getChildren().get(1);
+ assertTrue(orgComp instanceof Container);
+ Container orgContainer = (Container) orgComp;
+ assertEquals("c2-2", orgContainer.getId());
+
assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl",
orgContainer.getTemplate());
+ assertEquals("200px", orgContainer.getWidth());
+ assertEquals("300px", orgContainer.getHeight());
+ assertEquals("/platform/users", Utils.join(";",
orgContainer.getAccessPermissions()));
+ {
+ // Verify calendar gadget application
+ assertNotNull(orgContainer.getChildren());
+ assertEquals(1, orgContainer.getChildren().size());
+ ModelObject gadgetComponent = orgContainer.getChildren().get(0);
+ assertTrue(gadgetComponent instanceof Application);
+ @SuppressWarnings("unchecked")
+ Application<Gadget> application = (Application<Gadget>)
gadgetComponent;
+ assertTrue(application.getType() == ApplicationType.GADGET);
+ ApplicationState<Gadget> state = application.getState();
+ assertNotNull(state);
+ assertTrue(state instanceof TransientApplicationState);
+ TransientApplicationState<Gadget> tas =
(TransientApplicationState<Gadget>) state;
+ assertEquals("Calendar", tas.getContentId());
+ assertNull(tas.getContentState());
+
+
assertEquals("Vista:VistaTheme::Mac:MacTheme::Default:DefaultTheme",
application.getTheme());
+ assertEquals("Calendar Title", application.getTitle());
+
assertEquals("*:/platform/administrators;*:/organization/management/executive-board",
Utils.join(";", application.getAccessPermissions()));
+ assertTrue(application.getShowInfoBar());
+ assertFalse(application.getShowApplicationState());
+ assertFalse(application.getShowApplicationMode());
+ assertEquals("Calendar Description",
application.getDescription());
+ assertEquals("StarAwardIcon", application.getIcon());
+ assertEquals("100px", application.getWidth());
+ assertEquals("200px", application.getHeight());
+ }
+ }
+
+ // Verify container 3
+ ModelObject c3 = rootChildren.get(2);
+ assertNotNull(c3);
+ assertTrue(c3 instanceof Container);
+ Container container3 = (Container) c3;
+ assertEquals("c3", container3.getId());
+ assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl",
container3.getTemplate());
+ assertEquals(container3.getTemplate(),
"system:/groovy/portal/webui/container/UIContainer.gtmpl");
+ assertEquals("Everyone", Utils.join(";",
container3.getAccessPermissions()));
+ assertNull(container3.getFactoryId());
+ {
+ // Verify site map application
+ assertNotNull(container3.getChildren());
+ assertEquals(1, container3.getChildren().size());
+ ModelObject sitemapcomponent = container3.getChildren().get(0);
+ assertTrue(sitemapcomponent instanceof Application);
+ @SuppressWarnings("unchecked")
+ Application<Portlet> application = (Application<Portlet>)
sitemapcomponent;
+ assertTrue(application.getType() == ApplicationType.PORTLET);
+ ApplicationState<Portlet> state = application.getState();
+ assertNotNull(state);
+ assertTrue(state instanceof TransientApplicationState);
+ TransientApplicationState<Portlet> tas =
(TransientApplicationState<Portlet>) state;
+ assertEquals("web/SiteMapPortlet", tas.getContentId());
+ assertNull(tas.getContentState());
+
+ assertEquals("Default:DefaultTheme::Vista:VistaTheme::Mac:MacTheme",
application.getTheme());
+ assertEquals("SiteMap", application.getTitle());
+ assertEquals("*:/platform/users", Utils.join(";",
application.getAccessPermissions()));
+ assertTrue(application.getShowInfoBar());
+ assertTrue(application.getShowApplicationState());
+ assertFalse(application.getShowApplicationMode());
+ assertEquals("SiteMap", application.getDescription());
+ assertNull(application.getIcon());
+ assertNull(application.getWidth());
+ assertNull(application.getHeight());
+ }
+ }
+
+ public void testEmptyPageUnmarshalling()
+ {
+ PageMarshaller marshaller = new PageMarshaller();
+ Page.PageSet pages =
marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/pages-empty.xml"));
+ assertNotNull(pages);
+ assertNotNull(pages.getPages());
+ assertEquals(1, pages.getPages().size());
+ Page page = pages.getPages().get(0);
+ assertNotNull(page);
+ assertEquals("empty-page", page.getName());
+ assertEquals("Empty", page.getTitle());
+ assertNotNull(page.getChildren());
+ assertTrue(page.getChildren().isEmpty());
+ }
+
+ public void testPageMarshalling()
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ Portlet portlet = new Portlet();
+ portlet.putPreference(new Preference("pref-1", "value-1",
true));
+ portlet.putPreference(new Preference("pref-2", "value-2",
false));
+ portlet.putPreference(new Preference("multi-value-pref",
Arrays.asList("one", "two", "three"), false));
+ portlet.putPreference(new Preference("empty-value-pref", (String) null,
true));
+
+ ApplicationState<Portlet> state = new
TransientApplicationState<Portlet>("app-ref/portlet-ref", portlet);
+ ApplicationData<Portlet> applicationData = new
ApplicationData<Portlet>(null, null,
+ ApplicationType.PORTLET, state, null, "app-title",
"app-icon", "app-description", false, true, false,
+ "app-theme", "app-wdith", "app-height", new
HashMap<String,String>(),
+ Collections.singletonList("app-edit-permissions"));
+
+ ContainerData containerData = new ContainerData(null, "cd-id",
"cd-name", "cd-icon", "cd-template",
"cd-factoryId", "cd-title", "cd-description",
"cd-width", "cd-height",
Collections.singletonList("cd-access-permissions"),
Collections.singletonList((ComponentData) applicationData));
+ List<ComponentData> children = Collections.singletonList((ComponentData)
containerData);
+
+ PageData expectedData = new PageData(null, null, "page-name", null, null,
null, "Page Title", null, null, null,
+ Collections.singletonList("access-permissions"), children,
"", "", "edit-permission", true);
+
+ Page expected = new Page(expectedData);
+
+ Page.PageSet expectedPages = new Page.PageSet();
+ expectedPages.setPages(new ArrayList<Page>(1));
+ expectedPages.getPages().add(expected);
+
+ PageMarshaller marshaller = new PageMarshaller();
+ marshaller.marshal(expectedPages, baos);
+
+ //System.out.println(baos.toString());
+
+ Page.PageSet actualPages = marshaller.unmarshal(new
ByteArrayInputStream(baos.toByteArray()));
+
+ assertNotNull(actualPages);
+ assertNotNull(actualPages.getPages());
+ assertEquals(1, actualPages.getPages().size());
+
+ comparePages(expected, actualPages.getPages().get(0));
+ }
+
+ public void testPageMarshallingWithGadget()
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ Gadget gadget = null;
+ //TODO: Uncomment when gadget user-prefs are supported in gatein_objects
+ //Gadget gadget = new Gadget();
+ //gadget.setUserPref("user-pref");
+
+ ApplicationState<Gadget> state = new
TransientApplicationState<Gadget>("gadget-ref", gadget);
+ ApplicationData<Gadget> applicationData = new
ApplicationData<Gadget>(null, null,
+ ApplicationType.GADGET, state, null, "app-title",
"app-icon", "app-description", false, true, false,
+ "app-theme", "app-wdith", "app-height", new
HashMap<String,String>(),
+ Collections.singletonList("app-edit-permissions"));
+
+ List<ComponentData> children = Collections.singletonList((ComponentData)
applicationData);
+ PageData expectedData = new PageData(null, null, "page-name", null, null,
null, "Page Title", null, null, null,
+ Collections.singletonList("access-permissions"), children,
"", "", "edit-permission", true);
+
+ Page expected = new Page(expectedData);
+
+ Page.PageSet expectedPages = new Page.PageSet();
+ expectedPages.setPages(new ArrayList<Page>(1));
+ expectedPages.getPages().add(expected);
+
+ PageMarshaller marshaller = new PageMarshaller();
+ marshaller.marshal(expectedPages, baos);
+
+ //System.out.println(baos.toString());
+
+ Page.PageSet actualPages = marshaller.unmarshal(new
ByteArrayInputStream(baos.toByteArray()));
+
+ assertNotNull(actualPages);
+ assertNotNull(actualPages.getPages());
+ assertEquals(1, actualPages.getPages().size());
+
+ comparePages(expected, actualPages.getPages().get(0));
+ }
+
+ private void comparePages(Page expected, Page actual)
+ {
+ assertNull(actual.getStorageId());
+ assertNull(actual.getStorageName());
+ assertNull(actual.getId());
+ assertNull(actual.getOwnerType());
+ assertNull(actual.getOwnerId());
+ assertEquals(expected.getName(), actual.getName());
+ assertNull(actual.getIcon());
+ assertNull(actual.getTemplate());
+ assertNull(actual.getFactoryId());
+ assertEquals(expected.getTitle(), actual.getTitle());
+ assertNull(actual.getDescription());
+ assertNull(actual.getWidth());
+ assertNull(actual.getHeight());
+ assertEquals(Arrays.asList(expected.getAccessPermissions()),
Arrays.asList(actual.getAccessPermissions()));
+
+ compareComponents(expected.getChildren(), actual.getChildren());
+
+ assertEquals(expected.getEditPermission(), actual.getEditPermission());
+ assertEquals(expected.isShowMaxWindow(), actual.isShowMaxWindow());
+ }
+}
Deleted:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshallerTest.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshallerTest.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshallerTest.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,225 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.binding.xml;
-
-import org.exoplatform.portal.config.model.Application;
-import org.exoplatform.portal.config.model.ApplicationState;
-import org.exoplatform.portal.config.model.ApplicationType;
-import org.exoplatform.portal.config.model.Container;
-import org.exoplatform.portal.config.model.ModelObject;
-import org.exoplatform.portal.config.model.PageBody;
-import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.config.model.TransientApplicationState;
-import org.exoplatform.portal.pom.config.Utils;
-import org.exoplatform.portal.pom.data.ApplicationData;
-import org.exoplatform.portal.pom.data.BodyData;
-import org.exoplatform.portal.pom.data.BodyType;
-import org.exoplatform.portal.pom.data.ComponentData;
-import org.exoplatform.portal.pom.data.ContainerData;
-import org.exoplatform.portal.pom.data.PortalData;
-import org.exoplatform.portal.pom.spi.portlet.Portlet;
-import org.exoplatform.portal.pom.spi.portlet.Preference;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static junit.framework.Assert.*;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class SiteLayoutMarshallerTest extends AbstractMarshallerTest
-{
- public void testPortalDataUnmarshalling()
- {
- SiteLayoutMarshaller marshaller = new SiteLayoutMarshaller();
- PortalConfig data =
marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/portal.xml"));
- assertNotNull(data);
- assertEquals("classic", data.getName());
- assertEquals("site-label", data.getLabel());
- assertEquals("site-description", data.getDescription());
- assertEquals("en", data.getLocale());
- assertEquals("Everyone", Utils.join(";",
data.getAccessPermissions()));
- assertEquals("*:/platform/administrators", data.getEditPermission());
- assertNotNull(data.getProperties());
- assertEquals(1, data.getProperties().size());
- assertTrue(data.getProperties().containsKey("sessionAlive"));
- assertEquals("onDemand",
data.getProperties().get("sessionAlive"));
-
- // Verify portal layout container only has children
- assertNotNull(data.getPortalLayout());
- Container layout = data.getPortalLayout();
- assertNull(layout.getStorageId());
- assertNull(layout.getId());
- assertNull(layout.getName());
- assertNull(layout.getIcon());
- assertNull(layout.getTemplate());
- assertNull(layout.getFactoryId());
- assertNull(layout.getTitle());
- assertNull(layout.getDescription());
- assertNull(layout.getWidth());
- assertNull(layout.getHeight());
- assertNull(layout.getAccessPermissions());
- List<ModelObject> children = data.getPortalLayout().getChildren();
- assertEquals(5, children.size());
- int bodyCount = 0;
- for (ModelObject component : children)
- {
- if (component instanceof Application)
- {
- }
- else if (component instanceof PageBody)
- {
- bodyCount++;
- }
- else
- {
- fail("Only application data and one body data should be created for a
portal layout.");
- }
- }
- assertEquals(1, bodyCount);
-
- // Verify banner portlet app
- {
- @SuppressWarnings("unchecked")
- Application<Portlet> application = (Application<Portlet>)
children.get(0);
- assertTrue(application.getType() == ApplicationType.PORTLET);
- ApplicationState<Portlet> state = application.getState();
- assertNotNull(state);
- assertTrue(state instanceof TransientApplicationState);
- TransientApplicationState<Portlet> tas =
(TransientApplicationState<Portlet>) state;
- assertEquals("web/BannerPortlet", tas.getContentId());
- Portlet portlet = tas.getContentState();
- int count = 0;
- for (Preference pref : portlet)
- {
- count++;
- }
- assertEquals(1, count);
- Preference pref = portlet.getPreference("template");
- assertNotNull(pref);
- assertEquals("template", pref.getName());
-
assertEquals("par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl",
pref.getValue());
- assertFalse(pref.isReadOnly());
-
- assertEquals("Default:DefaultTheme::Mac:MacTheme::Vista:VistaTheme",
application.getTheme());
- assertEquals("Banner", application.getTitle());
-
assertEquals("*:/platform/administrators;*:/organization/management/executive-board",
Utils.join(";", application.getAccessPermissions()));
- assertFalse(application.getShowInfoBar());
- assertTrue(application.getShowApplicationState());
- assertFalse(application.getShowApplicationMode());
- assertEquals("Banner Portlet", application.getDescription());
- assertEquals("PortletIcon", application.getIcon());
- assertEquals("250px", application.getWidth());
- assertEquals("350px", application.getHeight());
- }
-
- // Verify navigation portlet app
- {
- @SuppressWarnings("unchecked")
- Application<Portlet> application = (Application<Portlet>)
children.get(1);
- assertTrue(application.getType() == ApplicationType.PORTLET);
- ApplicationState<Portlet> state = application.getState();
- assertNotNull(state);
- assertTrue(state instanceof TransientApplicationState);
- TransientApplicationState<Portlet> tas =
(TransientApplicationState<Portlet>) state;
- assertEquals("web/NavigationPortlet", tas.getContentId());
- assertNull(tas.getContentState());
-
- assertNull(application.getTheme());
- assertNull(application.getTitle());
- assertEquals("Everyone", Utils.join(";",
application.getAccessPermissions()));
- assertFalse(application.getShowInfoBar());
- assertTrue(application.getShowApplicationState());
- assertTrue(application.getShowApplicationMode());
- assertNull(application.getDescription());
- assertNull(application.getIcon());
- assertNull(application.getWidth());
- assertNull(application.getHeight());
- }
- }
-
- public void testPortalDataMarshalling()
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- Portlet portlet = new Portlet();
- portlet.putPreference(new Preference("pref-1", "value-1",
true));
- portlet.putPreference(new Preference("pref-2", "value-2",
false));
- portlet.putPreference(new Preference("multi-value-pref",
Arrays.asList("one", "two", "three"), false));
- portlet.putPreference(new Preference("no-value-pref", (String) null,
true));
-
- ApplicationState<Portlet> state = new
TransientApplicationState<Portlet>("app-ref/portlet-ref", portlet);
- ApplicationData<Portlet> application = new
ApplicationData<Portlet>(null, null,
- ApplicationType.PORTLET, state, null, "app-title",
"app-icon", "app-description", false, true, false,
- "app-theme", "app-wdith", "app-height", new
HashMap<String,String>(),
- Collections.singletonList("app-edit-permissions"));
-
- List<ComponentData> children = new ArrayList<ComponentData>();
- children.add(application);
- children.add(new BodyData(null, BodyType.PAGE));
-
- ContainerData layout = new ContainerData(null, null, "container-name",
"container-icon", "container-template",
- "factoryId", "title", "description",
"width", "height", Collections.singletonList("blah"),
children);
-
- Map<String,String> properties = new HashMap<String,String>();
- properties.put("key1", "value1");
- properties.put("key2", "value2");
-
- PortalData expectedData = new PortalData(null, "name", "type",
"locale", "label", "description",
- Collections.singletonList("access-permissions"),
"edit-permissions", properties, "skin", layout);
-
- PortalConfig expected = new PortalConfig(expectedData);
-
- SiteLayoutMarshaller marshaller = new SiteLayoutMarshaller();
- marshaller.marshal(expected, baos);
-
-// System.out.println(baos.toString());
-
- PortalConfig actual = marshaller.unmarshal(new
ByteArrayInputStream(baos.toByteArray()));
- assertNotNull(actual);
- assertNull(actual.getStorageId());
- assertNull(actual.getStorageName());
- assertEquals("name", actual.getName());
- assertEquals("label", actual.getLabel());
- assertEquals("description", actual.getDescription());
- assertEquals("portal", actual.getType());
- assertEquals("locale", actual.getLocale());
- assertEquals("access-permissions", Utils.join(";",
actual.getAccessPermissions()));
- assertEquals("edit-permissions", actual.getEditPermission());
- assertEquals(properties, actual.getProperties());
- assertEquals("skin", actual.getSkin());
- assertNotNull(actual.getPortalLayout());
- assertNotNull(actual.getPortalLayout().getChildren());
- assertEquals(2, actual.getPortalLayout().getChildren().size());
-
- compareComponents(expected.getPortalLayout().getChildren(),
actual.getPortalLayout().getChildren());
- }
-}
Copied:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshallerTest.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshallerTest.java)
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshallerTest.java
(rev 0)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/binding/xml/SiteLayoutMarshallerTest.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,225 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.binding.xml;
+
+import org.exoplatform.portal.config.model.Application;
+import org.exoplatform.portal.config.model.ApplicationState;
+import org.exoplatform.portal.config.model.ApplicationType;
+import org.exoplatform.portal.config.model.Container;
+import org.exoplatform.portal.config.model.ModelObject;
+import org.exoplatform.portal.config.model.PageBody;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.config.model.TransientApplicationState;
+import org.exoplatform.portal.pom.config.Utils;
+import org.exoplatform.portal.pom.data.ApplicationData;
+import org.exoplatform.portal.pom.data.BodyData;
+import org.exoplatform.portal.pom.data.BodyType;
+import org.exoplatform.portal.pom.data.ComponentData;
+import org.exoplatform.portal.pom.data.ContainerData;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.exoplatform.portal.pom.spi.portlet.Portlet;
+import org.exoplatform.portal.pom.spi.portlet.Preference;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static junit.framework.Assert.*;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SiteLayoutMarshallerTest extends AbstractMarshallerTest
+{
+ public void testPortalDataUnmarshalling()
+ {
+ SiteLayoutMarshaller marshaller = new SiteLayoutMarshaller();
+ PortalConfig data =
marshaller.unmarshal(getClass().getResourceAsStream("/org/exoplatform/portal/mop/management/portal.xml"));
+ assertNotNull(data);
+ assertEquals("classic", data.getName());
+ assertEquals("site-label", data.getLabel());
+ assertEquals("site-description", data.getDescription());
+ assertEquals("en", data.getLocale());
+ assertEquals("Everyone", Utils.join(";",
data.getAccessPermissions()));
+ assertEquals("*:/platform/administrators", data.getEditPermission());
+ assertNotNull(data.getProperties());
+ assertEquals(1, data.getProperties().size());
+ assertTrue(data.getProperties().containsKey("sessionAlive"));
+ assertEquals("onDemand",
data.getProperties().get("sessionAlive"));
+
+ // Verify portal layout container only has children
+ assertNotNull(data.getPortalLayout());
+ Container layout = data.getPortalLayout();
+ assertNull(layout.getStorageId());
+ assertNull(layout.getId());
+ assertNull(layout.getName());
+ assertNull(layout.getIcon());
+ assertNull(layout.getTemplate());
+ assertNull(layout.getFactoryId());
+ assertNull(layout.getTitle());
+ assertNull(layout.getDescription());
+ assertNull(layout.getWidth());
+ assertNull(layout.getHeight());
+ assertNull(layout.getAccessPermissions());
+ List<ModelObject> children = data.getPortalLayout().getChildren();
+ assertEquals(5, children.size());
+ int bodyCount = 0;
+ for (ModelObject component : children)
+ {
+ if (component instanceof Application)
+ {
+ }
+ else if (component instanceof PageBody)
+ {
+ bodyCount++;
+ }
+ else
+ {
+ fail("Only application data and one body data should be created for a
portal layout.");
+ }
+ }
+ assertEquals(1, bodyCount);
+
+ // Verify banner portlet app
+ {
+ @SuppressWarnings("unchecked")
+ Application<Portlet> application = (Application<Portlet>)
children.get(0);
+ assertTrue(application.getType() == ApplicationType.PORTLET);
+ ApplicationState<Portlet> state = application.getState();
+ assertNotNull(state);
+ assertTrue(state instanceof TransientApplicationState);
+ TransientApplicationState<Portlet> tas =
(TransientApplicationState<Portlet>) state;
+ assertEquals("web/BannerPortlet", tas.getContentId());
+ Portlet portlet = tas.getContentState();
+ int count = 0;
+ for (Preference pref : portlet)
+ {
+ count++;
+ }
+ assertEquals(1, count);
+ Preference pref = portlet.getPreference("template");
+ assertNotNull(pref);
+ assertEquals("template", pref.getName());
+
assertEquals("par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl",
pref.getValue());
+ assertFalse(pref.isReadOnly());
+
+ assertEquals("Default:DefaultTheme::Mac:MacTheme::Vista:VistaTheme",
application.getTheme());
+ assertEquals("Banner", application.getTitle());
+
assertEquals("*:/platform/administrators;*:/organization/management/executive-board",
Utils.join(";", application.getAccessPermissions()));
+ assertFalse(application.getShowInfoBar());
+ assertTrue(application.getShowApplicationState());
+ assertFalse(application.getShowApplicationMode());
+ assertEquals("Banner Portlet", application.getDescription());
+ assertEquals("PortletIcon", application.getIcon());
+ assertEquals("250px", application.getWidth());
+ assertEquals("350px", application.getHeight());
+ }
+
+ // Verify navigation portlet app
+ {
+ @SuppressWarnings("unchecked")
+ Application<Portlet> application = (Application<Portlet>)
children.get(1);
+ assertTrue(application.getType() == ApplicationType.PORTLET);
+ ApplicationState<Portlet> state = application.getState();
+ assertNotNull(state);
+ assertTrue(state instanceof TransientApplicationState);
+ TransientApplicationState<Portlet> tas =
(TransientApplicationState<Portlet>) state;
+ assertEquals("web/NavigationPortlet", tas.getContentId());
+ assertNull(tas.getContentState());
+
+ assertNull(application.getTheme());
+ assertNull(application.getTitle());
+ assertEquals("Everyone", Utils.join(";",
application.getAccessPermissions()));
+ assertFalse(application.getShowInfoBar());
+ assertTrue(application.getShowApplicationState());
+ assertTrue(application.getShowApplicationMode());
+ assertNull(application.getDescription());
+ assertNull(application.getIcon());
+ assertNull(application.getWidth());
+ assertNull(application.getHeight());
+ }
+ }
+
+ public void testPortalDataMarshalling()
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ Portlet portlet = new Portlet();
+ portlet.putPreference(new Preference("pref-1", "value-1",
true));
+ portlet.putPreference(new Preference("pref-2", "value-2",
false));
+ portlet.putPreference(new Preference("multi-value-pref",
Arrays.asList("one", "two", "three"), false));
+ portlet.putPreference(new Preference("no-value-pref", (String) null,
true));
+
+ ApplicationState<Portlet> state = new
TransientApplicationState<Portlet>("app-ref/portlet-ref", portlet);
+ ApplicationData<Portlet> application = new
ApplicationData<Portlet>(null, null,
+ ApplicationType.PORTLET, state, null, "app-title",
"app-icon", "app-description", false, true, false,
+ "app-theme", "app-wdith", "app-height", new
HashMap<String,String>(),
+ Collections.singletonList("app-edit-permissions"));
+
+ List<ComponentData> children = new ArrayList<ComponentData>();
+ children.add(application);
+ children.add(new BodyData(null, BodyType.PAGE));
+
+ ContainerData layout = new ContainerData(null, null, "container-name",
"container-icon", "container-template",
+ "factoryId", "title", "description",
"width", "height", Collections.singletonList("blah"),
children);
+
+ Map<String,String> properties = new HashMap<String,String>();
+ properties.put("key1", "value1");
+ properties.put("key2", "value2");
+
+ PortalData expectedData = new PortalData(null, "name", "type",
"locale", "label", "description",
+ Collections.singletonList("access-permissions"),
"edit-permissions", properties, "skin", layout);
+
+ PortalConfig expected = new PortalConfig(expectedData);
+
+ SiteLayoutMarshaller marshaller = new SiteLayoutMarshaller();
+ marshaller.marshal(expected, baos);
+
+// System.out.println(baos.toString());
+
+ PortalConfig actual = marshaller.unmarshal(new
ByteArrayInputStream(baos.toByteArray()));
+ assertNotNull(actual);
+ assertNull(actual.getStorageId());
+ assertNull(actual.getStorageName());
+ assertEquals("name", actual.getName());
+ assertEquals("label", actual.getLabel());
+ assertEquals("description", actual.getDescription());
+ assertEquals("portal", actual.getType());
+ assertEquals("locale", actual.getLocale());
+ assertEquals("access-permissions", Utils.join(";",
actual.getAccessPermissions()));
+ assertEquals("edit-permissions", actual.getEditPermission());
+ assertEquals(properties, actual.getProperties());
+ assertEquals("skin", actual.getSkin());
+ assertNotNull(actual.getPortalLayout());
+ assertNotNull(actual.getPortalLayout().getChildren());
+ assertEquals(2, actual.getPortalLayout().getChildren().size());
+
+ compareComponents(expected.getPortalLayout().getChildren(),
actual.getPortalLayout().getChildren());
+ }
+}
Deleted:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/exportimport/PageImportTaskTest.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/exportimport/PageImportTaskTest.java 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/exportimport/PageImportTaskTest.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,492 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.mop.management.exportimport;
-
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-import org.exoplatform.commons.utils.LazyPageList;
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.Query;
-import org.exoplatform.portal.config.model.Page;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.pom.data.ComponentData;
-import org.exoplatform.portal.pom.data.PageData;
-import org.mockito.ArgumentMatcher;
-import org.mockito.Matchers;
-
-import java.util.ArrayList;
-import java.util.Collections;
-
-import static org.mockito.Mockito.*;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PageImportTaskTest extends TestCase
-{
- private DataStorage dataStorage;
- private LazyPageList<Page> list;
- private SiteKey siteKey = new SiteKey("user", "foo");
-
- @Override
- @SuppressWarnings("unchecked")
- protected void setUp() throws Exception
- {
- dataStorage = mock(DataStorage.class);
- list = mock(LazyPageList.class);
- }
-
- public void testConserve_NoPages() throws Exception
- {
- Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
- PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
-
- when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
- when(list.getAvailable()).thenReturn(0); // no pages exist
-
- task.importData(ImportStrategy.CONSERVE);
-
- verify(dataStorage).find(query("user", "foo"));
- verify(list).getAvailable();
- verify(list, never()).getAll();
-
- for (Page page : importing.getPages())
- {
- verify(dataStorage).save(page);
- }
- verify(dataStorage, times(3)).save();
-
- verifyNoMoreInteractions(dataStorage, list);
-
- Assert.assertNotNull(task.getRollbackDeletes());
- Assert.assertEquals(importing, task.getRollbackDeletes());
- Assert.assertNull(task.getRollbackSaves());
- }
-
- public void testConserve_SamePages() throws Exception
- {
- Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
- Page.PageSet existing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
- PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
-
- when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
- when(list.getAvailable()).thenReturn(3);
- when(list.getAll()).thenReturn(existing.getPages());
-
- task.importData(ImportStrategy.CONSERVE);
-
- verify(dataStorage).find(query("user", "foo"));
- verify(list).getAvailable();
- verify(list).getAll();
-
- verifyNoMoreInteractions(dataStorage, list);
-
- assertNullOrEmpty(task.getRollbackDeletes());
- assertNullOrEmpty(task.getRollbackSaves());
- }
-
- public void testConserve_NewPages() throws Exception
- {
- Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
- Page.PageSet existing = new
Builder().addPage("foo").addPage("bar").addPage("baz").build();
- PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
-
- when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
- when(list.getAvailable()).thenReturn(3);
- when(list.getAll()).thenReturn(existing.getPages());
-
- task.importData(ImportStrategy.CONSERVE);
-
- verify(dataStorage).find(query("user", "foo"));
- verify(list).getAvailable();
- verify(list).getAll();
-
- for (Page page : importing.getPages())
- {
- verify(dataStorage).save(page);
- }
- verify(dataStorage, times(3)).save();
-
- verifyNoMoreInteractions(dataStorage, list);
-
- Assert.assertNotNull(task.getRollbackDeletes());
- Assert.assertEquals(importing.getPages(), task.getRollbackDeletes().getPages());
- Assert.assertNull(task.getRollbackSaves());
- }
-
- public void testConserve_NewAndSamePages() throws Exception
- {
- Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").addPage("page4").build();
- Page.PageSet existing = new
Builder().addPage("page2").addPage("bar").addPage("page3").build();
- PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
-
- when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
- when(list.getAvailable()).thenReturn(3);
- when(list.getAll()).thenReturn(existing.getPages());
-
- task.importData(ImportStrategy.CONSERVE);
-
- verify(dataStorage).find(query("user", "foo"));
- verify(list).getAvailable();
- verify(list).getAll();
-
- verify(dataStorage).save(importing.getPages().get(0));
- verify(dataStorage).save(importing.getPages().get(3));
-
- verify(dataStorage, times(2)).save();
-
- verifyNoMoreInteractions(dataStorage, list);
-
- Assert.assertNotNull(task.getRollbackDeletes());
- Assert.assertEquals(2, task.getRollbackDeletes().getPages().size());
- Assert.assertEquals(importing.getPages().get(0),
task.getRollbackDeletes().getPages().get(0));
- Assert.assertEquals(importing.getPages().get(3),
task.getRollbackDeletes().getPages().get(1));
- Assert.assertNull(task.getRollbackSaves());
- }
-
- public void testMerge_NoPages() throws Exception
- {
- Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
- PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
-
- when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
- when(list.getAvailable()).thenReturn(0); // no pages exist
-
- task.importData(ImportStrategy.MERGE);
-
- verify(dataStorage).find(query("user", "foo"));
- verify(list).getAvailable();
- verify(list, never()).getAll();
-
- for (Page page : importing.getPages())
- {
- verify(dataStorage).save(page);
- }
- verify(dataStorage, times(3)).save();
-
- verifyNoMoreInteractions(dataStorage, list);
-
- Assert.assertNotNull(task.getRollbackDeletes());
- Assert.assertEquals(importing, task.getRollbackDeletes());
- Assert.assertNull(task.getRollbackSaves());
- }
-
- public void testMerge_SamePages() throws Exception
- {
- Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
- Page.PageSet existing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
- PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
-
- when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
- when(list.getAvailable()).thenReturn(3);
- when(list.getAll()).thenReturn(existing.getPages());
-
- task.importData(ImportStrategy.MERGE);
-
- verify(dataStorage).find(query("user", "foo"));
- verify(list).getAvailable();
- verify(list).getAll();
-
- for (Page page : importing.getPages())
- {
- verify(dataStorage).save(page);
- }
- verify(dataStorage, times(3)).save();
-
- verifyNoMoreInteractions(dataStorage, list);
-
- assertNullOrEmpty(task.getRollbackDeletes());
- Assert.assertNotNull(task.getRollbackSaves());
- Assert.assertEquals(3, task.getRollbackSaves().getPages().size());
- Assert.assertEquals(existing.getPages(), task.getRollbackSaves().getPages());
- }
-
- public void testMerge_NewPages() throws Exception
- {
- Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
- Page.PageSet existing = new
Builder().addPage("foo").addPage("bar").addPage("baz").build();
- PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
-
- when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
- when(list.getAvailable()).thenReturn(3);
- when(list.getAll()).thenReturn(existing.getPages());
-
- task.importData(ImportStrategy.MERGE);
-
- verify(dataStorage).find(query("user", "foo"));
- verify(list).getAvailable();
- verify(list).getAll();
-
- for (Page page : importing.getPages())
- {
- verify(dataStorage).save(page);
- }
- verify(dataStorage, times(3)).save();
-
- verifyNoMoreInteractions(dataStorage, list);
-
- Assert.assertNotNull(task.getRollbackDeletes());
- Assert.assertEquals(importing.getPages(), task.getRollbackDeletes().getPages());
- assertNullOrEmpty(task.getRollbackSaves());
- }
-
- public void testMerge_NewAndSamePages() throws Exception
- {
- Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").addPage("page4").build();
- Page.PageSet existing = new
Builder().addPage("page2").addPage("bar").addPage("page3").build();
- PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
-
- when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
- when(list.getAvailable()).thenReturn(3);
- when(list.getAll()).thenReturn(existing.getPages());
-
- task.importData(ImportStrategy.MERGE);
-
- verify(dataStorage).find(query("user", "foo"));
- verify(list).getAvailable();
- verify(list).getAll();
-
- for (Page page : importing.getPages())
- {
- verify(dataStorage).save(page);
- }
- verify(dataStorage, times(4)).save();
-
- verifyNoMoreInteractions(dataStorage, list);
-
- Assert.assertNotNull(task.getRollbackDeletes());
- Assert.assertEquals(2, task.getRollbackDeletes().getPages().size());
- Assert.assertEquals(importing.getPages().get(0),
task.getRollbackDeletes().getPages().get(0));
- Assert.assertEquals(importing.getPages().get(3),
task.getRollbackDeletes().getPages().get(1));
-
- Assert.assertNotNull(task.getRollbackSaves());
- Assert.assertEquals(2, task.getRollbackSaves().getPages().size());
- Assert.assertEquals(existing.getPages().get(0),
task.getRollbackSaves().getPages().get(0));
- Assert.assertEquals(existing.getPages().get(2),
task.getRollbackSaves().getPages().get(1));
- }
-
- public void testOverwrite_NoPages() throws Exception
- {
- Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
- PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
-
- when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
- when(list.getAvailable()).thenReturn(0); // no pages exist
-
- task.importData(ImportStrategy.OVERWRITE);
-
- verify(dataStorage).find(query("user", "foo"));
- verify(list).getAvailable();
- verify(list, never()).getAll();
-
- for (Page page : importing.getPages())
- {
- verify(dataStorage).save(page);
- }
- verify(dataStorage, times(3)).save();
-
- verifyNoMoreInteractions(dataStorage, list);
-
- Assert.assertNotNull(task.getRollbackDeletes());
- Assert.assertEquals(importing, task.getRollbackDeletes());
- Assert.assertNull(task.getRollbackSaves());
- }
-
- public void testOverwrite_SamePages() throws Exception
- {
- Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
- Page.PageSet existing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
- PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
-
- when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
- when(list.getAvailable()).thenReturn(3);
- when(list.getAll()).thenReturn(existing.getPages());
-
- task.importData(ImportStrategy.OVERWRITE);
-
- verify(dataStorage).find(query("user", "foo"));
- verify(list).getAvailable();
- verify(list).getAll();
-
- int saveCount = importing.getPages().size() + existing.getPages().size();
- for (Page page : existing.getPages())
- {
- verify(dataStorage).remove(page);
- }
-
- for (Page page : importing.getPages())
- {
- verify(dataStorage).save(page);
- }
- verify(dataStorage, times(saveCount)).save();
-
- verifyNoMoreInteractions(dataStorage, list);
-
- assertNullOrEmpty(task.getRollbackDeletes());
- Assert.assertNotNull(task.getRollbackSaves());
- Assert.assertEquals(3, task.getRollbackSaves().getPages().size());
- Assert.assertEquals(existing.getPages(), task.getRollbackSaves().getPages());
- }
-
- public void testOverwrite_NewPages() throws Exception
- {
- Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
- Page.PageSet existing = new
Builder().addPage("foo").addPage("bar").addPage("baz").build();
- PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
-
- when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
- when(list.getAvailable()).thenReturn(3);
- when(list.getAll()).thenReturn(existing.getPages());
-
- task.importData(ImportStrategy.OVERWRITE);
-
- verify(dataStorage).find(query("user", "foo"));
- verify(list).getAvailable();
- verify(list).getAll();
-
- int saveCount = importing.getPages().size() + existing.getPages().size();
- for (Page page : existing.getPages())
- {
- verify(dataStorage).remove(page);
- }
-
- for (Page page : importing.getPages())
- {
- verify(dataStorage).save(page);
- }
- verify(dataStorage, times(saveCount)).save();
-
- verifyNoMoreInteractions(dataStorage, list);
-
- Assert.assertNotNull(task.getRollbackDeletes());
- Assert.assertEquals(importing.getPages(), task.getRollbackDeletes().getPages());
-
- Assert.assertNotNull(task.getRollbackSaves());
- Assert.assertEquals(existing.getPages(), task.getRollbackSaves().getPages());
- }
-
- public void testOverwrite_NewAndSamePages() throws Exception
- {
- Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").addPage("page4").build();
- Page.PageSet existing = new
Builder().addPage("page2").addPage("bar").addPage("page3").build();
- PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
-
- when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
- when(list.getAvailable()).thenReturn(3);
- when(list.getAll()).thenReturn(existing.getPages());
-
- task.importData(ImportStrategy.OVERWRITE);
-
- verify(dataStorage).find(query("user", "foo"));
- verify(list).getAvailable();
- verify(list).getAll();
-
- int saveCount = importing.getPages().size() + existing.getPages().size();
- for (Page page : existing.getPages())
- {
- verify(dataStorage).remove(page);
- }
-
- for (Page page : importing.getPages())
- {
- verify(dataStorage).save(page);
- }
- verify(dataStorage, times(saveCount)).save();
-
- verifyNoMoreInteractions(dataStorage, list);
-
- Assert.assertNotNull(task.getRollbackDeletes());
- Assert.assertEquals(2, task.getRollbackDeletes().getPages().size());
- Assert.assertEquals(importing.getPages().get(0),
task.getRollbackDeletes().getPages().get(0));
- Assert.assertEquals(importing.getPages().get(3),
task.getRollbackDeletes().getPages().get(1));
-
- Assert.assertNotNull(task.getRollbackSaves());
- Assert.assertEquals(existing.getPages(), task.getRollbackSaves().getPages());
- }
-
- private void assertNullOrEmpty(Page.PageSet pages)
- {
- if (pages != null)
- {
- Assert.assertTrue(pages.getPages().isEmpty());
- }
- }
-
- private Query<Page> query(String ownerType, String ownerId)
- {
- return argThat(new QueryMatcher(new Query<Page>(ownerType, ownerId,
Page.class)));
- }
-
- private class QueryMatcher extends ArgumentMatcher<Query<Page>>
- {
- private Query<Page> query;
-
- public QueryMatcher(Query<Page> query)
- {
- this.query = query;
- }
-
- @Override
- public boolean matches(Object o)
- {
- if (query == o) return true;
- if (!(o instanceof Query)) return false;
-
- Query that = (Query) o;
-
- if (!query.getClassType().equals(that.getClassType())) return false;
- if (!query.getOwnerType().equals(that.getOwnerType())) return false;
- if (!query.getOwnerId().equals(that.getOwnerId())) return false;
-
- if (query.getName() != null ? !query.getName().equals(that.getName()) :
that.getName() != null) return false;
- if (query.getTitle() != null ? !query.getTitle().equals(that.getTitle()) :
that.getTitle() != null) return false;
-
- return true;
- }
- }
-
- private static class Builder
- {
- private Page.PageSet pages;
- public Builder()
- {
- pages = new Page.PageSet();
- pages.setPages(new ArrayList<Page>());
- }
-
- public Builder addPage(String name)
- {
- PageData page= new PageData(null, "", name, null, null, null, null,
null, null, null, Collections.<String>emptyList(),
Collections.<ComponentData>emptyList(), "", "", null, false);
- pages.getPages().add(new Page(page));
-
- return this;
- }
-
- public Page.PageSet build()
- {
- return pages;
- }
- }
-}
Copied:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/exportimport/PageImportTaskTest.java
(from rev 6958,
portal/branches/gatein-management/component/portal/src/test/java/org/exoplatform/portal/mop/management/exportimport/PageImportTaskTest.java)
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/exportimport/PageImportTaskTest.java
(rev 0)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/mop/management/exportimport/PageImportTaskTest.java 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,492 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop.management.exportimport;
+
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.exoplatform.commons.utils.LazyPageList;
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.Query;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.pom.data.ComponentData;
+import org.exoplatform.portal.pom.data.PageData;
+import org.mockito.ArgumentMatcher;
+import org.mockito.Matchers;
+
+import java.util.ArrayList;
+import java.util.Collections;
+
+import static org.mockito.Mockito.*;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageImportTaskTest extends TestCase
+{
+ private DataStorage dataStorage;
+ private LazyPageList<Page> list;
+ private SiteKey siteKey = new SiteKey("user", "foo");
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception
+ {
+ dataStorage = mock(DataStorage.class);
+ list = mock(LazyPageList.class);
+ }
+
+ public void testConserve_NoPages() throws Exception
+ {
+ Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(0); // no pages exist
+
+ task.importData(ImportStrategy.CONSERVE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list, never()).getAll();
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(3)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ Assert.assertNotNull(task.getRollbackDeletes());
+ Assert.assertEquals(importing, task.getRollbackDeletes());
+ Assert.assertNull(task.getRollbackSaves());
+ }
+
+ public void testConserve_SamePages() throws Exception
+ {
+ Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ Page.PageSet existing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(3);
+ when(list.getAll()).thenReturn(existing.getPages());
+
+ task.importData(ImportStrategy.CONSERVE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list).getAll();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ assertNullOrEmpty(task.getRollbackDeletes());
+ assertNullOrEmpty(task.getRollbackSaves());
+ }
+
+ public void testConserve_NewPages() throws Exception
+ {
+ Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ Page.PageSet existing = new
Builder().addPage("foo").addPage("bar").addPage("baz").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(3);
+ when(list.getAll()).thenReturn(existing.getPages());
+
+ task.importData(ImportStrategy.CONSERVE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list).getAll();
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(3)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ Assert.assertNotNull(task.getRollbackDeletes());
+ Assert.assertEquals(importing.getPages(), task.getRollbackDeletes().getPages());
+ Assert.assertNull(task.getRollbackSaves());
+ }
+
+ public void testConserve_NewAndSamePages() throws Exception
+ {
+ Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").addPage("page4").build();
+ Page.PageSet existing = new
Builder().addPage("page2").addPage("bar").addPage("page3").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(3);
+ when(list.getAll()).thenReturn(existing.getPages());
+
+ task.importData(ImportStrategy.CONSERVE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list).getAll();
+
+ verify(dataStorage).save(importing.getPages().get(0));
+ verify(dataStorage).save(importing.getPages().get(3));
+
+ verify(dataStorage, times(2)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ Assert.assertNotNull(task.getRollbackDeletes());
+ Assert.assertEquals(2, task.getRollbackDeletes().getPages().size());
+ Assert.assertEquals(importing.getPages().get(0),
task.getRollbackDeletes().getPages().get(0));
+ Assert.assertEquals(importing.getPages().get(3),
task.getRollbackDeletes().getPages().get(1));
+ Assert.assertNull(task.getRollbackSaves());
+ }
+
+ public void testMerge_NoPages() throws Exception
+ {
+ Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(0); // no pages exist
+
+ task.importData(ImportStrategy.MERGE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list, never()).getAll();
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(3)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ Assert.assertNotNull(task.getRollbackDeletes());
+ Assert.assertEquals(importing, task.getRollbackDeletes());
+ Assert.assertNull(task.getRollbackSaves());
+ }
+
+ public void testMerge_SamePages() throws Exception
+ {
+ Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ Page.PageSet existing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(3);
+ when(list.getAll()).thenReturn(existing.getPages());
+
+ task.importData(ImportStrategy.MERGE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list).getAll();
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(3)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ assertNullOrEmpty(task.getRollbackDeletes());
+ Assert.assertNotNull(task.getRollbackSaves());
+ Assert.assertEquals(3, task.getRollbackSaves().getPages().size());
+ Assert.assertEquals(existing.getPages(), task.getRollbackSaves().getPages());
+ }
+
+ public void testMerge_NewPages() throws Exception
+ {
+ Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ Page.PageSet existing = new
Builder().addPage("foo").addPage("bar").addPage("baz").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(3);
+ when(list.getAll()).thenReturn(existing.getPages());
+
+ task.importData(ImportStrategy.MERGE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list).getAll();
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(3)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ Assert.assertNotNull(task.getRollbackDeletes());
+ Assert.assertEquals(importing.getPages(), task.getRollbackDeletes().getPages());
+ assertNullOrEmpty(task.getRollbackSaves());
+ }
+
+ public void testMerge_NewAndSamePages() throws Exception
+ {
+ Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").addPage("page4").build();
+ Page.PageSet existing = new
Builder().addPage("page2").addPage("bar").addPage("page3").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(3);
+ when(list.getAll()).thenReturn(existing.getPages());
+
+ task.importData(ImportStrategy.MERGE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list).getAll();
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(4)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ Assert.assertNotNull(task.getRollbackDeletes());
+ Assert.assertEquals(2, task.getRollbackDeletes().getPages().size());
+ Assert.assertEquals(importing.getPages().get(0),
task.getRollbackDeletes().getPages().get(0));
+ Assert.assertEquals(importing.getPages().get(3),
task.getRollbackDeletes().getPages().get(1));
+
+ Assert.assertNotNull(task.getRollbackSaves());
+ Assert.assertEquals(2, task.getRollbackSaves().getPages().size());
+ Assert.assertEquals(existing.getPages().get(0),
task.getRollbackSaves().getPages().get(0));
+ Assert.assertEquals(existing.getPages().get(2),
task.getRollbackSaves().getPages().get(1));
+ }
+
+ public void testOverwrite_NoPages() throws Exception
+ {
+ Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(0); // no pages exist
+
+ task.importData(ImportStrategy.OVERWRITE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list, never()).getAll();
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(3)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ Assert.assertNotNull(task.getRollbackDeletes());
+ Assert.assertEquals(importing, task.getRollbackDeletes());
+ Assert.assertNull(task.getRollbackSaves());
+ }
+
+ public void testOverwrite_SamePages() throws Exception
+ {
+ Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ Page.PageSet existing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(3);
+ when(list.getAll()).thenReturn(existing.getPages());
+
+ task.importData(ImportStrategy.OVERWRITE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list).getAll();
+
+ int saveCount = importing.getPages().size() + existing.getPages().size();
+ for (Page page : existing.getPages())
+ {
+ verify(dataStorage).remove(page);
+ }
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(saveCount)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ assertNullOrEmpty(task.getRollbackDeletes());
+ Assert.assertNotNull(task.getRollbackSaves());
+ Assert.assertEquals(3, task.getRollbackSaves().getPages().size());
+ Assert.assertEquals(existing.getPages(), task.getRollbackSaves().getPages());
+ }
+
+ public void testOverwrite_NewPages() throws Exception
+ {
+ Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").build();
+ Page.PageSet existing = new
Builder().addPage("foo").addPage("bar").addPage("baz").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(3);
+ when(list.getAll()).thenReturn(existing.getPages());
+
+ task.importData(ImportStrategy.OVERWRITE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list).getAll();
+
+ int saveCount = importing.getPages().size() + existing.getPages().size();
+ for (Page page : existing.getPages())
+ {
+ verify(dataStorage).remove(page);
+ }
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(saveCount)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ Assert.assertNotNull(task.getRollbackDeletes());
+ Assert.assertEquals(importing.getPages(), task.getRollbackDeletes().getPages());
+
+ Assert.assertNotNull(task.getRollbackSaves());
+ Assert.assertEquals(existing.getPages(), task.getRollbackSaves().getPages());
+ }
+
+ public void testOverwrite_NewAndSamePages() throws Exception
+ {
+ Page.PageSet importing = new
Builder().addPage("page1").addPage("page2").addPage("page3").addPage("page4").build();
+ Page.PageSet existing = new
Builder().addPage("page2").addPage("bar").addPage("page3").build();
+ PageImportTask task = new PageImportTask(importing, siteKey, dataStorage);
+
+ when(dataStorage.find(Matchers.<Query<Page>>any())).thenReturn(list);
+ when(list.getAvailable()).thenReturn(3);
+ when(list.getAll()).thenReturn(existing.getPages());
+
+ task.importData(ImportStrategy.OVERWRITE);
+
+ verify(dataStorage).find(query("user", "foo"));
+ verify(list).getAvailable();
+ verify(list).getAll();
+
+ int saveCount = importing.getPages().size() + existing.getPages().size();
+ for (Page page : existing.getPages())
+ {
+ verify(dataStorage).remove(page);
+ }
+
+ for (Page page : importing.getPages())
+ {
+ verify(dataStorage).save(page);
+ }
+ verify(dataStorage, times(saveCount)).save();
+
+ verifyNoMoreInteractions(dataStorage, list);
+
+ Assert.assertNotNull(task.getRollbackDeletes());
+ Assert.assertEquals(2, task.getRollbackDeletes().getPages().size());
+ Assert.assertEquals(importing.getPages().get(0),
task.getRollbackDeletes().getPages().get(0));
+ Assert.assertEquals(importing.getPages().get(3),
task.getRollbackDeletes().getPages().get(1));
+
+ Assert.assertNotNull(task.getRollbackSaves());
+ Assert.assertEquals(existing.getPages(), task.getRollbackSaves().getPages());
+ }
+
+ private void assertNullOrEmpty(Page.PageSet pages)
+ {
+ if (pages != null)
+ {
+ Assert.assertTrue(pages.getPages().isEmpty());
+ }
+ }
+
+ private Query<Page> query(String ownerType, String ownerId)
+ {
+ return argThat(new QueryMatcher(new Query<Page>(ownerType, ownerId,
Page.class)));
+ }
+
+ private class QueryMatcher extends ArgumentMatcher<Query<Page>>
+ {
+ private Query<Page> query;
+
+ public QueryMatcher(Query<Page> query)
+ {
+ this.query = query;
+ }
+
+ @Override
+ public boolean matches(Object o)
+ {
+ if (query == o) return true;
+ if (!(o instanceof Query)) return false;
+
+ Query that = (Query) o;
+
+ if (!query.getClassType().equals(that.getClassType())) return false;
+ if (!query.getOwnerType().equals(that.getOwnerType())) return false;
+ if (!query.getOwnerId().equals(that.getOwnerId())) return false;
+
+ if (query.getName() != null ? !query.getName().equals(that.getName()) :
that.getName() != null) return false;
+ if (query.getTitle() != null ? !query.getTitle().equals(that.getTitle()) :
that.getTitle() != null) return false;
+
+ return true;
+ }
+ }
+
+ private static class Builder
+ {
+ private Page.PageSet pages;
+ public Builder()
+ {
+ pages = new Page.PageSet();
+ pages.setPages(new ArrayList<Page>());
+ }
+
+ public Builder addPage(String name)
+ {
+ PageData page= new PageData(null, "", name, null, null, null, null,
null, null, null, Collections.<String>emptyList(),
Collections.<ComponentData>emptyList(), "", "", null, false);
+ pages.getPages().add(new Page(page));
+
+ return this;
+ }
+
+ public Page.PageSet build()
+ {
+ return pages;
+ }
+ }
+}
Deleted:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-empty.xml
===================================================================
---
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-empty.xml 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-empty.xml 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ JBoss, Home of Professional Open Source.
- ~ Copyright 2011, Red Hat, Inc., and individual contributors
- ~ as indicated by the @author tags. See the copyright.txt file in the
- ~ distribution for a full listing of individual contributors.
- ~
- ~ This is free software; you can redistribute it and/or modify it
- ~ under the terms of the GNU Lesser General Public License as
- ~ published by the Free Software Foundation; either version 2.1 of
- ~ the License, or (at your option) any later version.
- ~
- ~ This software is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
- ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- ~ Lesser General Public License for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public
- ~ License along with this software; if not, write to the Free
- ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- -->
-
-<node-navigation
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2">
- <priority>3</priority>
- <page-nodes/>
-</node-navigation>
Copied:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-empty.xml
(from rev 6958,
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-empty.xml)
===================================================================
---
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-empty.xml
(rev 0)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-empty.xml 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ -->
+
+<node-navigation
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2">
+ <priority>3</priority>
+ <page-nodes/>
+</node-navigation>
Deleted:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-extended.xml
===================================================================
---
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-extended.xml 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-extended.xml 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,53 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-
-<!--
- ~ JBoss, Home of Professional Open Source.
- ~ Copyright 2011, Red Hat, Inc., and individual contributors
- ~ as indicated by the @author tags. See the copyright.txt file in the
- ~ distribution for a full listing of individual contributors.
- ~
- ~ This is free software; you can redistribute it and/or modify it
- ~ under the terms of the GNU Lesser General Public License as
- ~ published by the Free Software Foundation; either version 2.1 of
- ~ the License, or (at your option) any later version.
- ~
- ~ This software is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
- ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- ~ Lesser General Public License for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public
- ~ License along with this software; if not, write to the Free
- ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- -->
-
-<node-navigation
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2">
- <priority>1</priority>
- <page-nodes>
- <node>
- <name>hello-node</name>
- <label lang="cn">Dobrý den</label>
- <label lang="fr">Bonjour</label>
- <label lang="en">Hello</label>
- <label lang="es">Hola</label>
- <label lang="ja">こんにちは</label>
- <label lang="it">Ciào</label>
- <label lang="zh">你好</label>
- <label lang="zh-TW">Li-ho</label>
- </node>
- <node>
- <name>hello-node2</name>
- <label xml:lang="cn">Dobrý den</label>
- <label xml:lang="fr">Bonjour</label>
- <label xml:lang="en">Hello</label>
- <label xml:lang="es">Hola</label>
- <label xml:lang="ja">こんにちは</label>
- <label xml:lang="it">Ciào</label>
- <label xml:lang="zh">你好</label>
- <label lang="zh-tw">Li-ho</label>
- </node>
- </page-nodes>
-</node-navigation>
Copied:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-extended.xml
(from rev 6958,
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-extended.xml)
===================================================================
---
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-extended.xml
(rev 0)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-extended.xml 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,53 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ -->
+
+<node-navigation
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2">
+ <priority>1</priority>
+ <page-nodes>
+ <node>
+ <name>hello-node</name>
+ <label lang="cn">Dobrý den</label>
+ <label lang="fr">Bonjour</label>
+ <label lang="en">Hello</label>
+ <label lang="es">Hola</label>
+ <label lang="ja">こんにちは</label>
+ <label lang="it">Ciào</label>
+ <label lang="zh">你好</label>
+ <label lang="zh-TW">Li-ho</label>
+ </node>
+ <node>
+ <name>hello-node2</name>
+ <label xml:lang="cn">Dobrý den</label>
+ <label xml:lang="fr">Bonjour</label>
+ <label xml:lang="en">Hello</label>
+ <label xml:lang="es">Hola</label>
+ <label xml:lang="ja">こんにちは</label>
+ <label xml:lang="it">Ciào</label>
+ <label xml:lang="zh">你好</label>
+ <label lang="zh-tw">Li-ho</label>
+ </node>
+ </page-nodes>
+</node-navigation>
Deleted:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-fragment.xml
===================================================================
---
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-fragment.xml 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-fragment.xml 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,53 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!--
- ~ JBoss, Home of Professional Open Source.
- ~ Copyright 2011, Red Hat, Inc., and individual contributors
- ~ as indicated by the @author tags. See the copyright.txt file in the
- ~ distribution for a full listing of individual contributors.
- ~
- ~ This is free software; you can redistribute it and/or modify it
- ~ under the terms of the GNU Lesser General Public License as
- ~ published by the Free Software Foundation; either version 2.1 of
- ~ the License, or (at your option) any later version.
- ~
- ~ This software is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
- ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- ~ Lesser General Public License for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public
- ~ License along with this software; if not, write to the Free
- ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- -->
-<node-navigation
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2">
- <priority>1</priority>
- <page-nodes>
- <parent-uri>home</parent-uri>
- <node>
- <name>home-1</name>
- <label>Home 1</label>
- <node>
- <name>home-1-1</name>
- <label>Home 1-1</label>
- </node>
- <node>
- <name>home-1-2</name>
- <label>Home 1-1</label>
- </node>
- </node>
- </page-nodes>
- <page-nodes>
- <parent-uri>foo-bar</parent-uri>
- <node>
- <name>foo</name>
- <label>Foo</label>
- </node>
- <node>
- <name>bar</name>
- <label>Bar</label>
- </node>
- </page-nodes>
-</node-navigation>
Copied:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-fragment.xml
(from rev 6958,
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-fragment.xml)
===================================================================
---
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-fragment.xml
(rev 0)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation-fragment.xml 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,53 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ -->
+<node-navigation
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2">
+ <priority>1</priority>
+ <page-nodes>
+ <parent-uri>home</parent-uri>
+ <node>
+ <name>home-1</name>
+ <label>Home 1</label>
+ <node>
+ <name>home-1-1</name>
+ <label>Home 1-1</label>
+ </node>
+ <node>
+ <name>home-1-2</name>
+ <label>Home 1-1</label>
+ </node>
+ </node>
+ </page-nodes>
+ <page-nodes>
+ <parent-uri>foo-bar</parent-uri>
+ <node>
+ <name>foo</name>
+ <label>Foo</label>
+ </node>
+ <node>
+ <name>bar</name>
+ <label>Bar</label>
+ </node>
+ </page-nodes>
+</node-navigation>
Deleted:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation.xml
===================================================================
---
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation.xml 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation.xml 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,172 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-
-<!--
- ~ JBoss, Home of Professional Open Source.
- ~ Copyright 2011, Red Hat, Inc., and individual contributors
- ~ as indicated by the @author tags. See the copyright.txt file in the
- ~ distribution for a full listing of individual contributors.
- ~
- ~ This is free software; you can redistribute it and/or modify it
- ~ under the terms of the GNU Lesser General Public License as
- ~ published by the Free Software Foundation; either version 2.1 of
- ~ the License, or (at your option) any later version.
- ~
- ~ This software is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
- ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- ~ Lesser General Public License for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public
- ~ License along with this software; if not, write to the Free
- ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- -->
-
-<node-navigation
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2">
- <priority>111</priority>
- <page-nodes>
- <node>
- <uri>home</uri>
- <name>home</name>
- <label>#{portal.classic.home}</label>
- <visibility>DISPLAYED</visibility>
- <page-reference>portal::classic::homepage</page-reference>
- <node>
- <uri>home/home-1</uri>
- <name>home-1</name>
- <label>Home 1</label>
- <icon>StarAward</icon>
-
<start-publication-date>2011-01-10T12:13:55-05:00</start-publication-date>
-
<end-publication-date>2011-01-17T17:14:00-05:00</end-publication-date>
- <visibility>TEMPORAL</visibility>
- <node>
- <uri>home/home-1/empty</uri>
- <name>empty</name>
- <label>Empty</label>
- <visibility>HIDDEN</visibility>
- <page-reference>portal::classic::empty-page</page-reference>
- </node>
- </node>
- </node>
- <node>
- <uri>sitemap</uri>
- <name>sitemap</name>
- <label>#{portal.classic.sitemap}</label>
- <visibility>DISPLAYED</visibility>
- <page-reference>portal::classic::sitemap</page-reference>
- </node>
- <node>
- <uri>groupnavigation</uri>
- <name>groupnavigation</name>
- <label>#{portal.classic.groupnavigation}</label>
- <visibility>DISPLAYED</visibility>
- <page-reference>portal::classic::groupnavigation</page-reference>
- </node>
- <node>
- <uri>portalnavigation</uri>
- <name>portalnavigation</name>
- <label>#{portal.classic.portalnavigation}</label>
- <visibility>SYSTEM</visibility>
- <page-reference>portal::classic::portalnavigation</page-reference>
- </node>
- <node>
- <uri>register</uri>
- <name>register</name>
- <label>#{portal.classic.register}</label>
- <visibility>SYSTEM</visibility>
- <page-reference>portal::classic::register</page-reference>
- </node>
- <node>
- <uri>notfound</uri>
- <name>notfound</name>
- <label>NotFound</label>
- <visibility>SYSTEM</visibility>
- </node>
- <node>
- <uri>n0</uri>
- <name>n0</name>
- <label>n0</label>
- <visibility>DISPLAYED</visibility>
- <page-reference>portal::classic::n0</page-reference>
- <node>
- <uri>n0/n0</uri>
- <name>n0</name>
- <label>n0</label>
- <visibility>DISPLAYED</visibility>
- <page-reference>portal::classic::n0_n0</page-reference>
- <node>
- <uri>n0/n0/n0</uri>
- <name>n0</name>
- <label>n0</label>
- <visibility>DISPLAYED</visibility>
- <page-reference>portal::classic::n0_n0_n0</page-reference>
- </node>
- <node>
- <uri>n0/n0/n1</uri>
- <name>n1</name>
- <label>n1</label>
- <visibility>DISPLAYED</visibility>
- <page-reference>portal::classic::n0_n0_n1</page-reference>
- </node>
- <node>
- <uri>n0/n0/n2</uri>
- <name>n2</name>
- <label>n2</label>
- <visibility>DISPLAYED</visibility>
- <page-reference>portal::classic::n0_n0_n2</page-reference>
- </node>
- <node>
- <uri>n0/n0/n3</uri>
- <name>n3</name>
- <label>n3</label>
- <visibility>DISPLAYED</visibility>
- <page-reference>portal::classic::n0_n0_n3</page-reference>
- </node>
- <node>
- <uri>n0/n0/n4</uri>
- <name>n4</name>
- <label>n4</label>
- <visibility>DISPLAYED</visibility>
- <page-reference>portal::classic::n0_n0_n4</page-reference>
- </node>
- <node>
- <uri>n0/n0/n5</uri>
- <name>n5</name>
- <label>n5</label>
- <visibility>DISPLAYED</visibility>
- <page-reference>portal::classic::n0_n0_n5</page-reference>
- </node>
- <node>
- <uri>n0/n0/n6</uri>
- <name>n6</name>
- <label>n6</label>
- <visibility>DISPLAYED</visibility>
- <page-reference>portal::classic::n0_n0_n6</page-reference>
- </node>
- <node>
- <uri>n0/n0/n7</uri>
- <name>n7</name>
- <label>n7</label>
- <visibility>DISPLAYED</visibility>
- <page-reference>portal::classic::n0_n0_n7</page-reference>
- </node>
- <node>
- <uri>n0/n0/n8</uri>
- <name>n8</name>
- <label>n8</label>
- <visibility>DISPLAYED</visibility>
- <page-reference>portal::classic::n0_n0_n8</page-reference>
- </node>
- <node>
- <uri>n0/n0/n9</uri>
- <name>n9</name>
- <label>n9</label>
- <visibility>DISPLAYED</visibility>
- <page-reference>portal::classic::n0_n0_n9</page-reference>
- </node>
- </node>
- </node>
- </page-nodes>
-</node-navigation>
Copied:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation.xml
(from rev 6958,
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation.xml)
===================================================================
---
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation.xml
(rev 0)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/navigation.xml 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,172 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ -->
+
+<node-navigation
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2">
+ <priority>111</priority>
+ <page-nodes>
+ <node>
+ <uri>home</uri>
+ <name>home</name>
+ <label>#{portal.classic.home}</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::homepage</page-reference>
+ <node>
+ <uri>home/home-1</uri>
+ <name>home-1</name>
+ <label>Home 1</label>
+ <icon>StarAward</icon>
+
<start-publication-date>2011-01-10T12:13:55-05:00</start-publication-date>
+
<end-publication-date>2011-01-17T17:14:00-05:00</end-publication-date>
+ <visibility>TEMPORAL</visibility>
+ <node>
+ <uri>home/home-1/empty</uri>
+ <name>empty</name>
+ <label>Empty</label>
+ <visibility>HIDDEN</visibility>
+ <page-reference>portal::classic::empty-page</page-reference>
+ </node>
+ </node>
+ </node>
+ <node>
+ <uri>sitemap</uri>
+ <name>sitemap</name>
+ <label>#{portal.classic.sitemap}</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::sitemap</page-reference>
+ </node>
+ <node>
+ <uri>groupnavigation</uri>
+ <name>groupnavigation</name>
+ <label>#{portal.classic.groupnavigation}</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::groupnavigation</page-reference>
+ </node>
+ <node>
+ <uri>portalnavigation</uri>
+ <name>portalnavigation</name>
+ <label>#{portal.classic.portalnavigation}</label>
+ <visibility>SYSTEM</visibility>
+ <page-reference>portal::classic::portalnavigation</page-reference>
+ </node>
+ <node>
+ <uri>register</uri>
+ <name>register</name>
+ <label>#{portal.classic.register}</label>
+ <visibility>SYSTEM</visibility>
+ <page-reference>portal::classic::register</page-reference>
+ </node>
+ <node>
+ <uri>notfound</uri>
+ <name>notfound</name>
+ <label>NotFound</label>
+ <visibility>SYSTEM</visibility>
+ </node>
+ <node>
+ <uri>n0</uri>
+ <name>n0</name>
+ <label>n0</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0</page-reference>
+ <node>
+ <uri>n0/n0</uri>
+ <name>n0</name>
+ <label>n0</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0</page-reference>
+ <node>
+ <uri>n0/n0/n0</uri>
+ <name>n0</name>
+ <label>n0</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n0</page-reference>
+ </node>
+ <node>
+ <uri>n0/n0/n1</uri>
+ <name>n1</name>
+ <label>n1</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n1</page-reference>
+ </node>
+ <node>
+ <uri>n0/n0/n2</uri>
+ <name>n2</name>
+ <label>n2</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n2</page-reference>
+ </node>
+ <node>
+ <uri>n0/n0/n3</uri>
+ <name>n3</name>
+ <label>n3</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n3</page-reference>
+ </node>
+ <node>
+ <uri>n0/n0/n4</uri>
+ <name>n4</name>
+ <label>n4</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n4</page-reference>
+ </node>
+ <node>
+ <uri>n0/n0/n5</uri>
+ <name>n5</name>
+ <label>n5</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n5</page-reference>
+ </node>
+ <node>
+ <uri>n0/n0/n6</uri>
+ <name>n6</name>
+ <label>n6</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n6</page-reference>
+ </node>
+ <node>
+ <uri>n0/n0/n7</uri>
+ <name>n7</name>
+ <label>n7</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n7</page-reference>
+ </node>
+ <node>
+ <uri>n0/n0/n8</uri>
+ <name>n8</name>
+ <label>n8</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n8</page-reference>
+ </node>
+ <node>
+ <uri>n0/n0/n9</uri>
+ <name>n9</name>
+ <label>n9</label>
+ <visibility>DISPLAYED</visibility>
+ <page-reference>portal::classic::n0_n0_n9</page-reference>
+ </node>
+ </node>
+ </node>
+ </page-nodes>
+</node-navigation>
Deleted:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-empty.xml
===================================================================
---
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-empty.xml 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-empty.xml 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,35 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!--
- ~ JBoss, Home of Professional Open Source.
- ~ Copyright 2011, Red Hat, Inc., and individual contributors
- ~ as indicated by the @author tags. See the copyright.txt file in the
- ~ distribution for a full listing of individual contributors.
- ~
- ~ This is free software; you can redistribute it and/or modify it
- ~ under the terms of the GNU Lesser General Public License as
- ~ published by the Free Software Foundation; either version 2.1 of
- ~ the License, or (at your option) any later version.
- ~
- ~ This software is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
- ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- ~ Lesser General Public License for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public
- ~ License along with this software; if not, write to the Free
- ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- -->
-
-<page-set
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2">
- <page>
- <name>empty-page</name>
- <title>Empty</title>
- <access-permissions>Everyone</access-permissions>
- <edit-permission>*:/platform/administrators</edit-permission>
- <show-max-window>false</show-max-window>
- </page>
-
-</page-set>
\ No newline at end of file
Copied:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-empty.xml
(from rev 6958,
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-empty.xml)
===================================================================
---
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-empty.xml
(rev 0)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-empty.xml 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,35 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ -->
+
+<page-set
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2">
+ <page>
+ <name>empty-page</name>
+ <title>Empty</title>
+ <access-permissions>Everyone</access-permissions>
+ <edit-permission>*:/platform/administrators</edit-permission>
+ <show-max-window>false</show-max-window>
+ </page>
+
+</page-set>
\ No newline at end of file
Deleted:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-homepage.xml
===================================================================
---
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-homepage.xml 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-homepage.xml 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ JBoss, Home of Professional Open Source.
- ~ Copyright 2011, Red Hat, Inc., and individual contributors
- ~ as indicated by the @author tags. See the copyright.txt file in the
- ~ distribution for a full listing of individual contributors.
- ~
- ~ This is free software; you can redistribute it and/or modify it
- ~ under the terms of the GNU Lesser General Public License as
- ~ published by the Free Software Foundation; either version 2.1 of
- ~ the License, or (at your option) any later version.
- ~
- ~ This software is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
- ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- ~ Lesser General Public License for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public
- ~ License along with this software; if not, write to the Free
- ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- -->
-
-<page-set
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2">
-
- <page>
- <name>homepage</name>
- <title>Home Page</title>
- <access-permissions>Everyone</access-permissions>
- <edit-permission>*:/platform/administrators</edit-permission>
- <portlet-application>
- <portlet>
- <application-ref>web</application-ref>
- <portlet-ref>HomePagePortlet</portlet-ref>
- <preferences>
- <preference>
- <name>template</name>
-
<value>system:/templates/groovy/webui/component/UIHomePagePortlet.gtmpl</value>
- <read-only>false</read-only>
- </preference>
- </preferences>
- </portlet>
- <title>Home Page portlet</title>
- <access-permissions>Everyone</access-permissions>
- <show-info-bar>false</show-info-bar>
- <show-application-state>false</show-application-state>
- <show-application-mode>false</show-application-mode>
- </portlet-application>
- </page>
-
-</page-set>
Copied:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-homepage.xml
(from rev 6958,
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-homepage.xml)
===================================================================
---
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-homepage.xml
(rev 0)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-homepage.xml 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ -->
+
+<page-set
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2">
+
+ <page>
+ <name>homepage</name>
+ <title>Home Page</title>
+ <access-permissions>Everyone</access-permissions>
+ <edit-permission>*:/platform/administrators</edit-permission>
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>HomePagePortlet</portlet-ref>
+ <preferences>
+ <preference>
+ <name>template</name>
+
<value>system:/templates/groovy/webui/component/UIHomePagePortlet.gtmpl</value>
+ <read-only>false</read-only>
+ </preference>
+ </preferences>
+ </portlet>
+ <title>Home Page portlet</title>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ <show-application-state>false</show-application-state>
+ <show-application-mode>false</show-application-mode>
+ </portlet-application>
+ </page>
+
+</page-set>
Deleted:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-loaded.xml
===================================================================
---
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-loaded.xml 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-loaded.xml 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,123 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!--
- ~ JBoss, Home of Professional Open Source.
- ~ Copyright 2011, Red Hat, Inc., and individual contributors
- ~ as indicated by the @author tags. See the copyright.txt file in the
- ~ distribution for a full listing of individual contributors.
- ~
- ~ This is free software; you can redistribute it and/or modify it
- ~ under the terms of the GNU Lesser General Public License as
- ~ published by the Free Software Foundation; either version 2.1 of
- ~ the License, or (at your option) any later version.
- ~
- ~ This software is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
- ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- ~ Lesser General Public License for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public
- ~ License along with this software; if not, write to the Free
- ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- -->
-
-<page-set
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2">
- <page>
- <name>loaded-page</name>
- <title>Loaded Page</title>
-
<access-permissions>manager:/platform/administrators;manager:/platform/users</access-permissions>
- <edit-permission>*:/platform/administrators</edit-permission>
- <show-max-window>false</show-max-window>
- <container id="rootContainer"
template="system:/groovy/portal/webui/container/UIContainer.gtmpl">
- <access-permissions>Everyone</access-permissions>
- <container id="c1"
template="system:/groovy/portal/webui/container/UIContainer.gtmpl">
- <access-permissions>*:/platform/users</access-permissions>
- <portlet-application>
- <portlet>
- <application-ref>web</application-ref>
- <portlet-ref>HomePagePortlet</portlet-ref>
- <preferences>
- <preference>
- <name>template</name>
-
<value>system:/templates/groovy/webui/component/UIHomePagePortlet.gtmpl</value>
- <read-only>true</read-only>
- </preference>
- <preference>
- <name>empty-preference-value</name>
- <value></value>
- </preference>
- <preference>
- <name>no-preference-value</name>
- </preference>
- </preferences>
- </portlet>
-
<theme>Mac:MacTheme::Default:DefaultTheme::Vista:VistaTheme</theme>
- <title>Home Page portlet</title>
- <access-permissions>Everyone</access-permissions>
- <show-info-bar>true</show-info-bar>
- <show-application-state>true</show-application-state>
- <show-application-mode>true</show-application-mode>
- </portlet-application>
- </container>
- <container id="c2"
template="system:/groovy/portal/webui/container/UITableColumnContainer.gtmpl">
- <access-permissions>*:/platform/guests</access-permissions>
- <factory-id>TableColumnContainer</factory-id>
- <container id="c2-1"
template="system:/groovy/portal/webui/container/UIContainer.gtmpl"
width="300px" height="400px">
- <access-permissions>Everyone</access-permissions>
- <portlet-application>
- <portlet>
- <application-ref>exoadmin</application-ref>
- <portlet-ref>ApplicationRegistryPortlet</portlet-ref>
- </portlet>
-
<theme>Default:DefaultTheme::Mac:MacTheme::Vista:VistaTheme</theme>
- <title>Application Registry</title>
-
<access-permissions>*:/platform/administrators;*:/organization/management/executive-board</access-permissions>
- <show-info-bar>false</show-info-bar>
- <show-application-state>true</show-application-state>
- <show-application-mode>false</show-application-mode>
- <description>Application Registry</description>
- <icon>PortletIcon</icon>
- <width>250px</width>
- <height>350px</height>
- </portlet-application>
- </container>
- <container id="c2-2"
template="system:/groovy/portal/webui/container/UIContainer.gtmpl"
width="200px" height="300px">
- <access-permissions>/platform/users</access-permissions>
- <gadget-application>
- <gadget>
- <gadget-ref>Calendar</gadget-ref>
- </gadget>
-
<theme>Vista:VistaTheme::Mac:MacTheme::Default:DefaultTheme</theme>
- <title>Calendar Title</title>
-
<access-permissions>*:/platform/administrators;*:/organization/management/executive-board</access-permissions>
- <show-info-bar>true</show-info-bar>
- <show-application-state>false</show-application-state>
- <show-application-mode>false</show-application-mode>
- <description>Calendar Description</description>
- <icon>StarAwardIcon</icon>
- <width>100px</width>
- <height>200px</height>
- </gadget-application>
- </container>
- </container>
- <container id="c3"
template="system:/groovy/portal/webui/container/UIContainer.gtmpl">
- <access-permissions>Everyone</access-permissions>
- <portlet-application>
- <portlet>
- <application-ref>web</application-ref>
- <portlet-ref>SiteMapPortlet</portlet-ref>
- </portlet>
-
<theme>Default:DefaultTheme::Vista:VistaTheme::Mac:MacTheme</theme>
- <title>SiteMap</title>
- <access-permissions>*:/platform/users</access-permissions>
- <show-info-bar>true</show-info-bar>
- <show-application-state>true</show-application-state>
- <show-application-mode>false</show-application-mode>
- <description>SiteMap</description>
- </portlet-application>
- </container>
- </container>
- </page>
-</page-set>
\ No newline at end of file
Copied:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-loaded.xml
(from rev 6958,
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-loaded.xml)
===================================================================
---
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-loaded.xml
(rev 0)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/pages-loaded.xml 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,123 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ -->
+
+<page-set
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2">
+ <page>
+ <name>loaded-page</name>
+ <title>Loaded Page</title>
+
<access-permissions>manager:/platform/administrators;manager:/platform/users</access-permissions>
+ <edit-permission>*:/platform/administrators</edit-permission>
+ <show-max-window>false</show-max-window>
+ <container id="rootContainer"
template="system:/groovy/portal/webui/container/UIContainer.gtmpl">
+ <access-permissions>Everyone</access-permissions>
+ <container id="c1"
template="system:/groovy/portal/webui/container/UIContainer.gtmpl">
+ <access-permissions>*:/platform/users</access-permissions>
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>HomePagePortlet</portlet-ref>
+ <preferences>
+ <preference>
+ <name>template</name>
+
<value>system:/templates/groovy/webui/component/UIHomePagePortlet.gtmpl</value>
+ <read-only>true</read-only>
+ </preference>
+ <preference>
+ <name>empty-preference-value</name>
+ <value></value>
+ </preference>
+ <preference>
+ <name>no-preference-value</name>
+ </preference>
+ </preferences>
+ </portlet>
+
<theme>Mac:MacTheme::Default:DefaultTheme::Vista:VistaTheme</theme>
+ <title>Home Page portlet</title>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>true</show-info-bar>
+ <show-application-state>true</show-application-state>
+ <show-application-mode>true</show-application-mode>
+ </portlet-application>
+ </container>
+ <container id="c2"
template="system:/groovy/portal/webui/container/UITableColumnContainer.gtmpl">
+ <access-permissions>*:/platform/guests</access-permissions>
+ <factory-id>TableColumnContainer</factory-id>
+ <container id="c2-1"
template="system:/groovy/portal/webui/container/UIContainer.gtmpl"
width="300px" height="400px">
+ <access-permissions>Everyone</access-permissions>
+ <portlet-application>
+ <portlet>
+ <application-ref>exoadmin</application-ref>
+ <portlet-ref>ApplicationRegistryPortlet</portlet-ref>
+ </portlet>
+
<theme>Default:DefaultTheme::Mac:MacTheme::Vista:VistaTheme</theme>
+ <title>Application Registry</title>
+
<access-permissions>*:/platform/administrators;*:/organization/management/executive-board</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ <show-application-state>true</show-application-state>
+ <show-application-mode>false</show-application-mode>
+ <description>Application Registry</description>
+ <icon>PortletIcon</icon>
+ <width>250px</width>
+ <height>350px</height>
+ </portlet-application>
+ </container>
+ <container id="c2-2"
template="system:/groovy/portal/webui/container/UIContainer.gtmpl"
width="200px" height="300px">
+ <access-permissions>/platform/users</access-permissions>
+ <gadget-application>
+ <gadget>
+ <gadget-ref>Calendar</gadget-ref>
+ </gadget>
+
<theme>Vista:VistaTheme::Mac:MacTheme::Default:DefaultTheme</theme>
+ <title>Calendar Title</title>
+
<access-permissions>*:/platform/administrators;*:/organization/management/executive-board</access-permissions>
+ <show-info-bar>true</show-info-bar>
+ <show-application-state>false</show-application-state>
+ <show-application-mode>false</show-application-mode>
+ <description>Calendar Description</description>
+ <icon>StarAwardIcon</icon>
+ <width>100px</width>
+ <height>200px</height>
+ </gadget-application>
+ </container>
+ </container>
+ <container id="c3"
template="system:/groovy/portal/webui/container/UIContainer.gtmpl">
+ <access-permissions>Everyone</access-permissions>
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>SiteMapPortlet</portlet-ref>
+ </portlet>
+
<theme>Default:DefaultTheme::Vista:VistaTheme::Mac:MacTheme</theme>
+ <title>SiteMap</title>
+ <access-permissions>*:/platform/users</access-permissions>
+ <show-info-bar>true</show-info-bar>
+ <show-application-state>true</show-application-state>
+ <show-application-mode>false</show-application-mode>
+ <description>SiteMap</description>
+ </portlet-application>
+ </container>
+ </container>
+ </page>
+</page-set>
\ No newline at end of file
Deleted:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/portal.xml
===================================================================
---
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/portal.xml 2011-07-29
21:04:11 UTC (rev 6958)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/portal.xml 2011-07-30
02:53:38 UTC (rev 6960)
@@ -1,100 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-
-<!--
- ~ JBoss, Home of Professional Open Source.
- ~ Copyright 2011, Red Hat, Inc., and individual contributors
- ~ as indicated by the @author tags. See the copyright.txt file in the
- ~ distribution for a full listing of individual contributors.
- ~
- ~ This is free software; you can redistribute it and/or modify it
- ~ under the terms of the GNU Lesser General Public License as
- ~ published by the Free Software Foundation; either version 2.1 of
- ~ the License, or (at your option) any later version.
- ~
- ~ This software is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
- ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- ~ Lesser General Public License for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public
- ~ License along with this software; if not, write to the Free
- ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- -->
-
-<portal-config
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2">
- <portal-name>classic</portal-name>
- <label>site-label</label>
- <description>site-description</description>
- <locale>en</locale>
- <access-permissions>Everyone</access-permissions>
- <edit-permission>*:/platform/administrators</edit-permission>
- <properties>
- <entry key="sessionAlive">onDemand</entry>
- </properties>
- <portal-layout>
- <portlet-application>
- <portlet>
- <application-ref>web</application-ref>
- <portlet-ref>BannerPortlet</portlet-ref>
- <preferences>
- <preference>
- <name>template</name>
-
<value>par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl</value>
- <read-only>false</read-only>
- </preference>
- </preferences>
- </portlet>
- <theme>Default:DefaultTheme::Mac:MacTheme::Vista:VistaTheme</theme>
- <title>Banner</title>
-
<access-permissions>*:/platform/administrators;*:/organization/management/executive-board</access-permissions>
- <show-info-bar>false</show-info-bar>
- <show-application-state>true</show-application-state>
- <show-application-mode>false</show-application-mode>
- <description>Banner Portlet</description>
- <icon>PortletIcon</icon>
- <width>250px</width>
- <height>350px</height>
- </portlet-application>
- <portlet-application>
- <portlet>
- <application-ref>web</application-ref>
- <portlet-ref>NavigationPortlet</portlet-ref>
- </portlet>
- <access-permissions>Everyone</access-permissions>
- <show-info-bar>false</show-info-bar>
- <show-application-state>true</show-application-state>
- <show-application-mode>true</show-application-mode>
- </portlet-application>
- <portlet-application>
- <portlet>
- <application-ref>web</application-ref>
- <portlet-ref>BreadcumbsPortlet</portlet-ref>
- </portlet>
- <access-permissions>Everyone</access-permissions>
- <show-info-bar>false</show-info-bar>
- <show-application-state>true</show-application-state>
- <show-application-mode>true</show-application-mode>
- </portlet-application>
- <page-body/>
- <portlet-application>
- <portlet>
- <application-ref>web</application-ref>
- <portlet-ref>FooterPortlet</portlet-ref>
- <preferences>
- <preference>
- <name>template</name>
-
<value>par:/groovy/groovy/webui/component/UIFooterPortlet.gtmpl</value>
- <read-only>false</read-only>
- </preference>
- </preferences>
- </portlet>
- <access-permissions>Everyone</access-permissions>
- <show-info-bar>false</show-info-bar>
- <show-application-state>true</show-application-state>
- <show-application-mode>true</show-application-mode>
- </portlet-application>
- </portal-layout>
-</portal-config>
\ No newline at end of file
Copied:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/portal.xml
(from rev 6958,
portal/branches/gatein-management/component/portal/src/test/resources/org/exoplatform/portal/mop/management/portal.xml)
===================================================================
---
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/portal.xml
(rev 0)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/mop/management/portal.xml 2011-07-30
02:53:38 UTC (rev 6960)
@@ -0,0 +1,100 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ -->
+
+<portal-config
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2">
+ <portal-name>classic</portal-name>
+ <label>site-label</label>
+ <description>site-description</description>
+ <locale>en</locale>
+ <access-permissions>Everyone</access-permissions>
+ <edit-permission>*:/platform/administrators</edit-permission>
+ <properties>
+ <entry key="sessionAlive">onDemand</entry>
+ </properties>
+ <portal-layout>
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>BannerPortlet</portlet-ref>
+ <preferences>
+ <preference>
+ <name>template</name>
+
<value>par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl</value>
+ <read-only>false</read-only>
+ </preference>
+ </preferences>
+ </portlet>
+ <theme>Default:DefaultTheme::Mac:MacTheme::Vista:VistaTheme</theme>
+ <title>Banner</title>
+
<access-permissions>*:/platform/administrators;*:/organization/management/executive-board</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ <show-application-state>true</show-application-state>
+ <show-application-mode>false</show-application-mode>
+ <description>Banner Portlet</description>
+ <icon>PortletIcon</icon>
+ <width>250px</width>
+ <height>350px</height>
+ </portlet-application>
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>NavigationPortlet</portlet-ref>
+ </portlet>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ <show-application-state>true</show-application-state>
+ <show-application-mode>true</show-application-mode>
+ </portlet-application>
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>BreadcumbsPortlet</portlet-ref>
+ </portlet>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ <show-application-state>true</show-application-state>
+ <show-application-mode>true</show-application-mode>
+ </portlet-application>
+ <page-body/>
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>FooterPortlet</portlet-ref>
+ <preferences>
+ <preference>
+ <name>template</name>
+
<value>par:/groovy/groovy/webui/component/UIFooterPortlet.gtmpl</value>
+ <read-only>false</read-only>
+ </preference>
+ </preferences>
+ </portlet>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ <show-application-state>true</show-application-state>
+ <show-application-mode>true</show-application-mode>
+ </portlet-application>
+ </portal-layout>
+</portal-config>
\ No newline at end of file
Modified: portal/trunk/packaging/jboss-as5/pkg/pom.xml
===================================================================
--- portal/trunk/packaging/jboss-as5/pkg/pom.xml 2011-07-30 02:15:53 UTC (rev 6959)
+++ portal/trunk/packaging/jboss-as5/pkg/pom.xml 2011-07-30 02:53:38 UTC (rev 6960)
@@ -358,6 +358,30 @@
<artifactId>mop-spi</artifactId>
</dependency>
+ <!-- GateIn Management -->
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-rest</artifactId>
+ </dependency>
+
+ <!-- Staxnav -->
+ <dependency>
+ <groupId>org.staxnav</groupId>
+ <artifactId>staxnav.core</artifactId>
+ </dependency>
+
<!-- GateIn Captcha -->
<dependency>
<groupId>org.gatein.captcha</groupId>
Modified: portal/trunk/packaging/jboss-as6/pkg/pom.xml
===================================================================
--- portal/trunk/packaging/jboss-as6/pkg/pom.xml 2011-07-30 02:15:53 UTC (rev 6959)
+++ portal/trunk/packaging/jboss-as6/pkg/pom.xml 2011-07-30 02:53:38 UTC (rev 6960)
@@ -356,6 +356,30 @@
<artifactId>mop-spi</artifactId>
</dependency>
+ <!-- GateIn Management -->
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-rest</artifactId>
+ </dependency>
+
+ <!-- Staxnav -->
+ <dependency>
+ <groupId>org.staxnav</groupId>
+ <artifactId>staxnav.core</artifactId>
+ </dependency>
+
<!-- GateIn Captcha -->
<dependency>
<groupId>org.gatein.captcha</groupId>
Modified: portal/trunk/packaging/jetty/pkg/pom.xml
===================================================================
--- portal/trunk/packaging/jetty/pkg/pom.xml 2011-07-30 02:15:53 UTC (rev 6959)
+++ portal/trunk/packaging/jetty/pkg/pom.xml 2011-07-30 02:53:38 UTC (rev 6960)
@@ -356,6 +356,30 @@
<artifactId>mop-spi</artifactId>
</dependency>
+ <!-- GateIn Management -->
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-rest</artifactId>
+ </dependency>
+
+ <!-- Staxnav -->
+ <dependency>
+ <groupId>org.staxnav</groupId>
+ <artifactId>staxnav.core</artifactId>
+ </dependency>
+
<!-- GateIn Captcha -->
<dependency>
<groupId>org.gatein.captcha</groupId>
Modified: portal/trunk/packaging/tomcat/pkg/pom.xml
===================================================================
--- portal/trunk/packaging/tomcat/pkg/pom.xml 2011-07-30 02:15:53 UTC (rev 6959)
+++ portal/trunk/packaging/tomcat/pkg/pom.xml 2011-07-30 02:53:38 UTC (rev 6960)
@@ -348,6 +348,30 @@
<artifactId>mop-spi</artifactId>
</dependency>
+ <!-- GateIn Management -->
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-rest</artifactId>
+ </dependency>
+
+ <!-- Staxnav -->
+ <dependency>
+ <groupId>org.staxnav</groupId>
+ <artifactId>staxnav.core</artifactId>
+ </dependency>
+
<!-- GateIn Captcha -->
<dependency>
<groupId>org.gatein.captcha</groupId>
Modified: portal/trunk/pom.xml
===================================================================
--- portal/trunk/pom.xml 2011-07-30 02:15:53 UTC (rev 6959)
+++ portal/trunk/pom.xml 2011-07-30 02:53:38 UTC (rev 6960)
@@ -49,6 +49,7 @@
<org.picketlink.idm>1.3.0.Alpha03</org.picketlink.idm>
<org.gatein.wsrp.version>2.1.0-Beta04</org.gatein.wsrp.version>
<org.gatein.mop.version>1.1.0-Beta05</org.gatein.mop.version>
+ <org.gatein.mgmt.version>1.0.0-Beta01</org.gatein.mgmt.version>
<org.slf4j.version>1.5.8</org.slf4j.version>
<commons-pool.version>1.5.5</commons-pool.version>
<rhino.version>1.6R5</rhino.version>
@@ -56,6 +57,7 @@
<javax.servlet.version>2.5</javax.servlet.version>
<version.chromattic>1.1.0-beta6</version.chromattic>
<version.reflext>1.1.0-beta12</version.reflext>
+ <org.staxnav.version>0.9.4</org.staxnav.version>
<jcip.version>1.0</jcip.version>
<!-- ************** -->
@@ -321,6 +323,27 @@
<artifactId>mop-core</artifactId>
<version>${org.gatein.mop.version}</version>
</dependency>
+ <!-- Gatein Mgmt -->
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-api</artifactId>
+ <version>${org.gatein.mgmt.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-spi</artifactId>
+ <version>${org.gatein.mgmt.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-core</artifactId>
+ <version>${org.gatein.mgmt.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.management</groupId>
+ <artifactId>gatein-management-rest</artifactId>
+ <version>${org.gatein.mgmt.version}</version>
+ </dependency>
<!-- WSRP -->
<dependency>
<groupId>org.gatein.wsrp</groupId>
@@ -637,6 +660,13 @@
<version>${version.chromattic}</version>
</dependency>
+ <!-- Staxnav -->
+ <dependency>
+ <groupId>org.staxnav</groupId>
+ <artifactId>staxnav.core</artifactId>
+ <version>${org.staxnav.version}</version>
+ </dependency>
+
<!-- Picketlink -->
<dependency>
<groupId>org.picketlink.idm</groupId>