You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by at...@apache.org on 2008/04/10 13:19:15 UTC
svn commit: r646760 - in /portals/jetspeed-2/portal/trunk/maven:
jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/
jetspeed-maven-utils/
jetspeed-maven-utils/src/main/java/org/apache/jetspeed/maven/utils/
Author: ate
Date: Thu Apr 10 04:19:07 2008
New Revision: 646760
URL: http://svn.apache.org/viewvc?rev=646760&view=rev
Log:
Enhancement to the jetspeed-db-maven-plugin: now supporting importing JetspeedSerializer format xml too (j2-seed.xml)
Added:
portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/src/main/java/org/apache/jetspeed/maven/utils/MavenToolsLogger.java (with props)
portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/src/main/java/org/apache/jetspeed/maven/utils/Serializer.java (with props)
Modified:
portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/LoadMojo.java
portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/pom.xml
Modified: portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/LoadMojo.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/LoadMojo.java?rev=646760&r1=646759&r2=646760&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/LoadMojo.java (original)
+++ portals/jetspeed-2/portal/trunk/maven/jetspeed-db-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/LoadMojo.java Thu Apr 10 04:19:07 2008
@@ -20,6 +20,7 @@
import org.apache.jetspeed.maven.utils.Artifacts;
import org.apache.jetspeed.maven.utils.DbConnection;
+import org.apache.jetspeed.maven.utils.Serializer;
import org.apache.jetspeed.maven.utils.SqlScripts;
import org.apache.jetspeed.maven.utils.UnpackResources;
import org.apache.maven.plugin.AbstractMojo;
@@ -48,6 +49,11 @@
/**
* @parameter
*/
+ private Serializer seed;
+
+ /**
+ * @parameter
+ */
private UnpackResources unpack;
/**
@@ -99,6 +105,11 @@
}
connection.checkSettings(settings);
sql.execute(connection, getLog());
+ }
+
+ if (seed != null && seed.isConfigered())
+ {
+ seed.execute(getLog());
}
}
}
Modified: portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/pom.xml?rev=646760&r1=646759&r2=646760&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/pom.xml (original)
+++ portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/pom.xml Thu Apr 10 04:19:07 2008
@@ -41,6 +41,10 @@
<version>2.0.7</version>
</dependency>
<dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>jetspeed-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0.7</version>
Added: portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/src/main/java/org/apache/jetspeed/maven/utils/MavenToolsLogger.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/src/main/java/org/apache/jetspeed/maven/utils/MavenToolsLogger.java?rev=646760&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/src/main/java/org/apache/jetspeed/maven/utils/MavenToolsLogger.java (added)
+++ portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/src/main/java/org/apache/jetspeed/maven/utils/MavenToolsLogger.java Thu Apr 10 04:19:07 2008
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.maven.utils;
+
+import org.apache.jetspeed.tools.ToolsLogger;
+import org.apache.maven.plugin.logging.Log;
+
+/**
+ * @version $Id$
+ *
+ */
+public class MavenToolsLogger implements ToolsLogger
+{
+ Log mavenLogger;
+
+ public MavenToolsLogger(Log mavenLogger)
+ {
+ this.mavenLogger = mavenLogger;
+ }
+
+ public void debug(CharSequence content, Throwable error)
+ {
+ mavenLogger.debug(content, error);
+ }
+
+ public void debug(CharSequence content)
+ {
+ mavenLogger.debug(content);
+ }
+
+ public void debug(Throwable error)
+ {
+ mavenLogger.debug(error);
+ }
+
+ public void error(CharSequence content, Throwable error)
+ {
+ mavenLogger.error(content, error);
+ }
+
+ public void error(CharSequence content)
+ {
+ mavenLogger.error(content);
+ }
+
+ public void error(Throwable error)
+ {
+ mavenLogger.error(error);
+ }
+
+ public void info(CharSequence content, Throwable error)
+ {
+ mavenLogger.info(content, error);
+ }
+
+ public void info(CharSequence content)
+ {
+ mavenLogger.info(content);
+ }
+
+ public void info(Throwable error)
+ {
+ mavenLogger.info(error);
+ }
+
+ public boolean isDebugEnabled()
+ {
+ return mavenLogger.isDebugEnabled();
+ }
+
+ public boolean isErrorEnabled()
+ {
+ return mavenLogger.isErrorEnabled();
+ }
+
+ public boolean isInfoEnabled()
+ {
+ return mavenLogger.isInfoEnabled();
+ }
+
+ public boolean isWarnEnabled()
+ {
+ return mavenLogger.isWarnEnabled();
+ }
+
+ public void warn(CharSequence content, Throwable error)
+ {
+ mavenLogger.warn(content, error);
+ }
+
+ public void warn(CharSequence content)
+ {
+ mavenLogger.warn(content);
+ }
+
+ public void warn(Throwable error)
+ {
+ mavenLogger.warn(error);
+ }
+}
Propchange: portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/src/main/java/org/apache/jetspeed/maven/utils/MavenToolsLogger.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/src/main/java/org/apache/jetspeed/maven/utils/MavenToolsLogger.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/src/main/java/org/apache/jetspeed/maven/utils/MavenToolsLogger.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/src/main/java/org/apache/jetspeed/maven/utils/Serializer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/src/main/java/org/apache/jetspeed/maven/utils/Serializer.java?rev=646760&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/src/main/java/org/apache/jetspeed/maven/utils/Serializer.java (added)
+++ portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/src/main/java/org/apache/jetspeed/maven/utils/Serializer.java Thu Apr 10 04:19:07 2008
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.maven.utils;
+
+import java.io.File;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.jetspeed.serializer.JetspeedSerializerApplication;
+import org.apache.jetspeed.serializer.SerializerException;
+import org.apache.jetspeed.tools.ToolsLogger;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
+
+public class Serializer
+{
+ private static final String SERIALIZER_APPLICATION_CLASS_NAME = "org.apache.jetspeed.tools.db.serializer.JetspeedSerializerApplicationImpl";
+
+ private String filterPropertiesFileName;
+ private String categories;
+ private String applicationRootPath;
+ private String[] files;
+ private Map initProperties;
+
+ public boolean isConfigered() throws MojoExecutionException
+ {
+ boolean configured = false;
+
+ if (files != null && files.length > 0)
+ {
+ for (int i = 0; i < files.length; i++)
+ {
+ if (files[i] == null || files[i].length() == 0)
+ {
+ throw new MojoExecutionException( "Serializer seed element ["+i+"] is empty");
+ }
+
+ if (!(new File(files[i]).exists()))
+ {
+ throw new MojoExecutionException( "Serializer seed file or directory "+files[i]+" not found");
+ }
+ }
+ if (applicationRootPath == null)
+ {
+ throw new MojoExecutionException("Serializer applicationRootPath is required");
+ }
+ configured = true;
+ }
+ return configured;
+ }
+
+ public void execute(Log log) throws MojoExecutionException
+ {
+
+ JetspeedSerializerApplication app = null;
+ try
+ {
+ Class dfClass = Class.forName(SERIALIZER_APPLICATION_CLASS_NAME, true, Thread.currentThread().getContextClassLoader());
+ app = (JetspeedSerializerApplication) dfClass.newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new MojoExecutionException("Cannot find or load JetspeedSerializerApplication class "+ SERIALIZER_APPLICATION_CLASS_NAME, e);
+ }
+
+ ToolsLogger logger = new MavenToolsLogger(log);
+
+ Properties props = null;
+ if (initProperties != null)
+ {
+ props = new Properties();
+ props.putAll(initProperties);
+ }
+
+ try
+ {
+ if (files != null && files.length > 0)
+ {
+ app.importFiles(logger, applicationRootPath, categories, filterPropertiesFileName, props, files);
+ }
+ }
+ catch (SerializerException se)
+ {
+ throw new MojoExecutionException("Serializer error: ",se);
+ }
+ }
+}
Propchange: portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/src/main/java/org/apache/jetspeed/maven/utils/Serializer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/src/main/java/org/apache/jetspeed/maven/utils/Serializer.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: portals/jetspeed-2/portal/trunk/maven/jetspeed-maven-utils/src/main/java/org/apache/jetspeed/maven/utils/Serializer.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org