continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tryg...@apache.org
Subject svn commit: r179234 - in /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum: core/action/ core/action/AbstractContinuumAction.java core/action/CheckOutProjectContinuumAction.java core/action/ContinuumAction.java scm/queue/CheckOutTaskExecutor.java
Date Tue, 31 May 2005 16:29:15 GMT
Author: trygvis
Date: Tue May 31 09:29:14 2005
New Revision: 179234

URL: http://svn.apache.org/viewcvs?rev=179234&view=rev
Log: (empty)

Added:
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
  (with props)
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckOutProjectContinuumAction.java
  (with props)
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ContinuumAction.java
  (with props)
Modified:
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java

Added: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java?rev=179234&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
(added)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
Tue May 31 09:29:14 2005
@@ -0,0 +1,149 @@
+package org.apache.maven.continuum.core.action;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import java.util.Map;
+import java.io.File;
+
+import org.apache.maven.continuum.store.ContinuumStore;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.apache.maven.continuum.scm.ContinuumScm;
+import org.apache.maven.continuum.scm.CheckOutScmResult;
+
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public abstract class AbstractContinuumAction
+    extends AbstractLogEnabled
+    implements ContinuumAction
+{
+    public final static String KEY_PROJECT_ID = "projectId";
+
+    public static final String KEY_WORKING_DIRECTORY = "workingDirectory";
+
+    public static final String KEY_CHECKOUT_RESULT = "checkOutResult";
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    /**
+     * @plexus.requirement
+     */
+    private ContinuumStore store;
+
+    /**
+     * @plexus.requirement
+     */
+    private ContinuumScm scm;
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    protected abstract void doExecute( Map context )
+        throws Exception;
+
+    protected abstract void handleException( Map context, Throwable throwable )
+        throws ContinuumStoreException;
+
+    protected void handleContinuumStoreException( ContinuumStoreException exception )
+    {
+        getLogger().fatalError( "Error using the store.", exception );
+    }
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    protected ContinuumStore getStore()
+    {
+        return store;
+    }
+
+    protected ContinuumScm getContinuumScm()
+    {
+        return scm;
+    }
+
+    protected String getProjectId( Map context )
+        throws ContinuumStoreException
+    {
+        return getString( context, KEY_PROJECT_ID );
+    }
+
+    protected File getWorkingDirectory( Map context )
+    {
+        return new File( getString( context, KEY_WORKING_DIRECTORY ) );
+    }
+
+    protected CheckOutScmResult getCheckOutResult( Map context )
+    {
+        return (CheckOutScmResult) getObject( context, KEY_CHECKOUT_RESULT );
+    }
+
+    // ----------------------------------------------------------------------
+    // ContinuumAction Implementatin
+    // ----------------------------------------------------------------------
+
+    public void execute( Map context )
+    {
+        try
+        {
+            doExecute( context );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            handleContinuumStoreException( e );
+        }
+        catch ( Exception e )
+        {
+            try
+            {
+                handleException( context, e );
+            }
+            catch ( ContinuumStoreException e2 )
+            {
+                handleContinuumStoreException( e2 );
+            }
+        }
+    }
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    private String getString( Map context, String key )
+    {
+        return (String) getObject( context, key );
+    }
+
+    private Object getObject( Map context, String key )
+    {
+        Object value = context.get( key );
+
+        if ( value == null )
+        {
+            throw new RuntimeException( "Missing value for key '" + key + "'." );
+        }
+
+        return value;
+    }
+}

Propchange: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckOutProjectContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckOutProjectContinuumAction.java?rev=179234&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckOutProjectContinuumAction.java
(added)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckOutProjectContinuumAction.java
Tue May 31 09:29:14 2005
@@ -0,0 +1,72 @@
+package org.apache.maven.continuum.core.action;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import java.io.File;
+import java.util.Map;
+
+import org.apache.maven.continuum.project.ContinuumProject;
+import org.apache.maven.continuum.scm.CheckOutScmResult;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.apache.maven.scm.manager.NoSuchScmProviderException;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class CheckOutProjectContinuumAction
+    extends AbstractContinuumAction
+{
+    protected void doExecute( Map context )
+        throws Exception
+    {
+        String projectId = getProjectId( context );
+
+        ContinuumProject project = getStore().getProject( projectId );
+
+        File workingDirectory = getWorkingDirectory( context );
+
+        CheckOutScmResult result;
+
+        result = getContinuumScm().checkOut( project, workingDirectory );
+
+        getStore().setCheckoutDone( projectId, result, null, null );
+
+        context.put( KEY_CHECKOUT_RESULT, result );
+    }
+
+    protected void handleException( Map context, Throwable throwable )
+        throws ContinuumStoreException
+    {
+        String errorMessage = null;
+
+        // TODO: Dissect the scm exception to be able to give better feedback
+        Throwable cause = throwable.getCause();
+
+        if ( cause instanceof NoSuchScmProviderException )
+        {
+            errorMessage = cause.getMessage();
+
+            throwable = null;
+        }
+
+        getStore().setCheckoutDone( getProjectId( context ),
+                                    getCheckOutResult( context ),
+                                    errorMessage,
+                                    throwable );
+    }
+}

Propchange: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckOutProjectContinuumAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckOutProjectContinuumAction.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ContinuumAction.java?rev=179234&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ContinuumAction.java
(added)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ContinuumAction.java
Tue May 31 09:29:14 2005
@@ -0,0 +1,28 @@
+package org.apache.maven.continuum.core.action;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public interface ContinuumAction
+{
+    void execute( Map context );
+}

Propchange: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ContinuumAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ContinuumAction.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java?rev=179234&r1=179233&r2=179234&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java
Tue May 31 09:29:14 2005
@@ -33,7 +33,7 @@
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
- * @version $Id:$
+ * @version $Id$
  */
 public class CheckOutTaskExecutor
     extends AbstractLogEnabled
@@ -52,6 +52,8 @@
     public void executeTask( Task t )
         throws TaskExecutionException
     {
+        // TODO: Replace with a exection of the "check out project" action
+
         CheckOutTask task = (CheckOutTask) t;
 
         String projectId = task.getProjectId();



Mime
View raw message