]> source.dussan.org Git - archiva.git/commitdiff
Updates for admin screens
authorJoakim Erdfelt <joakime@apache.org>
Tue, 1 May 2007 12:46:46 +0000 (12:46 +0000)
committerJoakim Erdfelt <joakime@apache.org>
Tue, 1 May 2007 12:46:46 +0000 (12:46 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-jpox-database-refactor@534044 13f79535-47bb-0310-9956-ffa450edef68

54 files changed:
archiva-base/archiva-configuration/src/main/mdo/configuration.mdo
archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java
archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/MostRecentRepositoryScanStatistics.java [new file with mode: 0644]
archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java
archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java
archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsProcessedConstraintTest.java
archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/MostRecentRepositoryScanStatisticsTest.java [new file with mode: 0644]
archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/ArchivaTaskQueue.java
archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/ArchivaTaskScheduler.java
archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AbstractConfigureRepositoryAction.java [deleted file]
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AbstractRepositoryAction.java [new file with mode: 0644]
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AdminModel.java [deleted file]
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureAction.java
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureProxiedRepositoryAction.java [deleted file]
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureRepositoryAction.java
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureSyncedRepositoryAction.java [deleted file]
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/DeleteProxiedRepositoryAction.java [deleted file]
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/DeleteSyncedRepositoryAction.java [deleted file]
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/EditRepositoryAction.java [new file with mode: 0644]
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/IndexRepositoryAction.java [new file with mode: 0644]
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/RepositoriesAction.java
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/RunRepositoryTaskAction.java [deleted file]
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SaveRepositoryAction.java [new file with mode: 0644]
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/models/AdminModel.java [new file with mode: 0644]
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/models/AdminRepositoryConfiguration.java [new file with mode: 0644]
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/interceptor/WebworkIsDoingStrangeThingsInterceptor.java [new file with mode: 0644]
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/RepositoryServlet.java
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/CopyPasteSnippet.java [new file with mode: 0644]
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/CopyPasteSnippetTag.java [new file with mode: 0644]
archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ContextUtils.java [new file with mode: 0644]
archiva-web/archiva-webapp/src/main/resources/META-INF/plexus/application.xml
archiva-web/archiva-webapp/src/main/resources/META-INF/taglib.tld
archiva-web/archiva-webapp/src/main/resources/log4j.xml
archiva-web/archiva-webapp/src/main/resources/webwork.properties
archiva-web/archiva-webapp/src/main/resources/xwork.xml
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addProxiedRepository.jsp [deleted file]
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addRepository.jsp
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addSyncedRepository.jsp [deleted file]
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteProxiedRepository.jsp [deleted file]
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteSyncedRepository.jsp [deleted file]
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editProxiedRepository.jsp [deleted file]
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editRepository.jsp
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editSyncedRepository.jsp [deleted file]
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/managedRepositories.jsp [deleted file]
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxiedRepositories.jsp [deleted file]
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/selectSyncedRepository.jsp [deleted file]
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/syncedRepositories.jsp [deleted file]
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/tags/currentWWUrl.tag
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml
archiva-web/archiva-webapp/src/main/webapp/css/maven-theme.css

index 6de28dc794b67fa472c0f652418abc849d4322ba..8ea11bd2bb7a41cfdc94d7c25dbf5bba87db1956 100644 (file)
           </description>
           <defaultValue>0 0,30 * * * ?</defaultValue>
         </field>
-      </fields>\r
+      </fields>
+      <codeSegments>
+        <codeSegment>
+          <version>1.0.0+</version>
+          <code><![CDATA[
+    /**
+     * Utility method to help determine if configuration refers to a remote repository.
+     * 
+     * @return true if configuration belongs to a remote repository. 
+     *      (note: false does not automatically mean this is a managed repository,
+     *      you must use {@link #isManaged()} to test for that.)
+     */
+    public boolean isRemote()
+    {
+        if ( this.url == null )
+        {
+            return false;
+        }
+
+        return !this.url.startsWith( "file" );
+    }
+
+    /**
+     * Utility method to help determine if configuration refers to a managed repository.
+     * 
+     * @return true if configuration belongs to a managed repository. 
+     *      (note: false does not automatically mean this is a remote repository,
+     *      you must use {@link #isRemote()} to test for that.)
+     */
+    public boolean isManaged()
+    {
+        if ( this.url == null )
+        {
+            return false;
+        }
+
+        return this.url.startsWith( "file" );
+    }          
+          ]]></code>
+        </codeSegment>
+      </codeSegments>\r
     </class>
     
     <!-- 
index d6675c6edae5d6f33dd9f520170c24e4b79f6829..bd64fb5da71f67732dd2d9fa8f00c8c9747e1b40 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.maven.archiva.database;
  * under the License.
  */
 
+import java.io.Serializable;
 import java.util.List;
 
 /**
@@ -39,6 +40,14 @@ public interface ArchivaDAO
      */
     List query( SimpleConstraint constraint );
 
+    /**
+     * Perform a simple save of a peristable object to the database.
+     * 
+     * @param o the serializable (persistable) object to save.
+     * @return the post-serialized object.
+     */
+    Object save( Serializable obj );
+
     ArtifactDAO getArtifactDAO();
 
     ProjectModelDAO getProjectModelDAO();
diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/MostRecentRepositoryScanStatistics.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/MostRecentRepositoryScanStatistics.java
new file mode 100644 (file)
index 0000000..496f4f2
--- /dev/null
@@ -0,0 +1,54 @@
+package org.apache.maven.archiva.database.constraints;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.archiva.model.RepositoryContentStatistics;
+
+/**
+ * MostRecentRepositoryScanStatistics 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class MostRecentRepositoryScanStatistics
+    extends AbstractSimpleConstraint
+{
+    private String sql;
+
+    public MostRecentRepositoryScanStatistics( String repoId )
+    {
+        sql = "SELECT FROM " + RepositoryContentStatistics.class.getName()
+            + " WHERE repositoryId == repoId PARAMETERS String repoId"
+            + " ORDER BY whenGathered DESCENDING"
+            + " RANGE 1,1";
+
+        super.params = new Object[] { repoId };
+    }
+
+    public Class getResultClass()
+    {
+        return RepositoryContentStatistics.class;
+    }
+
+    public String getSelectSql()
+    {
+        return sql;
+    }
+}
index b1544de1d42e3f6a3445e115bf54a355b537a776..7fbf79ad56201a8cab0ad470f90f50ad10815380 100644 (file)
@@ -27,6 +27,7 @@ import org.apache.maven.archiva.database.RepositoryProblemDAO;
 import org.apache.maven.archiva.database.SimpleConstraint;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 
+import java.io.Serializable;
 import java.util.List;
 
 /**
@@ -45,37 +46,42 @@ public class JdoArchivaDAO
      * @plexus.requirement role-hint="archiva"
      */
     private JdoAccess jdo;
-    
+
     /**
      * @plexus.requirement role-hint="jdo"
      */
     private ArtifactDAO artifactDAO;
-    
+
     /**
      * @plexus.requirement role-hint="jdo"
      */
     private ProjectModelDAO projectModelDAO;
-    
+
     /**
      * @plexus.requirement role-hint="jdo"
      */
     private RepositoryDAO repositoryDAO;
-    
+
     /**
      * @plexus.requirement role-hint="jdo"
      */
     private RepositoryProblemDAO repositoryProblemDAO;
-    
+
     public List query( SimpleConstraint constraint )
     {
         return jdo.queryObjects( constraint );
     }
 
+    public Object save( Serializable obj )
+    {
+        return jdo.saveObject( obj );
+    }
+
     public ArtifactDAO getArtifactDAO()
     {
         return artifactDAO;
     }
-    
+
     public ProjectModelDAO getProjectModelDAO()
     {
         return projectModelDAO;
index f936bca5da6a2e37add7015e1b589f06c96d26fa..4deedfc9e54c491d27ffc8f6ff9e9367139cd85f 100644 (file)
@@ -26,6 +26,8 @@ import org.jpox.SchemaTool;
 
 import java.io.File;
 import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
@@ -42,41 +44,43 @@ import javax.jdo.PersistenceManagerFactory;
 public class AbstractArchivaDatabaseTestCase
     extends PlexusTestCase
 {
+    private static final String TIMESTAMP = "yyyy/MM/dd HH:mm:ss";
+
     protected ArchivaDAO dao;
-    
+
     protected void setUp()
         throws Exception
     {
         super.setUp();
-        
+
         DefaultConfigurableJdoFactory jdoFactory = (DefaultConfigurableJdoFactory) lookup( JdoFactory.ROLE, "archiva" );
         assertEquals( DefaultConfigurableJdoFactory.class.getName(), jdoFactory.getClass().getName() );
 
-        jdoFactory.setPersistenceManagerFactoryClass( "org.jpox.PersistenceManagerFactoryImpl" ); 
+        jdoFactory.setPersistenceManagerFactoryClass( "org.jpox.PersistenceManagerFactoryImpl" );
 
         /* derby version
-        File derbyDbDir = new File( "target/plexus-home/testdb" );
-        if ( derbyDbDir.exists() )
-        {
-            FileUtils.deleteDirectory( derbyDbDir );
-        }
+         File derbyDbDir = new File( "target/plexus-home/testdb" );
+         if ( derbyDbDir.exists() )
+         {
+         FileUtils.deleteDirectory( derbyDbDir );
+         }
 
-        jdoFactory.setDriverName( System.getProperty( "jdo.test.driver", "org.apache.derby.jdbc.EmbeddedDriver" ) );   
-        jdoFactory.setUrl( System.getProperty( "jdo.test.url", "jdbc:derby:" + derbyDbDir.getAbsolutePath() + ";create=true" ) );
-         */   
+         jdoFactory.setDriverName( System.getProperty( "jdo.test.driver", "org.apache.derby.jdbc.EmbeddedDriver" ) );   
+         jdoFactory.setUrl( System.getProperty( "jdo.test.url", "jdbc:derby:" + derbyDbDir.getAbsolutePath() + ";create=true" ) );
+         */
 
-        jdoFactory.setDriverName( System.getProperty( "jdo.test.driver", "org.hsqldb.jdbcDriver" ) );   
+        jdoFactory.setDriverName( System.getProperty( "jdo.test.driver", "org.hsqldb.jdbcDriver" ) );
         jdoFactory.setUrl( System.getProperty( "jdo.test.url", "jdbc:hsqldb:mem:" + getName() ) );
-        
-        jdoFactory.setUserName( System.getProperty( "jdo.test.user", "sa" ) ); 
 
-        jdoFactory.setPassword( System.getProperty( "jdo.test.pass", "" ) ); 
+        jdoFactory.setUserName( System.getProperty( "jdo.test.user", "sa" ) );
+
+        jdoFactory.setPassword( System.getProperty( "jdo.test.pass", "" ) );
 
-        jdoFactory.setProperty( "org.jpox.transactionIsolation", "READ_COMMITTED" );  
+        jdoFactory.setProperty( "org.jpox.transactionIsolation", "READ_COMMITTED" );
 
-        jdoFactory.setProperty( "org.jpox.poid.transactionIsolation", "READ_COMMITTED" );  
+        jdoFactory.setProperty( "org.jpox.poid.transactionIsolation", "READ_COMMITTED" );
 
-        jdoFactory.setProperty( "org.jpox.autoCreateSchema", "true" );  
+        jdoFactory.setProperty( "org.jpox.autoCreateSchema", "true" );
 
         jdoFactory.setProperty( "javax.jdo.option.RetainValues", "true" );
 
@@ -99,8 +103,7 @@ public class AbstractArchivaDatabaseTestCase
             System.setProperty( (String) entry.getKey(), (String) entry.getValue() );
         }
 
-        URL jdoFileUrls[] = new URL[] { getClass()
-            .getResource( "/org/apache/maven/archiva/model/package.jdo" ) }; 
+        URL jdoFileUrls[] = new URL[] { getClass().getResource( "/org/apache/maven/archiva/model/package.jdo" ) };
 
         if ( ( jdoFileUrls == null ) || ( jdoFileUrls[0] == null ) )
         {
@@ -123,4 +126,18 @@ public class AbstractArchivaDatabaseTestCase
 
         this.dao = (ArchivaDAO) lookup( ArchivaDAO.class.getName(), "jdo" );
     }
+
+    protected Date toDate( String txt )
+        throws Exception
+    {
+        SimpleDateFormat sdf = new SimpleDateFormat( TIMESTAMP );
+        return sdf.parse( txt );
+    }
+
+    protected String fromDate( Date date )
+        throws Exception
+    {
+        SimpleDateFormat sdf = new SimpleDateFormat( TIMESTAMP );
+        return sdf.format( date );
+    }
 }
index 603fdca901a8f9b6e8dcc0b518bc578412be7457..a76d9689bcde47048bf4c6cf40f3d18c88e89b6f 100644 (file)
@@ -23,7 +23,6 @@ import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
 import org.apache.maven.archiva.database.ArtifactDAO;
 import org.apache.maven.archiva.model.ArchivaArtifact;
 
-import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
@@ -57,13 +56,6 @@ public class ArtifactsProcessedConstraintTest
         return artifact;
     }
 
-    private Date toDate( String txt )
-        throws Exception
-    {
-        SimpleDateFormat sdf = new SimpleDateFormat( "yyyy/MM/dd HH:mm:ss" );
-        return sdf.parse( txt );
-    }
-    
     public void assertResults( String type, List results, String expectedArtifacts[] )
     {
         assertNotNull( "Results[" + type + "] should not be null.", results );
diff --git a/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/MostRecentRepositoryScanStatisticsTest.java b/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/MostRecentRepositoryScanStatisticsTest.java
new file mode 100644 (file)
index 0000000..3ef84e8
--- /dev/null
@@ -0,0 +1,86 @@
+package org.apache.maven.archiva.database.constraints;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
+import org.apache.maven.archiva.model.RepositoryContentStatistics;
+
+import java.util.List;
+
+/**
+ * MostRecentRepositoryScanStatisticsTest 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class MostRecentRepositoryScanStatisticsTest
+    extends AbstractArchivaDatabaseTestCase
+{
+    private RepositoryContentStatistics createStats( String repoId, String timestamp, long duration, long totalfiles,
+                                                     long newfiles )
+        throws Exception
+    {
+        RepositoryContentStatistics stats = new RepositoryContentStatistics();
+        stats.setRepositoryId( repoId );
+        stats.setDuration( duration );
+        stats.setNewFileCount( newfiles );
+        stats.setTotalFileCount( totalfiles );
+        stats.setWhenGathered( toDate( timestamp ) );
+
+        return stats;
+    }
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        dao.save( createStats( "internal", "2007/02/21 10:00:00", 20000, 12000, 400 ) );
+        dao.save( createStats( "internal", "2007/02/20 10:00:00", 20000, 11800, 0 ) );
+        dao.save( createStats( "internal", "2007/02/19 10:00:00", 20000, 11800, 100 ) );
+        dao.save( createStats( "internal", "2007/02/18 10:00:00", 20000, 11700, 320 ) );
+    }
+
+    public void testNotProcessedYet()
+        throws Exception
+    {
+        List results = dao.query( new MostRecentRepositoryScanStatistics( "central" ) );
+        assertNotNull( "Not Processed Yet", results );
+        assertTrue( "Not Processed Yet", results.isEmpty() );
+    }
+
+    public void testStats()
+        throws Exception
+    {
+        List results = dao.query( new MostRecentRepositoryScanStatistics( "internal" ) );
+        assertNotNull( "Stats: results (not null)", results );
+        assertEquals( "Stats: results.size", 1, results.size() );
+
+        Object o = results.get( 0 );
+        assertTrue( "Stats: result[0] instanceof RepositoryScanStatistics", o instanceof RepositoryContentStatistics );
+        RepositoryContentStatistics stats = (RepositoryContentStatistics) o;
+        assertEquals( "Stats: id", "internal", stats.getRepositoryId() );
+        assertEquals( "Stats: when gathered", "2007/02/21 10:00:00", fromDate( stats.getWhenGathered() ) );
+        assertEquals( "Stats: duration", 20000, stats.getDuration() );
+        assertEquals( "Stats: total file count", 12000, stats.getTotalFileCount() );
+        assertEquals( "Stats: new file count", 400, stats.getNewFileCount() );
+    }
+
+}
index f2deaa106bde20ee21782890bb85c8722c08cb57..4d221fff399876fc6fa14ef512507b992ee60a97 100644 (file)
@@ -19,7 +19,15 @@ package org.apache.maven.archiva.scheduled;
  * under the License.
  */
 
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.scheduled.tasks.DatabaseTask;
+import org.apache.maven.archiva.scheduled.tasks.RepositoryTask;
 import org.codehaus.plexus.taskqueue.DefaultTaskQueue;
+import org.codehaus.plexus.taskqueue.Task;
+import org.codehaus.plexus.taskqueue.TaskQueueException;
+
+import java.util.Iterator;
+import java.util.List;
 
 /**
  * ArchivaTaskQueue 
@@ -39,4 +47,74 @@ public class ArchivaTaskQueue
         super();
         /* do nothing special */
     }
+
+    public boolean hasDatabaseTaskInQueue()
+    {
+        try
+        {
+            List queue = getQueueSnapshot();
+            Iterator it = queue.iterator();
+            while ( it.hasNext() )
+            {
+                Task task = (Task) it.next();
+                if ( task instanceof DatabaseTask )
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+        catch ( TaskQueueException e )
+        {
+            return false;
+        }
+    }
+
+    public boolean hasFilesystemTaskInQueue()
+    {
+        try
+        {
+            List queue = getQueueSnapshot();
+            Iterator it = queue.iterator();
+            while ( it.hasNext() )
+            {
+                Task task = (Task) it.next();
+                if ( task instanceof RepositoryTask )
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+        catch ( TaskQueueException e )
+        {
+            return false;
+        }
+    }
+
+    public boolean hasRepositoryTaskInQueue( String repoid )
+    {
+        try
+        {
+            List queue = getQueueSnapshot();
+            Iterator it = queue.iterator();
+            while ( it.hasNext() )
+            {
+                Task task = (Task) it.next();
+                if ( task instanceof RepositoryTask )
+                {
+                    RepositoryTask rtask = (RepositoryTask) task;
+                    if ( StringUtils.equals( repoid, rtask.getRepositoryId() ) )
+                    {
+                        return true;
+                    }
+                }
+            }
+            return false;
+        }
+        catch ( TaskQueueException e )
+        {
+            return false;
+        }
+    }
 }
index ffe3c624a7ccf7ddf602cae7af0a36c37d7aed4d..9becfb2f26e3a823924a658259fc56590ea6acee 100644 (file)
@@ -32,11 +32,15 @@ public interface ArchivaTaskScheduler
      * The Plexus component role.
      */
     public final static String ROLE = ArchivaTaskScheduler.class.getName();
+    
+    public ArchivaTaskQueue getTaskQueue();
 
-    public void runDatabaseTasks() throws TaskExecutionException;
+    public void scheduleAllRepositoryTasks()
+        throws TaskExecutionException;
 
-    public void runAllRepositoryTasks() throws TaskExecutionException;
-    
-    public void runRepositoryTasks( String repositoryId ) throws TaskExecutionException;
-    
-} 
+    public void scheduleDatabaseTasks()
+        throws TaskExecutionException;
+
+    public void scheduleRepositoryTask( String repositoryId )
+        throws TaskExecutionException;
+}
index 7b351e482a6c0bee675501a22e8ccdc503f414eb..50de8347f7b12238f960b4d5ba3dbeaa87db3084 100644 (file)
@@ -20,12 +20,8 @@ package org.apache.maven.archiva.scheduled;
  */
 
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.RepositoryConfiguration;
-import org.apache.maven.archiva.database.ArchivaDatabaseException;
-import org.apache.maven.archiva.database.ObjectNotFoundException;
-import org.apache.maven.archiva.database.RepositoryDAO;
-import org.apache.maven.archiva.model.ArchivaRepository;
+import org.apache.maven.archiva.scheduled.tasks.ArchivaTask;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException;
@@ -34,7 +30,6 @@ import org.codehaus.plexus.registry.Registry;
 import org.codehaus.plexus.registry.RegistryListener;
 import org.codehaus.plexus.scheduler.Scheduler;
 import org.codehaus.plexus.taskqueue.TaskQueue;
-import org.codehaus.plexus.taskqueue.TaskQueueException;
 import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
 import org.quartz.CronTrigger;
 import org.quartz.JobDataMap;
@@ -73,12 +68,12 @@ public class DefaultArchivaTaskScheduler
     private ArchivaConfiguration archivaConfiguration;
   
     
-    public static final String DATABASE_DISCOVERER_GROUP = "database-group";
+    public static final String DATABASE_SCAN_GROUP = "database-group";
     
     public static final String DATABASE_JOB = "database-job";
     public static final String DATABASE_JOB_TRIGGER = "database-job-trigger";
    
-    public static final String REPOSITORY_DISCOVERER_GROUP = "repository-group";
+    public static final String REPOSITORY_SCAN_GROUP = "repository-group";
     
     public static final String REPOSITORY_JOB = "repository-job";
     public static final String REPOSITORY_JOB_TRIGGER = "repository-job-trigger";
@@ -119,17 +114,18 @@ public class DefaultArchivaTaskScheduler
         
         // setup the unprocessed artifact job
         JobDetail repositoryJob =
-            new JobDetail( REPOSITORY_JOB + ":" + repoConfig.getId() , REPOSITORY_DISCOVERER_GROUP, RepositoryTaskJob.class );
+            new JobDetail( REPOSITORY_JOB + ":" + repoConfig.getId() , REPOSITORY_SCAN_GROUP, RepositoryTaskJob.class );
 
         JobDataMap dataMap = new JobDataMap();
         dataMap.put( RepositoryTaskJob.TASK_QUEUE, archivaTaskQueue );
+        dataMap.put( RepositoryTaskJob.TASK_QUEUE_POLICY, ArchivaTask.QUEUE_POLICY_WAIT );
         dataMap.put( RepositoryTaskJob.TASK_REPOSITORY, repoConfig.getId() );
         repositoryJob.setJobDataMap( dataMap );
        
         try 
         {
             CronTrigger trigger =
-                new CronTrigger( REPOSITORY_JOB_TRIGGER + ":" + repoConfig.getId() , REPOSITORY_DISCOVERER_GROUP, cronString );
+                new CronTrigger( REPOSITORY_JOB_TRIGGER + ":" + repoConfig.getId() , REPOSITORY_SCAN_GROUP, cronString );
         
             scheduler.scheduleJob( repositoryJob, trigger );
         }
@@ -147,7 +143,7 @@ public class DefaultArchivaTaskScheduler
         
         // setup the unprocessed artifact job
         JobDetail databaseJob =
-            new JobDetail( DATABASE_JOB, DATABASE_DISCOVERER_GROUP, DatabaseTaskJob.class );
+            new JobDetail( DATABASE_JOB, DATABASE_SCAN_GROUP, DatabaseTaskJob.class );
 
         JobDataMap dataMap = new JobDataMap();
         dataMap.put( DatabaseTaskJob.TASK_QUEUE, archivaTaskQueue );
@@ -156,7 +152,7 @@ public class DefaultArchivaTaskScheduler
         try 
         {
             CronTrigger trigger =
-                new CronTrigger( DATABASE_JOB_TRIGGER, DATABASE_DISCOVERER_GROUP, cronString );
+                new CronTrigger( DATABASE_JOB_TRIGGER, DATABASE_SCAN_GROUP, cronString );
         
             scheduler.scheduleJob( databaseJob, trigger );
         }
@@ -172,7 +168,7 @@ public class DefaultArchivaTaskScheduler
     {
         try
         {
-            scheduler.unscheduleJob( DATABASE_JOB, DATABASE_DISCOVERER_GROUP );         
+            scheduler.unscheduleJob( DATABASE_JOB, DATABASE_SCAN_GROUP );         
         }
         catch ( SchedulerException e )
         {
@@ -198,7 +194,7 @@ public class DefaultArchivaTaskScheduler
             
             try
             {
-                scheduler.unscheduleJob( DATABASE_JOB, DATABASE_DISCOVERER_GROUP );
+                scheduler.unscheduleJob( DATABASE_JOB, DATABASE_SCAN_GROUP );
             
                 scheduleDatabaseJobs();
             }
@@ -224,7 +220,7 @@ public class DefaultArchivaTaskScheduler
                     try
                     {
                         // unschedule handles jobs that might not exist
-                        scheduler.unscheduleJob( REPOSITORY_JOB + ":" + repoConfig.getId() , REPOSITORY_DISCOVERER_GROUP );
+                        scheduler.unscheduleJob( REPOSITORY_JOB + ":" + repoConfig.getId() , REPOSITORY_SCAN_GROUP );
                         scheduleRepositoryJobs( repoConfig );
                     }
                     catch ( SchedulerException e )
@@ -236,7 +232,7 @@ public class DefaultArchivaTaskScheduler
         }
     }
 
-    public void runAllRepositoryTasks() throws TaskExecutionException
+    public void scheduleAllRepositoryTasks() throws TaskExecutionException
     {
         try
         {
@@ -256,7 +252,7 @@ public class DefaultArchivaTaskScheduler
         }
     }
 
-    public void runDatabaseTasks() throws TaskExecutionException
+    public void scheduleDatabaseTasks() throws TaskExecutionException
     {
         try
         {
@@ -269,7 +265,7 @@ public class DefaultArchivaTaskScheduler
         }
     }
 
-    public void runRepositoryTasks( String repositoryId ) throws TaskExecutionException
+    public void scheduleRepositoryTask( String repositoryId ) throws TaskExecutionException
     {
         try
         {
@@ -282,7 +278,9 @@ public class DefaultArchivaTaskScheduler
             throw new TaskExecutionException( "Unable to schedule repository jobs: " + e.getMessage(), e );
         } 
     }
-
-    
     
+    public ArchivaTaskQueue getTaskQueue()
+    {
+        return (ArchivaTaskQueue) archivaTaskQueue;
+    }
 }
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AbstractConfigureRepositoryAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AbstractConfigureRepositoryAction.java
deleted file mode 100644 (file)
index f181c17..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-package org.apache.maven.archiva.web.action.admin;
-
-/*
- * 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.
- */
-
-import com.opensymphony.xwork.ModelDriven;
-import com.opensymphony.xwork.Preparable;
-//import org.apache.maven.archiva.configuration.AbstractRepositoryConfiguration;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.InvalidConfigurationException;
-import org.apache.maven.archiva.security.ArchivaRoleConstants;
-import org.codehaus.plexus.rbac.profile.RoleProfileException;
-import org.codehaus.plexus.rbac.profile.RoleProfileManager;
-import org.codehaus.plexus.registry.RegistryException;
-import org.codehaus.plexus.security.rbac.RbacManagerException;
-import org.codehaus.plexus.security.rbac.Resource;
-import org.codehaus.plexus.security.ui.web.interceptor.SecureAction;
-import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle;
-import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException;
-import org.codehaus.plexus.xwork.action.PlexusActionSupport;
-
-import java.io.IOException;
-
-/**
- * Base action for repository configuration actions.
- *
- * @author <a href="mailto:brett@apache.org">Brett Porter</a>
- */
-public abstract class AbstractConfigureRepositoryAction
-    extends PlexusActionSupport
-    implements ModelDriven, Preparable, SecureAction
-{
-    /**
-     * @plexus.requirement
-     */
-    private ArchivaConfiguration archivaConfiguration;
-
-    /**
-     * @plexus.requirement role-hint="archiva"
-     */
-    protected RoleProfileManager roleProfileManager;
-
-    /**
-     * The repository.
-     */
-//    private AbstractRepositoryConfiguration repository;
-
-    /**
-     * The repository ID to lookup when editing a repository.
-     */
-    private String repoId;
-
-    /**
-     * The previously read configuration.
-     */
-    protected Configuration configuration;
-
-    public String add()
-        throws IOException, InvalidConfigurationException, RbacManagerException, RoleProfileException, RegistryException
-    {
-        // TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded
-
-//        AbstractRepositoryConfiguration existingRepository = getRepository( repository.getId() );
-//        if ( existingRepository != null )
-//        {
-//            addFieldError( "id", "A repository with that id already exists" );
-//            return INPUT;
-//        }
-
-        return saveConfiguration();
-    }
-
-    public String edit()
-        throws IOException, InvalidConfigurationException, RbacManagerException, RoleProfileException, RegistryException
-    {
-        // TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded
-
-//        AbstractRepositoryConfiguration existingRepository = getRepository( repository.getId() );
-//        removeRepository( existingRepository );
-
-        return saveConfiguration();
-    }
-
-//    protected abstract void removeRepository( AbstractRepositoryConfiguration existingRepository );
-//
-//    protected abstract AbstractRepositoryConfiguration getRepository( String id );
-
-    private String saveConfiguration()
-        throws IOException, InvalidConfigurationException, RbacManagerException, RoleProfileException, RegistryException
-    {
-        addRepository();
-
-        archivaConfiguration.save( configuration );
-
-        // TODO: do we need to check if indexing is needed?
-
-        addActionMessage( "Successfully saved configuration" );
-
-        return SUCCESS;
-    }
-
-    protected abstract void addRepository()
-        throws IOException, RoleProfileException;
-
-    public String input()
-    {
-        return INPUT;
-    }
-
-    public Object getModel()
-    {
-        return new Object();
-//        return repository;
-    }
-
-//    protected abstract AbstractRepositoryConfiguration createRepository();
-
-    public void prepare()
-    {
-        configuration = archivaConfiguration.getConfiguration();
-
-//        if ( repository == null )
-//        {
-//            repository = getRepository( repoId );
-//        }
-//        if ( repository == null )
-//        {
-//            repository = createRepository();
-//        }
-    }
-
-    public String getRepoId()
-    {
-        return repoId;
-    }
-
-    public void setRepoId( String repoId )
-    {
-        this.repoId = repoId;
-    }
-
-//    protected AbstractRepositoryConfiguration getRepository()
-//    {
-//        return repository;
-//    }
-
-    public Configuration getConfiguration()
-    {
-        return configuration;
-    }
-
-    public SecureActionBundle getSecureActionBundle()
-        throws SecureActionException
-    {
-        SecureActionBundle bundle = new SecureActionBundle();
-
-        bundle.setRequiresAuthentication( true );
-
-        if ( getRepoId() != null )
-        {
-            // TODO: this is not right. It needs to change based on method. But is this really the right way to restrict this area?
-            // TODO: not right. We only care about this permission on managed repositories. Otherwise, it's configuration
-            bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_EDIT_REPOSITORY, getRepoId() );
-        }
-        else
-        {
-            bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
-        }
-
-        return bundle;
-    }
-}
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AbstractRepositoryAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AbstractRepositoryAction.java
new file mode 100644 (file)
index 0000000..ac241e9
--- /dev/null
@@ -0,0 +1,208 @@
+package org.apache.maven.archiva.web.action.admin;
+
+/*
+ * 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.
+ */
+
+import com.opensymphony.xwork.ActionContext;
+import com.opensymphony.xwork.ModelDriven;
+import com.opensymphony.xwork.Preparable;
+
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.InvalidConfigurationException;
+import org.apache.maven.archiva.configuration.RepositoryConfiguration;
+import org.apache.maven.archiva.security.ArchivaRoleConstants;
+import org.apache.maven.archiva.web.action.admin.models.AdminRepositoryConfiguration;
+import org.codehaus.plexus.rbac.profile.RoleProfileException;
+import org.codehaus.plexus.rbac.profile.RoleProfileManager;
+import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.plexus.security.authorization.AuthorizationException;
+import org.codehaus.plexus.security.authorization.AuthorizationResult;
+import org.codehaus.plexus.security.rbac.RbacManagerException;
+import org.codehaus.plexus.security.rbac.Resource;
+import org.codehaus.plexus.security.system.SecuritySession;
+import org.codehaus.plexus.security.system.SecuritySystem;
+import org.codehaus.plexus.security.ui.web.interceptor.SecureAction;
+import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle;
+import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException;
+import org.codehaus.plexus.xwork.action.PlexusActionSupport;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * AbstractRepositoryAction 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public abstract class AbstractRepositoryAction
+    extends PlexusActionSupport
+    implements ModelDriven, Preparable, SecureAction
+{
+    protected static final String SUCCESS = "success";
+
+    /**
+     * @plexus.requirement role-hint="archiva"
+     */
+    private RoleProfileManager roleProfileManager;
+
+    /**
+     * @plexus.requirement
+     */
+    private SecuritySystem securitySystem;
+
+    private String repoid;
+
+    private String mode;
+
+    /**
+     * @plexus.requirement
+     */
+    protected ArchivaConfiguration archivaConfiguration;
+
+    /**
+     * The model for this action.
+     */
+    protected AdminRepositoryConfiguration repository;
+
+    public String getMode()
+    {
+        return this.mode;
+    }
+
+    public Object getModel()
+    {
+        return getRepository();
+    }
+
+    public String getRepoid()
+    {
+        return repoid;
+    }
+
+    public SecureActionBundle getSecureActionBundle()
+        throws SecureActionException
+    {
+        SecureActionBundle bundle = new SecureActionBundle();
+
+        bundle.setRequiresAuthentication( true );
+        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
+
+        return bundle;
+    }
+
+    public String input()
+    {
+        getLogger().info( "input()" );
+        return INPUT;
+    }
+
+    public abstract void prepare()
+        throws Exception;
+
+    public void setMode( String mode )
+    {
+        this.mode = mode;
+    }
+
+    public void setRepoid( String repoid )
+    {
+        this.repoid = repoid;
+    }
+
+    protected void addRepository( AdminRepositoryConfiguration repository )
+        throws IOException, RoleProfileException
+    {
+        getLogger().info( ".addRepository(" + repository + ")" );
+
+        if ( repository.isManaged() )
+        {
+            // Normalize the path
+            File file = new File( repository.getDirectory() );
+            repository.setDirectory( file.getCanonicalPath() );
+            if ( !file.exists() )
+            {
+                file.mkdirs();
+                // TODO: error handling when this fails, or is not a directory!
+            }
+        }
+
+        archivaConfiguration.getConfiguration().addRepository( repository );
+
+        // TODO: double check these are configured on start up
+        roleProfileManager.getDynamicRole( "archiva-repository-manager", repository.getId() );
+
+        roleProfileManager.getDynamicRole( "archiva-repository-observer", repository.getId() );
+    }
+
+    protected AdminRepositoryConfiguration getRepository()
+    {
+        if ( repository == null )
+        {
+            repository = new AdminRepositoryConfiguration();
+        }
+
+        return repository;
+    }
+
+    protected boolean operationAllowed( String permission, String repoid )
+    {
+        ActionContext context = ActionContext.getContext();
+        SecuritySession securitySession = (SecuritySession) context.get( SecuritySession.ROLE );
+
+        AuthorizationResult authzResult;
+        try
+        {
+            authzResult = securitySystem.authorize( securitySession, permission, repoid );
+
+            return authzResult.isAuthorized();
+        }
+        catch ( AuthorizationException e )
+        {
+            getLogger().info(
+                              "Unable to authorize permission: " + permission + " against repo: " + repoid
+                                  + " due to: " + e.getMessage() );
+            return false;
+        }
+    }
+
+    protected void removeRepository( String repoId )
+    {
+        getLogger().info( ".removeRepository()" );
+
+        RepositoryConfiguration toremove = archivaConfiguration.getConfiguration().findRepositoryById( repoId );
+        if ( toremove != null )
+        {
+            archivaConfiguration.getConfiguration().removeRepository( toremove );
+        }
+    }
+
+    protected String saveConfiguration()
+        throws IOException, InvalidConfigurationException, RbacManagerException, RoleProfileException,
+        RegistryException
+    {
+        getLogger().info( ".saveConfiguration()" );
+
+        archivaConfiguration.save( archivaConfiguration.getConfiguration() );
+
+        addActionMessage( "Successfully saved configuration" );
+
+        return SUCCESS;
+    }
+}
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AdminModel.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AdminModel.java
deleted file mode 100644 (file)
index 6431a5f..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-package org.apache.maven.archiva.web.action.admin;
-
-/*
- * 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.
- */
-
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.RepositoryConfiguration;
-import org.apache.maven.archiva.model.RepositoryURL;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * AdminModel 
- *
- * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class AdminModel
-{
-    private String baseUrl;
-    
-    private List managedRepositories = new ArrayList();
-
-    private List remoteRepositories = new ArrayList();
-
-    public AdminModel()
-    {
-        /* do nothing */
-    }
-
-    public AdminModel( Configuration configuration )
-    {
-        Iterator it = configuration.getRepositories().iterator();
-        while ( it.hasNext() )
-        {
-            RepositoryConfiguration repoconfig = (RepositoryConfiguration) it.next();
-            RepositoryURL repourl = new RepositoryURL( repoconfig.getUrl() );
-            if ( "file".equals( repourl.getProtocol() ) )
-            {
-                managedRepositories.add( repoconfig );
-            }
-            else
-            {
-                remoteRepositories.add( repoconfig );
-            }
-        }
-    }
-
-    public List getManagedRepositories()
-    {
-        return managedRepositories;
-    }
-
-    public void setManagedRepositories( List managedRepositories )
-    {
-        this.managedRepositories = managedRepositories;
-    }
-
-    public List getRemoteRepositories()
-    {
-        return remoteRepositories;
-    }
-
-    public void setRemoteRepositories( List remoteRepositories )
-    {
-        this.remoteRepositories = remoteRepositories;
-    }
-
-    public String getBaseUrl()
-    {
-        return baseUrl;
-    }
-
-    public void setBaseUrl( String baseUrl )
-    {
-        this.baseUrl = baseUrl;
-    }
-}
index 5f61766a1bd59b2ddecf7a9f91982ce474c86f02..c5cac433722203defc3066f6176ea527f803fe04 100644 (file)
@@ -60,6 +60,7 @@ public class ConfigureAction
     
     public void validate()
     {
+        getLogger().info( "validate()" );
         //validate cron expression
     }
 
@@ -67,6 +68,7 @@ public class ConfigureAction
         throws IOException, RepositoryIndexException, RepositoryIndexSearchException, InvalidConfigurationException,
         RegistryException
     {
+        getLogger().info( "execute()" );
         // TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded
         // TODO: if this is changed, do we move the index or recreate it?
 
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureProxiedRepositoryAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureProxiedRepositoryAction.java
deleted file mode 100644 (file)
index 57b46bd..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.apache.maven.archiva.web.action.admin;
-
-/*
- * 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.
- */
-
-//import org.apache.maven.archiva.configuration.AbstractRepositoryConfiguration;
-//import org.apache.maven.archiva.configuration.ProxiedRepositoryConfiguration;
-
-import java.io.IOException;
-
-/**
- * Configures the application repositories.
- *
- * @plexus.component role="com.opensymphony.xwork.Action" role-hint="configureProxiedRepositoryAction"
- */
-public class ConfigureProxiedRepositoryAction
-    extends AbstractConfigureRepositoryAction
-{
-//    protected void removeRepository( AbstractRepositoryConfiguration existingRepository )
-//    {
-//        configuration.removeProxiedRepository( (ProxiedRepositoryConfiguration) existingRepository );
-//    }
-//
-//    protected AbstractRepositoryConfiguration getRepository( String id )
-//    {
-//        return configuration.getProxiedRepositoryById( id );
-//    }
-
-    protected void addRepository()
-        throws IOException
-    {
-//        ProxiedRepositoryConfiguration repository = (ProxiedRepositoryConfiguration) getRepository();
-//
-//        configuration.addProxiedRepository( repository );
-    }
-
-//    protected AbstractRepositoryConfiguration createRepository()
-//    {
-//        return new ProxiedRepositoryConfiguration();
-//    }
-}
index 9edd013e76d782e10b297141aede4aebb5eb2b64..de4b88c9a07bef8e71138fed75dfcea5e07bd69c 100644 (file)
@@ -19,9 +19,25 @@ package org.apache.maven.archiva.web.action.admin;
  * under the License.
  */
 
-//import org.apache.maven.archiva.configuration.AbstractRepositoryConfiguration;
+import com.opensymphony.xwork.ModelDriven;
+import com.opensymphony.xwork.Preparable;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.InvalidConfigurationException;
 import org.apache.maven.archiva.configuration.RepositoryConfiguration;
+import org.apache.maven.archiva.security.ArchivaRoleConstants;
+import org.apache.maven.archiva.web.action.admin.models.AdminRepositoryConfiguration;
 import org.codehaus.plexus.rbac.profile.RoleProfileException;
+import org.codehaus.plexus.rbac.profile.RoleProfileManager;
+import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.plexus.security.rbac.RbacManagerException;
+import org.codehaus.plexus.security.rbac.Resource;
+import org.codehaus.plexus.security.ui.web.interceptor.SecureAction;
+import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle;
+import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException;
+import org.codehaus.plexus.xwork.action.PlexusActionSupport;
 
 import java.io.File;
 import java.io.IOException;
@@ -32,44 +48,244 @@ import java.io.IOException;
  * @plexus.component role="com.opensymphony.xwork.Action" role-hint="configureRepositoryAction"
  */
 public class ConfigureRepositoryAction
-    extends AbstractConfigureRepositoryAction
+    extends PlexusActionSupport
+    implements ModelDriven, Preparable, SecureAction
 {
-//    protected void removeRepository( AbstractRepositoryConfiguration existingRepository )
-//    {
-//        configuration.removeRepository( (RepositoryConfiguration) existingRepository );
-//    }
-//
-//    protected AbstractRepositoryConfiguration getRepository( String id )
-//    {
-//        return configuration.getRepositoryById( id );
-//    }
-
-    protected void addRepository()
+    /**
+     * @plexus.requirement
+     */
+    private ArchivaConfiguration archivaConfiguration;
+
+    /**
+     * @plexus.requirement role-hint="archiva"
+     */
+    private RoleProfileManager roleProfileManager;
+
+    /**
+     * The repository.
+     */
+    private AdminRepositoryConfiguration repository;
+
+    /**
+     * The repository ID to lookup when editing a repository.
+     */
+    private String repoId;
+
+    /**
+     * The previously read configuration.
+     */
+    private Configuration configuration;
+
+    public String add()
+        throws IOException, InvalidConfigurationException, RbacManagerException, RoleProfileException,
+        RegistryException
+    {
+        // TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded
+        getLogger().info( ".add()" );
+
+        AdminRepositoryConfiguration existingRepository = getRepository( repository.getId() );
+        if ( existingRepository != null )
+        {
+            addFieldError( "id", "A repository with that id already exists" );
+            return INPUT;
+        }
+
+        return saveConfiguration();
+    }
+
+    public String edit()
+        throws IOException, InvalidConfigurationException, RbacManagerException, RoleProfileException,
+        RegistryException
+    {
+        // TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded
+        getLogger().info( ".edit()" );
+
+        if ( StringUtils.isBlank( repository.getId() ) )
+        {
+            addFieldError( "id", "A repository with a blank id cannot be editted." );
+            return INPUT;
+        }
+
+        removeRepository( getRepository() );
+
+        addRepository();
+
+        return saveConfiguration();
+    }
+
+    public Configuration getConfiguration()
+    {
+        return configuration;
+    }
+
+    public Object getModel()
+    {
+        getLogger().info( ".getModel()" );
+        if( repository == null )
+        {
+            repository = createRepository();
+        }
+        
+        return repository;
+    }
+
+    public String getRepoId()
+    {
+        return repoId;
+    }
+
+    public SecureActionBundle getSecureActionBundle()
+        throws SecureActionException
+    {
+        SecureActionBundle bundle = new SecureActionBundle();
+
+        bundle.setRequiresAuthentication( true );
+
+        if ( getRepoId() != null )
+        {
+            // TODO: this is not right. It needs to change based on method. But is this really the right way to restrict this area?
+            // TODO: not right. We only care about this permission on managed repositories. Otherwise, it's configuration
+            bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_EDIT_REPOSITORY, getRepoId() );
+        }
+        else
+        {
+            bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
+        }
+
+        return bundle;
+    }
+
+    public String input()
+    {
+        getLogger().info( ".input()" );
+        return INPUT;
+    }
+    
+    public String doDefault()
+        throws Exception
+    {
+        getLogger().info( ".doDefault()" );
+        return super.doDefault();
+    }
+    
+    public String doInput()
+        throws Exception
+    {
+        getLogger().info( ".doInput()" );
+        return super.doInput();
+    }
+    
+    public void validate()
+    {
+        getLogger().info( ".validate()" );
+        // super.validate();
+    }
+    
+    public String execute()
+        throws Exception
+    {
+        getLogger().info( ".execute()" );
+        return super.execute();
+    }
+
+    public void prepare()
+    {
+        getLogger().info( ".prepare()" );
+        configuration = archivaConfiguration.getConfiguration();
+
+        if ( repository == null )
+        {
+            repository = getRepository( repoId );
+        }
+        if ( repository == null )
+        {
+            repository = createRepository();
+        }
+    }
+
+    public void setRepoId( String repoId )
+    {
+        this.repoId = repoId;
+    }
+    
+    private void addRepository()
         throws IOException, RoleProfileException
     {
-//        RepositoryConfiguration repository = (RepositoryConfiguration) getRepository();
-//
-//        // Normalize the path
-//        File file = new File( repository.getDirectory() );
-//        repository.setDirectory( file.getCanonicalPath() );
-//        if ( !file.exists() )
-//        {
-//            file.mkdirs();
-//            // TODO: error handling when this fails, or is not a directory!
-//        }
-//
-//        configuration.addRepository( repository );
-//
-//        // TODO: double check these are configured on start up
-//        roleProfileManager.getDynamicRole( "archiva-repository-manager", repository.getId() );
-//
-//        roleProfileManager.getDynamicRole( "archiva-repository-observer", repository.getId() );
-    }
-
-//    protected AbstractRepositoryConfiguration createRepository()
-//    {
-//        RepositoryConfiguration repository = new RepositoryConfiguration();
-//        repository.setIndexed( false );
-//        return repository;
-//    }
+        getLogger().info( ".addRepository()" );
+        AdminRepositoryConfiguration repository = (AdminRepositoryConfiguration) getRepository();
+
+        if ( repository.isManaged() )
+        {
+            // Normalize the path
+            File file = new File( repository.getDirectory() );
+            repository.setDirectory( file.getCanonicalPath() );
+            if ( !file.exists() )
+            {
+                file.mkdirs();
+                // TODO: error handling when this fails, or is not a directory!
+            }
+        }
+
+        configuration.addRepository( repository );
+
+        // TODO: double check these are configured on start up
+        roleProfileManager.getDynamicRole( "archiva-repository-manager", repository.getId() );
+
+        roleProfileManager.getDynamicRole( "archiva-repository-observer", repository.getId() );
+    }
+
+    private AdminRepositoryConfiguration createRepository()
+    {
+        getLogger().info( ".createRepository()" );
+        AdminRepositoryConfiguration repository = new AdminRepositoryConfiguration();
+        repository.setIndexed( false );
+        return repository;
+    }
+
+    private AdminRepositoryConfiguration getRepository()
+    {
+        return repository;
+    }
+
+    private AdminRepositoryConfiguration getRepository( String id )
+    {
+        getLogger().info( ".getRepository(" + id + ")" );
+
+        RepositoryConfiguration repoconfig = configuration.findRepositoryById( id );
+        if ( repoconfig == null )
+        {
+            return createRepository();
+        }
+        return new AdminRepositoryConfiguration( repoconfig );
+    }
+
+    private boolean removeRepository( RepositoryConfiguration existingRepository )
+    {
+        getLogger().info( ".removeRepository()" );
+
+        RepositoryConfiguration toremove = configuration.findRepositoryById( existingRepository.getId() );
+        if ( toremove != null )
+        {
+            configuration.removeRepository( toremove );
+            return true;
+        }
+        
+        return false;
+    }
+
+    private String saveConfiguration()
+        throws IOException, InvalidConfigurationException, RbacManagerException, RoleProfileException,
+        RegistryException
+    {
+        getLogger().info( ".saveConfiguration()" );
+        addRepository();
+
+        archivaConfiguration.save( configuration );
+
+        // TODO: do we need to check if indexing is needed?
+
+        addActionMessage( "Successfully saved configuration" );
+
+        return SUCCESS;
+    }
 }
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureSyncedRepositoryAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureSyncedRepositoryAction.java
deleted file mode 100644 (file)
index b374378..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.apache.maven.archiva.web.action.admin;
-
-/*
- * 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.
- */
-
-//import org.apache.maven.archiva.configuration.AbstractRepositoryConfiguration;
-//import org.apache.maven.archiva.configuration.SyncedRepositoryConfiguration;
-
-import java.io.IOException;
-
-/**
- * Configures the application repositories.
- *
- * @plexus.component role="com.opensymphony.xwork.Action" role-hint="configureSyncedRepositoryAction"
- */
-public class ConfigureSyncedRepositoryAction
-    extends AbstractConfigureRepositoryAction
-{
-//    protected void removeRepository( AbstractRepositoryConfiguration existingRepository )
-//    {
-//        configuration.removeSyncedRepository( (SyncedRepositoryConfiguration) existingRepository );
-//    }
-//
-//    protected AbstractRepositoryConfiguration getRepository( String id )
-//    {
-//        return configuration.getSyncedRepositoryById( id );
-//    }
-
-    protected void addRepository()
-        throws IOException
-    {
-//        SyncedRepositoryConfiguration repository = (SyncedRepositoryConfiguration) getRepository();
-//
-//        configuration.addSyncedRepository( repository );
-    }
-
-//    protected AbstractRepositoryConfiguration createRepository()
-//    {
-//        return new SyncedRepositoryConfiguration();
-//    }
-}
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/DeleteProxiedRepositoryAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/DeleteProxiedRepositoryAction.java
deleted file mode 100644 (file)
index 1da7550..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.apache.maven.archiva.web.action.admin;
-
-/*
- * 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.
- */
-
-//import org.apache.maven.archiva.configuration.AbstractRepositoryConfiguration;
-import org.apache.maven.archiva.configuration.Configuration;
-//import org.apache.maven.archiva.configuration.ProxiedRepositoryConfiguration;
-
-import java.io.IOException;
-
-/**
- * Configures the application repositories.
- *
- * @plexus.component role="com.opensymphony.xwork.Action" role-hint="deleteProxiedRepositoryAction"
- */
-public class DeleteProxiedRepositoryAction
-    extends AbstractDeleteRepositoryAction
-{
-//    protected AbstractRepositoryConfiguration getRepository( Configuration configuration )
-//    {
-//        return configuration.getProxiedRepositoryById( repoId );
-//    }
-//
-//    protected void removeRepository( Configuration configuration, AbstractRepositoryConfiguration existingRepository )
-//    {
-//        configuration.removeProxiedRepository( (ProxiedRepositoryConfiguration) existingRepository );
-//    }
-//
-//    protected void removeContents( AbstractRepositoryConfiguration existingRepository )
-//        throws IOException
-//    {
-//        // TODO! delete it
-//    }
-}
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/DeleteSyncedRepositoryAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/DeleteSyncedRepositoryAction.java
deleted file mode 100644 (file)
index 4288666..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.apache.maven.archiva.web.action.admin;
-
-/*
- * 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.
- */
-
-//import org.apache.maven.archiva.configuration.AbstractRepositoryConfiguration;
-import org.apache.maven.archiva.configuration.Configuration;
-//import org.apache.maven.archiva.configuration.SyncedRepositoryConfiguration;
-
-import java.io.IOException;
-
-/**
- * Configures the application repositories.
- *
- * @plexus.component role="com.opensymphony.xwork.Action" role-hint="deleteSyncedRepositoryAction"
- */
-public class DeleteSyncedRepositoryAction
-    extends AbstractDeleteRepositoryAction
-{
-//    protected AbstractRepositoryConfiguration getRepository( Configuration configuration )
-//    {
-//        return configuration.getSyncedRepositoryById( repoId );
-//    }
-//
-//    protected void removeRepository( Configuration configuration, AbstractRepositoryConfiguration existingRepository )
-//    {
-//        configuration.removeSyncedRepository( (SyncedRepositoryConfiguration) existingRepository );
-//    }
-//
-//    protected void removeContents( AbstractRepositoryConfiguration existingRepository )
-//        throws IOException
-//    {
-//        // TODO! remove the contents
-//    }
-}
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/EditRepositoryAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/EditRepositoryAction.java
new file mode 100644 (file)
index 0000000..ff6cce0
--- /dev/null
@@ -0,0 +1,71 @@
+package org.apache.maven.archiva.web.action.admin;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.archiva.configuration.RepositoryConfiguration;
+import org.apache.maven.archiva.security.ArchivaRoleConstants;
+import org.apache.maven.archiva.web.action.admin.models.AdminRepositoryConfiguration;
+
+/**
+ * EditRepositoryAction 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ * 
+ * @plexus.component role="com.opensymphony.xwork.Action" role-hint="editRepositoryAction"
+ */
+public class EditRepositoryAction
+    extends AbstractRepositoryAction
+{
+    public String edit()
+    {
+        getLogger().info( ".edit()" );
+
+        if ( operationAllowed( ArchivaRoleConstants.OPERATION_EDIT_REPOSITORY, getRepoid() ) )
+        {
+            addActionError( "You do not have the appropriate permissions to edit the " + getRepoid() + " repository." );
+            return ERROR;
+        }
+
+        return INPUT;
+    }
+
+    public void prepare()
+        throws Exception
+    {
+        String id = getRepoid();
+        if ( id == null )
+        {
+            // TODO: Throw error?
+            return;
+        }
+
+        RepositoryConfiguration repoconfig = archivaConfiguration.getConfiguration().findRepositoryById( id );
+        if ( repoconfig != null )
+        {
+            this.repository = new AdminRepositoryConfiguration( repoconfig );
+        }
+    }
+
+    public String getMode()
+    {
+        return "edit";
+    }
+}
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/IndexRepositoryAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/IndexRepositoryAction.java
new file mode 100644 (file)
index 0000000..2dbf69b
--- /dev/null
@@ -0,0 +1,120 @@
+package org.apache.maven.archiva.web.action.admin;
+
+/*
+ * 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.
+ */
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler;
+import org.apache.maven.archiva.scheduled.DefaultArchivaTaskScheduler;
+import org.apache.maven.archiva.scheduled.tasks.ArchivaTask;
+import org.apache.maven.archiva.scheduled.tasks.RepositoryTask;
+import org.apache.maven.archiva.security.ArchivaRoleConstants;
+import org.codehaus.plexus.security.rbac.Resource;
+import org.codehaus.plexus.security.ui.web.interceptor.SecureAction;
+import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle;
+import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException;
+import org.codehaus.plexus.taskqueue.TaskQueueException;
+import org.codehaus.plexus.xwork.action.PlexusActionSupport;
+
+/**
+ * Configures the application.
+ *
+ * @plexus.component role="com.opensymphony.xwork.Action" role-hint="indexRepositoryAction"
+ */
+public class IndexRepositoryAction
+    extends PlexusActionSupport
+    implements SecureAction
+{
+    /**
+     * @plexus.requirement
+     */
+    private ArchivaTaskScheduler taskScheduler;
+
+    private String repoid;
+
+    public String run()
+    {
+        if ( StringUtils.isBlank( repoid ) )
+        {
+            addActionError( "Cannot run indexer on blank repository id." );
+            return SUCCESS;
+        }
+
+        RepositoryTask task = new RepositoryTask();
+        task.setRepositoryId( repoid );
+        task.setName( DefaultArchivaTaskScheduler.REPOSITORY_JOB + ":" + repoid );
+        task.setQueuePolicy( ArchivaTask.QUEUE_POLICY_WAIT );
+
+        boolean scheduleTask = false;
+
+        if ( taskScheduler.getTaskQueue().hasFilesystemTaskInQueue() )
+        {
+            if ( taskScheduler.getTaskQueue().hasRepositoryTaskInQueue( repoid ) )
+            {
+                addActionError( "Repository [" + repoid + "] task was already queued." );
+            }
+            else
+            {
+                scheduleTask = true;
+            }
+        }
+        else
+        {
+            scheduleTask = true;
+        }
+
+        if ( scheduleTask )
+        {
+            try
+            {
+                taskScheduler.getTaskQueue().put( task );
+                addActionMessage( "Your request to have repository [" + repoid + "] be indexed has been queued." );
+            }
+            catch ( TaskQueueException e )
+            {
+                addActionError( "Unable to queue your request to have repository [" + repoid + "] be indexed: "
+                    + e.getMessage() );
+            }
+        }
+
+        // Return to the repositories screen.
+        return SUCCESS;
+    }
+
+    public SecureActionBundle getSecureActionBundle()
+        throws SecureActionException
+    {
+        SecureActionBundle bundle = new SecureActionBundle();
+
+        bundle.setRequiresAuthentication( true );
+        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_RUN_INDEXER, Resource.GLOBAL );
+
+        return bundle;
+    }
+
+    public String getRepoid()
+    {
+        return repoid;
+    }
+
+    public void setRepoid( String repoid )
+    {
+        this.repoid = repoid;
+    }
+}
index ddbcf6e8b205a2a77be6745d52d5df4ac758fc8d..e9fcc4199c793b08eb816137171f70c20f94439a 100644 (file)
@@ -26,13 +26,21 @@ import com.opensymphony.xwork.Validateable;
 
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.database.ArchivaDAO;
+import org.apache.maven.archiva.database.constraints.MostRecentRepositoryScanStatistics;
+import org.apache.maven.archiva.model.RepositoryContentStatistics;
 import org.apache.maven.archiva.security.ArchivaRoleConstants;
+import org.apache.maven.archiva.web.action.admin.models.AdminModel;
+import org.apache.maven.archiva.web.action.admin.models.AdminRepositoryConfiguration;
+import org.apache.maven.archiva.web.util.ContextUtils;
 import org.codehaus.plexus.security.rbac.Resource;
 import org.codehaus.plexus.security.ui.web.interceptor.SecureAction;
 import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle;
 import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException;
 import org.codehaus.plexus.xwork.action.PlexusActionSupport;
 
+import java.util.Iterator;
+import java.util.List;
+
 import javax.servlet.http.HttpServletRequest;
 
 /**
@@ -47,29 +55,30 @@ public class RepositoriesAction
     extends PlexusActionSupport
     implements ModelDriven, Preparable, Validateable, SecureAction, ServletRequestAware
 {
-    /**
-     * @plexus.requirement
-     */
-    private ArchivaConfiguration archivaConfiguration;
-
     /**
      * @plexus.requirement role-hint="jdo"
      */
     private ArchivaDAO dao;
 
-    private HttpServletRequest request;
+    /**
+     * @plexus.requirement
+     */
+    private ArchivaConfiguration archivaConfiguration;
 
     private AdminModel model;
 
+    private String baseUrl;
+
     public Object getModel()
     {
-        return model;
+        return getAdminModel();
     }
 
     public void prepare()
         throws Exception
     {
-        model = new AdminModel( archivaConfiguration.getConfiguration() );
+        model = null;
+        getModel();
     }
 
     public void validate()
@@ -77,6 +86,13 @@ public class RepositoriesAction
         super.validate();
     }
 
+    public String execute()
+        throws Exception
+    {
+        getLogger().info( ".execute()" );
+        return super.execute();
+    }
+
     public SecureActionBundle getSecureActionBundle()
         throws SecureActionException
     {
@@ -90,22 +106,44 @@ public class RepositoriesAction
 
     public void setServletRequest( HttpServletRequest request )
     {
-        this.request = request;
-        StringBuffer baseUrl = new StringBuffer();
+        this.baseUrl = ContextUtils.getBaseURL( request, "repository" );
+    }
 
-        baseUrl.append( request.getScheme() );
-        baseUrl.append( request.getServerName() );
-        int portnum = request.getServerPort();
+    public AdminModel getAdminModel()
+    {
+        if ( model == null )
+        {
+            model = new AdminModel( archivaConfiguration.getConfiguration() );
+            model.setBaseUrl( baseUrl );
+            updateLastIndexed( model.getManagedRepositories() );
+        }
+
+        return model;
+    }
 
-        // Only add port if non-standard.
-        if ( ( "https".equalsIgnoreCase( request.getScheme() ) && ( portnum != 443 ) )
-            || ( "http".equalsIgnoreCase( request.getScheme() ) && ( portnum != 80 ) ) )
+    private void updateLastIndexed( List managedRepositories )
+    {
+        Iterator it = managedRepositories.iterator();
+        while ( it.hasNext() )
         {
-            baseUrl.append( ":" ).append( String.valueOf( portnum ) );
+            AdminRepositoryConfiguration config = (AdminRepositoryConfiguration) it.next();
+
+            List results = dao.query( new MostRecentRepositoryScanStatistics( config.getId() ) );
+            if ( !results.isEmpty() )
+            {
+                RepositoryContentStatistics stats = (RepositoryContentStatistics) results.get( 0 );
+                config.setStats( stats );
+            }
         }
-        baseUrl.append( request.getContextPath() );
-        baseUrl.append( "/repository" );
+    }
 
-        model.setBaseUrl( baseUrl.toString() );
+    public String getBaseUrlB()
+    {
+        return baseUrl;
+    }
+
+    public void setBaseUrlB( String baseUrl )
+    {
+        this.baseUrl = baseUrl;
     }
 }
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/RunRepositoryTaskAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/RunRepositoryTaskAction.java
deleted file mode 100644 (file)
index 7028613..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.apache.maven.archiva.web.action.admin;
-
-/*
- * 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.
- */
-
-//import org.apache.maven.archiva.scheduler.RepositoryTaskScheduler;
-import org.apache.maven.archiva.security.ArchivaRoleConstants;
-import org.codehaus.plexus.security.rbac.Resource;
-import org.codehaus.plexus.security.ui.web.interceptor.SecureAction;
-import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle;
-import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException;
-//import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
-import org.codehaus.plexus.xwork.action.PlexusActionSupport;
-
-/**
- * Configures the application.
- *
- * @plexus.component role="com.opensymphony.xwork.Action" role-hint="runRepositoryTaskAction"
- */
-public class RunRepositoryTaskAction
-    extends PlexusActionSupport
-    implements SecureAction
-{
-//    /**
-//     * @plexus.requirement
-//     */
-//    private RepositoryTaskScheduler taskScheduler;
-
-    public String runRefresh()
-    {
-//        taskScheduler.runDataRefresh();
-
-        return SUCCESS;
-    }
-
-    public SecureActionBundle getSecureActionBundle()
-        throws SecureActionException
-    {
-        SecureActionBundle bundle = new SecureActionBundle();
-
-        bundle.setRequiresAuthentication( true );
-        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_RUN_INDEXER, Resource.GLOBAL );
-
-        return bundle;
-    }
-}
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SaveRepositoryAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SaveRepositoryAction.java
new file mode 100644 (file)
index 0000000..8aa9bb4
--- /dev/null
@@ -0,0 +1,93 @@
+package org.apache.maven.archiva.web.action.admin;
+
+/*
+ * 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.
+ */
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.configuration.InvalidConfigurationException;
+import org.codehaus.plexus.rbac.profile.RoleProfileException;
+import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.plexus.security.rbac.RbacManagerException;
+
+import java.io.IOException;
+
+/**
+ * SaveRepositoryAction 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ * 
+ * @plexus.component role="com.opensymphony.xwork.Action" role-hint="saveRepositoryAction" 
+ */
+public class SaveRepositoryAction
+    extends AbstractRepositoryAction
+{
+    public void prepare()
+        throws Exception
+    {
+        /* nothing to do here */
+    }
+
+    public String save()
+    {
+        String mode = getMode();
+        String repoId = getRepository().getId();
+        
+        getLogger().info( "edit(" + mode + ":" + repoId + ")" );
+        
+        if ( StringUtils.isBlank( repository.getId() ) )
+        {
+            addFieldError( "id", "A repository with a blank id cannot be saved." );
+            return SUCCESS;
+        }
+
+        if( StringUtils.equalsIgnoreCase( "edit", mode ) )
+        {
+            removeRepository( repoId );
+        }
+
+        try
+        {
+            addRepository( getRepository() );
+            saveConfiguration();
+        }
+        catch ( IOException e )
+        {
+            addActionError( "I/O Exception: " + e.getMessage() );
+        }
+        catch ( RoleProfileException e )
+        {
+            addActionError( "Role Profile Exception: " + e.getMessage() );
+        }
+        catch ( InvalidConfigurationException e )
+        {
+            addActionError( "Invalid Configuration Exception: " + e.getMessage() );
+        }
+        catch ( RbacManagerException e )
+        {
+            addActionError( "RBAC Manager Exception: " + e.getMessage() );
+        }
+        catch ( RegistryException e )
+        {
+            addActionError( "Configuration Registry Exception: " + e.getMessage() );
+        }
+        
+        return SUCCESS;
+    }
+}
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/models/AdminModel.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/models/AdminModel.java
new file mode 100644 (file)
index 0000000..3ea4c5a
--- /dev/null
@@ -0,0 +1,110 @@
+package org.apache.maven.archiva.web.action.admin.models;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.RepositoryConfiguration;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * AdminModel 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class AdminModel
+{
+    private String baseUrl;
+
+    private List managedRepositories = new ArrayList();
+
+    private List remoteRepositories = new ArrayList();
+
+    private Map repoMap = new HashMap();
+
+    public AdminModel()
+    {
+        /* do nothing */
+    }
+
+    public AdminModel( Configuration configuration )
+    {
+        repoMap.putAll( configuration.createRepositoryMap() );
+
+        Iterator it = configuration.getRepositories().iterator();
+        while ( it.hasNext() )
+        {
+            RepositoryConfiguration repoconfig = (RepositoryConfiguration) it.next();
+            if ( repoconfig.isManaged() )
+            {
+                managedRepositories.add( new AdminRepositoryConfiguration( repoconfig ) );
+            }
+            else if ( repoconfig.isRemote() )
+            {
+                remoteRepositories.add( repoconfig );
+            }
+            else
+            {
+                // Should never occur, but it is possible that the configuration could
+                // contain a repository configuration which is null.
+            }
+        }
+    }
+
+    public List getManagedRepositories()
+    {
+        return managedRepositories;
+    }
+
+    public void setManagedRepositories( List managedRepositories )
+    {
+        this.managedRepositories = managedRepositories;
+    }
+
+    public List getRemoteRepositories()
+    {
+        return remoteRepositories;
+    }
+
+    public void setRemoteRepositories( List remoteRepositories )
+    {
+        this.remoteRepositories = remoteRepositories;
+    }
+
+    public String getBaseUrl()
+    {
+        return baseUrl;
+    }
+
+    public void setBaseUrl( String baseUrl )
+    {
+        this.baseUrl = baseUrl;
+    }
+
+    public String toString()
+    {
+        return "[ActionModel]";
+    }
+}
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/models/AdminRepositoryConfiguration.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/models/AdminRepositoryConfiguration.java
new file mode 100644 (file)
index 0000000..e685775
--- /dev/null
@@ -0,0 +1,102 @@
+package org.apache.maven.archiva.web.action.admin.models;
+
+/*
+ * 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.
+ */
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.common.utils.PathUtil;
+import org.apache.maven.archiva.configuration.RepositoryConfiguration;
+import org.apache.maven.archiva.model.RepositoryContentStatistics;
+import org.apache.maven.archiva.model.RepositoryURL;
+
+import java.io.File;
+
+/**
+ * AdminRepositoryConfiguration 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class AdminRepositoryConfiguration
+    extends RepositoryConfiguration
+{
+    private String directory;
+
+    private RepositoryContentStatistics stats;
+
+    public AdminRepositoryConfiguration()
+    {
+        super();
+    }
+
+    /**
+     * Copy Constructor.
+     */
+    public AdminRepositoryConfiguration( RepositoryConfiguration repoconfig )
+    {
+        this.setId( repoconfig.getId() );
+        this.setName( repoconfig.getName() );
+        this.setUrl( repoconfig.getUrl() );
+        this.setLayout( repoconfig.getLayout() );
+        this.setIndexed( repoconfig.isIndexed() );
+        this.setReleases( repoconfig.isReleases() );
+        this.setSnapshots( repoconfig.isSnapshots() );
+
+        this.setIndexDir( repoconfig.getIndexDir() );
+        this.setRefreshCronExpression( repoconfig.getRefreshCronExpression() );
+
+        if ( repoconfig.isManaged() )
+        {
+            RepositoryURL url = new RepositoryURL( repoconfig.getUrl() );
+            this.setDirectory( url.getPath() );
+        }
+    }
+
+    public boolean isDirectoryExists()
+    {
+        if ( StringUtils.isBlank( directory ) )
+        {
+            return false;
+        }
+
+        File dir = new File( directory );
+        return ( dir.exists() && dir.isDirectory() );
+    }
+
+    public String getDirectory()
+    {
+        return directory;
+    }
+
+    public void setDirectory( String directory )
+    {
+        this.directory = directory;
+        this.setUrl( PathUtil.toUrl( directory ) );
+    }
+
+    public RepositoryContentStatistics getStats()
+    {
+        return stats;
+    }
+
+    public void setStats( RepositoryContentStatistics stats )
+    {
+        this.stats = stats;
+    }
+}
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/interceptor/WebworkIsDoingStrangeThingsInterceptor.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/interceptor/WebworkIsDoingStrangeThingsInterceptor.java
new file mode 100644 (file)
index 0000000..a61c12e
--- /dev/null
@@ -0,0 +1,140 @@
+package org.apache.maven.archiva.web.interceptor;
+
+/*
+ * 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.
+ */
+
+import com.opensymphony.xwork.ActionContext;
+import com.opensymphony.xwork.ActionInvocation;
+import com.opensymphony.xwork.ActionProxy;
+import com.opensymphony.xwork.interceptor.Interceptor;
+import com.opensymphony.xwork.interceptor.PreResultListener;
+
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * WebworkIsDoingStrangeThingsInterceptor 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ * @plexus.component role="com.opensymphony.xwork.interceptor.Interceptor"
+ *                   role-hint="webwork-is-doing-strange-things"
+ */
+public class WebworkIsDoingStrangeThingsInterceptor
+    extends AbstractLogEnabled
+    implements Interceptor, PreResultListener
+{
+    private String hint = "(nohint)";
+
+    public void init()
+    {
+        getLogger().info( ".init()" );
+    }
+
+    public String intercept( ActionInvocation invocation )
+        throws Exception
+    {
+        StringBuffer dbg = new StringBuffer();
+
+        invocation.addPreResultListener( this );
+
+        dbg.append( "[" ).append( hint ).append( "] " );
+        dbg.append( ".intercept(" ).append( invocation.getClass().getName() ).append( ")" );
+        dbg.append( "\n Action=" ).append( invocation.getAction().getClass().getName() );
+
+        ActionProxy proxy = invocation.getProxy();
+        dbg.append( "\n Proxy=" ).append( proxy.getClass().getName() );
+        dbg.append( "\n    .namespace  =" ).append( proxy.getNamespace() );
+        dbg.append( "\n    .actionName =" ).append( proxy.getActionName() );
+        dbg.append( "\n    .method     =" ).append( proxy.getMethod() );
+        dbg.append( "\n    .execute result =" ).append( proxy.getExecuteResult() );
+
+        ActionContext context = invocation.getInvocationContext();
+        dbg.append( "\n InvocationContext=" ).append( context.getClass().getName() );
+        appendMap( "\n    .session=", dbg, context.getSession() );
+        appendMap( "\n    .parameters=", dbg, context.getParameters() );
+
+        String result = invocation.invoke();
+
+        dbg.append( "\n ... result=\"" ).append( result ).append( "\"" );
+        dbg.append( ", code=" ).append( invocation.getResultCode() );
+        getLogger().info( dbg.toString() );
+        return result;
+    }
+
+    private void appendMap( String heading, StringBuffer dbg, Map map )
+    {
+        dbg.append( heading );
+
+        if ( map == null )
+        {
+            dbg.append( "<null>" );
+            return;
+        }
+
+        if ( map.isEmpty() )
+        {
+            dbg.append( "<empty>" );
+            return;
+        }
+
+        Iterator entries = map.entrySet().iterator();
+        while ( entries.hasNext() )
+        {
+            Map.Entry entry = (Entry) entries.next();
+            String key = (String) entry.getKey();
+            Object value = entry.getValue();
+            dbg.append( "\n      [" ).append( key ).append( "]: " );
+            if ( value == null )
+            {
+                dbg.append( "<null>" );
+            }
+            else
+            {
+                try
+                {
+                    dbg.append( value.toString() );
+                }
+                catch ( NullPointerException e )
+                {
+                    dbg.append( "<npe>" );
+                }
+            }
+        }
+
+    }
+
+    public void destroy()
+    {
+        getLogger().info( ".destroy()" );
+    }
+
+    public void setHint( String hint )
+    {
+        this.hint = hint;
+    }
+
+    public void beforeResult( ActionInvocation invocation, String resultCode )
+    {
+        getLogger().info( "before result: invocation: " + invocation + ", resultCode: " + resultCode );
+    }
+}
index 073802d0ce06c59a2588b80825a717cf33d786f9..4f43f76e6d48a31a4f03ad51199f6df62128d36b 100644 (file)
@@ -20,6 +20,7 @@ package org.apache.maven.archiva.web.repository;
  */
 
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.ConfigurationNames;
 import org.apache.maven.archiva.database.ArchivaDAO;
 import org.apache.maven.archiva.database.ArchivaDatabaseException;
 import org.apache.maven.archiva.database.ObjectNotFoundException;
@@ -121,7 +122,12 @@ public class RepositoryServlet
 
                 if ( !repoDir.exists() )
                 {
-                    repoDir.mkdirs();
+                    if ( !repoDir.mkdirs() )
+                    {
+                        // Skip invalid directories.
+                        log( "Unable to create missing directory for " + repo.getUrl().getPath() );
+                        continue;
+                    }
                 }
 
                 DavServerComponent server = createServer( repo.getId(), repoDir, servletConfig );
@@ -252,9 +258,8 @@ public class RepositoryServlet
 
     public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
     {
-        if ( propertyName.startsWith( "repositories" ) )
+        if ( ConfigurationNames.isRepositories( propertyName ) )
         {
-            log( "Triggering managed repository configuration change with " + propertyName + " set to " + propertyValue );
             getDavManager().removeAllServers();
 
             try
@@ -267,9 +272,5 @@ public class RepositoryServlet
                      e );
             }
         }
-        else
-        {
-            log( "Not triggering managed repository configuration change with " + propertyName );
-        }
     }
 }
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/CopyPasteSnippet.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/CopyPasteSnippet.java
new file mode 100644 (file)
index 0000000..cf4042e
--- /dev/null
@@ -0,0 +1,115 @@
+package org.apache.maven.archiva.web.tags;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.maven.archiva.configuration.RepositoryConfiguration;
+import org.apache.maven.archiva.web.util.ContextUtils;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+
+import java.io.IOException;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.PageContext;
+
+/**
+ * CopyPasteSnippet 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ * 
+ * @plexus.component role="org.apache.maven.archiva.web.tags.CopyPasteSnippet"
+ */
+public class CopyPasteSnippet
+    extends AbstractLogEnabled
+{
+    public void write( Object o, PageContext pageContext )
+        throws JspException
+    {
+        StringBuffer buf = new StringBuffer();
+
+        if ( o == null )
+        {
+            buf.append( "Error generating snippet." );
+            getLogger().error( "Unable to generate snippet for null object." );
+        }
+        else if ( o instanceof RepositoryConfiguration )
+        {
+            createSnippet( buf, (RepositoryConfiguration) o, pageContext );
+        }
+        else
+        {
+            buf.append( "Unable to generate snippet for object " ).append( o.getClass().getName() );
+        }
+
+        try
+        {
+            JspWriter out = pageContext.getOut();
+            out.write( StringEscapeUtils.escapeXml( buf.toString() ) );
+            out.flush();
+        }
+        catch ( IOException e )
+        {
+            throw new JspException( "Unable to write snippet to output: " + e.getMessage(), e );
+        }
+    }
+
+    private void createSnippet( StringBuffer snippet, RepositoryConfiguration repo, PageContext pageContext )
+    {
+        snippet.append( "<project>\n" );
+        snippet.append( "  ...\n" );
+        snippet.append( "  <distributionManagement>\n" );
+
+        String distRepoName = "repository";
+        if ( repo.isSnapshots() )
+        {
+            distRepoName = "snapshotRepository";
+        }
+
+        snippet.append( "    <" ).append( distRepoName ).append( ">\n" );
+        snippet.append( "      <id>" ).append( repo.getId() ).append( "</id>\n" );
+
+        if ( !"default".equals( repo.getLayout() ) )
+        {
+            snippet.append( "      <layout>" ).append( repo.getLayout() ).append( "</layout>" );
+        }
+
+        snippet.append( "    </" ).append( distRepoName ).append( ">\n" );
+        snippet.append( "  </distributionManagement>\n" );
+        snippet.append( "\n" );
+
+        snippet.append( "  <repositories>\n" );
+        snippet.append( "    <repository>\n" );
+        snippet.append( "      <id>" ).append( repo.getId() ).append( "</id>\n" );
+        snippet.append( "      <name>" ).append( repo.getName() ).append( "</name>\n" );
+
+        snippet.append( "      <url>" );
+        if ( repo.isManaged() )
+        {
+            snippet.append( ContextUtils.getBaseURL( pageContext, "repository" ) );
+            snippet.append( "/" ).append( repo.getId() ).append( "/" );
+        }
+        else
+        {
+            snippet.append( repo.getUrl() );
+        }
+
+        snippet.append( "</url>\n" );
+
+        if ( !"default".equals( repo.getLayout() ) )
+        {
+            snippet.append( "      <layout>" ).append( repo.getLayout() ).append( "</layout>\n" );
+        }
+
+        snippet.append( "      <releases>\n" );
+        snippet.append( "        <enabled>" ).append( Boolean.valueOf( repo.isReleases() ) ).append( "</enabled>\n" );
+        snippet.append( "      </releases>\n" );
+        snippet.append( "      <snapshots>\n" );
+        snippet.append( "        <enabled>" ).append( Boolean.valueOf( repo.isSnapshots() ) ).append( "</enabled>\n" );
+        snippet.append( "      </snapshots>\n" );
+        snippet.append( "    </repository>\n" );
+        snippet.append( "  </repositories>\n" );
+
+        snippet.append( "  ...\n" );
+        snippet.append( "</project>\n" );
+    }
+}
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/CopyPasteSnippetTag.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/CopyPasteSnippetTag.java
new file mode 100644 (file)
index 0000000..8bed58d
--- /dev/null
@@ -0,0 +1,71 @@
+package org.apache.maven.archiva.web.tags;
+
+/*
+ * 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.
+ */
+
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.TagSupport;
+
+/**
+ * CopyPasteSnippetTag 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class CopyPasteSnippetTag
+    extends TagSupport
+{
+    private Object object;
+
+    public void release()
+    {
+        object = null;
+        super.release();
+    }
+
+    public int doEndTag()
+        throws JspException
+    {
+        CopyPasteSnippet snippet;
+        try
+        {
+            snippet = (CopyPasteSnippet) PlexusTagUtil.lookup( pageContext, CopyPasteSnippet.class.getName() );
+        }
+        catch ( ComponentLookupException e )
+        {
+            throw new JspException( "Unable to lookup CopyPasteSnippet: " + e.getMessage(), e );
+        }
+
+        if ( snippet == null )
+        {
+            throw new JspException( "Unable to process snippet.  Component not found." );
+        }
+
+        snippet.write( object, pageContext );
+
+        return super.doEndTag();
+    }
+
+    public void setObject( Object object )
+    {
+        this.object = object;
+    }
+}
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ContextUtils.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ContextUtils.java
new file mode 100644 (file)
index 0000000..bf6a714
--- /dev/null
@@ -0,0 +1,106 @@
+package org.apache.maven.archiva.web.util;
+
+/*
+ * 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.
+ */
+
+import org.apache.commons.lang.StringUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.jsp.PageContext;
+
+/**
+ * ContextUtils 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class ContextUtils
+{
+    private static final Map defaultSchemePortMap;
+
+    static
+    {
+        defaultSchemePortMap = new HashMap();
+        defaultSchemePortMap.put( "http", new Integer( 80 ) );
+        defaultSchemePortMap.put( "https", new Integer( 443 ) );
+    }
+
+    /**
+     * Using the page context, get the base url.
+     * 
+     * @param pageContext the page context to use
+     * @return the base url with module name.
+     */
+    public static String getBaseURL( PageContext pageContext )
+    {
+        return getBaseURL( pageContext, null );
+    }
+
+    /**
+     * Using the page context, get the base url and append an optional resource name to the end of the provided url.
+     * 
+     * @param pageContext the page context to use
+     * @param resource the resource name (or null if no resource name specified)
+     * @return the base url with resource name.
+     */
+    public static String getBaseURL( PageContext pageContext, String resource )
+    {
+        HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
+        return getBaseURL( request, resource );
+    }
+    
+    /**
+     * Using the http servlet request, get the base url and append an optional resource name to the end of the url.
+     * 
+     * @param request the request to use
+     * @param resource the resource name (or null if not resource name should be appended)
+     * @return the base url with resource name.
+     */
+    public static String getBaseURL( HttpServletRequest request, String resource )
+    {
+        StringBuffer baseUrl = new StringBuffer();
+        
+        baseUrl.append( request.getScheme() ).append( "://" );
+        baseUrl.append( request.getServerName() );
+        int portnum = request.getServerPort();
+
+        // Only add port if non-standard.
+        Integer defaultPortnum = (Integer) defaultSchemePortMap.get( request.getScheme() );
+        if ( ( defaultPortnum == null ) || ( defaultPortnum.intValue() != portnum ) )
+        {
+            baseUrl.append( ":" ).append( String.valueOf( portnum ) );
+        }
+        baseUrl.append( request.getContextPath() );
+
+        if ( StringUtils.isNotBlank( resource ) )
+        {
+            if ( !baseUrl.toString().endsWith( "/" ) )
+            {
+                baseUrl.append( "/" );
+            }
+
+            baseUrl.append( resource );
+        }
+
+        return baseUrl.toString();
+    }
+}
index 802f0c744bceb1d44d26a2288be8f916ed0fb130..b884efce604d263490c2e1632af8885dfb7e01ff 100644 (file)
       <role>org.apache.maven.archiva.scheduled.ArchivaTaskScheduler</role>
       <role-hint>default</role-hint>
     </component>
-    <!-- 
     <component>
-      <role>org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor</role>
+      <role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role>
       <role-hint>archiva-task-executor</role-hint>
     </component>
-      -->
   </load-on-start>
 
   <lifecycle-handler-manager implementation="org.codehaus.plexus.lifecycle.DefaultLifecycleHandlerManager">
index 8acf73d8ecad9e416f104d4c28582eae19e60f06..ced328857c27ca3941e4fa10f2532990ce8d8280 100644 (file)
       
    </tag>
 
+   <tag>
+
+      <name>copy-paste-snippet</name>
+      <tag-class>org.apache.maven.archiva.web.tags.CopyPasteSnippetTag</tag-class>
+      <body-content>empty</body-content>
+      <description><![CDATA[Render a copy paste snippet for the provided object]]></description>
+
+      <attribute>
+        <name>object</name>
+        <required>true</required>
+        <rtexprvalue>true</rtexprvalue>
+        
+        <description><![CDATA[The Object to Render]]></description>
+      </attribute>
+      
+   </tag>
+   
    
 </taglib>
\ No newline at end of file
index 89ee23fb5f2f22789823d674fa2e94f73a0dcc20..40fb48983cf0d0bcf6950d0c49403e4ffea679cf 100644 (file)
@@ -15,7 +15,7 @@
   <appender name="console" class="org.apache.log4j.ConsoleAppender">
     <param name="Target" value="System.out"/>
     <layout class="org.apache.log4j.PatternLayout">
-      <param name="ConversionPattern" value="%d [%t] %-5p %c{1} - %m%n"/>
+      <param name="ConversionPattern" value="%d [%t] %-5p %c %x - %m%n"/>
     </layout>
   </appender>
 
     <level value="info"/>
   </logger>
 
+  <logger name="org.apache.maven.archiva">
+    <level value="debug" />
+  </logger>
+
   <logger name="org.codehaus.plexus.security">
     <level value="info"/>
   </logger>
 
   <!-- squelch noisy objects (for now) -->
+  <logger name="org.apache.commons">
+    <level value="warn"/>
+  </logger>
+
+  <logger name="net.sf.ehcache">
+    <level value="warn"/>
+  </logger>
+
   <logger name="org.codehaus.plexus.mailsender.MailSender">
     <level value="info"/>
   </logger>
 
+  <logger name="org.codehaus.plexus.velocity">
+    <level value="error"/>
+  </logger>
+
   <logger name="org.quartz">
     <level value="info"/>
   </logger>
@@ -78,7 +94,7 @@
   </logger>
 
   <root>
-    <priority value ="warn" />
+    <priority value ="info" />
     <appender-ref ref="console" />
     <appender-ref ref="rolling" />
   </root>
index 8209ea80012cc2a740de344fc453f709701a48d9..b533349093410c29015a6df372d5cfcb2d95db70 100644 (file)
@@ -22,4 +22,6 @@ webwork.mapper.class = org.apache.maven.archiva.web.mapper.RepositoryActionMappe
 webwork.objectFactory = org.codehaus.plexus.xwork.PlexusObjectFactory
 webwork.url.includeParams = none
 
+webwork.devMode = true
+
 # TODO: package up a theme and share with Continuum. Should contain everything from xhtml, and set templateDir to WEB-INF/themes
index 9f19eedb664ab2ccc38fbac3becfe34545708323..9ca85a62bd51b11119342e45364de0bd744297d2 100644 (file)
 
   <package name="base" extends="webwork-default">
     <interceptors>
+      <interceptor name="strange" class="webwork-is-doing-strange-things"/>
       <interceptor name="configuration" class="configurationInterceptor"/>
       <interceptor name="pssForceAdminUser" class="pssForceAdminUserInterceptor"/>
       <interceptor name="pssSecureActions" class="pssSecureActionInterceptor"/>
       <interceptor name="pssAutoLogin" class="pssAutoLoginInterceptor"/>
-      <interceptor name="pssEnvironmentChecker" class="pssEnvironmentCheckInterceptor"/>
       <interceptor name="pssPolicyEnforcement" class="pssPolicyEnforcementInterceptor"/>
 
-      <interceptor-stack name="unconfiguredStack">
-        <interceptor-ref name="defaultStack"/>
-        <interceptor-ref name="pssEnvironmentChecker"/>
+      <interceptor-stack name="configuredArchivaStack">
         <interceptor-ref name="pssForceAdminUser"/>
         <interceptor-ref name="pssAutoLogin"/>
-        <interceptor-ref name="pssPolicyEnforcement"/>
+        <interceptor-ref name="defaultStack"/>
         <interceptor-ref name="pssSecureActions"/>
+        <interceptor-ref name="pssPolicyEnforcement"/>
+        <interceptor-ref name="configuration"/>
+        <interceptor-ref name="validation">
+          <param name="excludeMethods">input,back,cancel,browse</param>
+        </interceptor-ref>
+        <interceptor-ref name="workflow">
+          <param name="excludeMethods">input,back,cancel,browse</param>
+        </interceptor-ref>
       </interceptor-stack>
 
-      <interceptor-stack name="configuredStack">
-        <interceptor-ref name="defaultStack"/>
-        <interceptor-ref name="pssEnvironmentChecker"/>
+      <interceptor-stack name="unconfiguredArchivaStack">
         <interceptor-ref name="pssForceAdminUser"/>
         <interceptor-ref name="pssAutoLogin"/>
+        <interceptor-ref name="defaultStack"/>
         <interceptor-ref name="pssPolicyEnforcement"/>
         <interceptor-ref name="pssSecureActions"/>
-        <interceptor-ref name="configuration"/>
+        <interceptor-ref name="validation">
+          <param name="excludeMethods">input,back,cancel,browse</param>
+        </interceptor-ref>
+        <interceptor-ref name="workflow">
+          <param name="excludeMethods">input,back,cancel,browse</param>
+        </interceptor-ref>
       </interceptor-stack>
 
       <interceptor-stack name="configuredPrepareParamsStack">
-        <interceptor-ref name="paramsPrepareParamsStack"/>
-        <interceptor-ref name="configuredStack"/>
+        <!-- <interceptor-ref name="prepare" /> -->
+        <interceptor-ref name="params" />
+        <interceptor-ref name="configuredArchivaStack"/>
       </interceptor-stack>
+
     </interceptors>
 
     <!-- Default interceptor stack. -->
-    <default-interceptor-ref name="configuredStack"/>
+    <default-interceptor-ref name="configuredArchivaStack"/>
 
     <global-results>
       <!-- TODO: want an extra message on the configure page when this first happens! -->
     <action name="repositories" class="repositoriesAction" method="input">
       <result name="input">/WEB-INF/jsp/admin/repositories.jsp</result>
     </action>
+    
+    <action name="indexRepository" class="indexRepositoryAction" method="run">
+      <result type="redirect-action">repositories</result>
+    </action>
 
     <action name="addRepository" class="configureRepositoryAction" method="add">
       <result name="input">/WEB-INF/jsp/admin/addRepository.jsp</result>
-      <result type="redirect-action">managedRepositories</result>
-      <interceptor-ref name="unconfiguredStack"/>
+      <result type="redirect-action">repositories</result>
+      <!-- <interceptor-ref name="unconfiguredArchivaStack"/> -->
     </action>
 
-    <action name="editRepository" class="configureRepositoryAction" method="edit">
+    <action name="editRepository" class="editRepositoryAction" method="edit">
       <result name="input">/WEB-INF/jsp/admin/editRepository.jsp</result>
-      <result type="redirect-action">managedRepositories</result>
+      <result name="error" type="redirect-action">repositories</result>
+      <result name="success" type="redirect-action">repositories</result>
       <interceptor-ref name="configuredPrepareParamsStack"/>
     </action>
+    
+    <action name="saveRepository" class="saveRepositoryAction" method="save">
+      <result name="success" type="redirect-action">repositories</result>
+    </action>
 
     <action name="deleteRepository" class="deleteRepositoryAction">
       <result name="input">/WEB-INF/jsp/admin/deleteRepository.jsp</result>
-      <result type="redirect-action">managedRepositories</result>
+      <result type="redirect-action">repositories</result>
     </action>
 
     <action name="configure" class="configureAction" method="input">
       <result name="input">/WEB-INF/jsp/admin/configure.jsp</result>
-      <interceptor-ref name="unconfiguredStack"/>
+      <interceptor-ref name="unconfiguredArchivaStack"/>
     </action>
 
     <action name="saveConfiguration" class="configureAction">
       <result name="input">/WEB-INF/jsp/admin/configure.jsp</result>
       <result>/WEB-INF/jsp/admin/index.jsp</result>
-      <interceptor-ref name="unconfiguredStack"/>
+      <interceptor-ref name="unconfiguredArchivaStack"/>
     </action>
 
     <action name="reports" class="reportsAction">
     </action>
 
     <action name="runReport" class="reportsAction" method="runReport">
-      <interceptor-ref name="configuredStack"/>
+      <interceptor-ref name="configuredArchivaStack"/>
       <interceptor-ref name="execAndWait"/>
       <result name="wait" type="redirect">/admin/reports.action?reportGroup=${reportGroup}&amp;repositoryId=${repositoryId}&amp;filter=${filter}</result>
       <result name="success" type="redirect">/admin/reports.action?reportGroup=${reportGroup}&amp;repositoryId=${repositoryId}&amp;filter=${filter}</result>
diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addProxiedRepository.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addProxiedRepository.jsp
deleted file mode 100644 (file)
index 4add78e..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<%--
-  ~ 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.
-  --%>
-
-<%@ taglib prefix="ww" uri="/webwork" %>
-
-<html>
-<head>
-  <title>Configuration</title>
-  <ww:head/>
-</head>
-
-<body>
-
-<h1>Configuration</h1>
-
-<div id="contentArea">
-
-  <h2>Add Proxied Repository</h2>
-
-  <%@ include file="errorMessages.jsp" %>
-
-  <ww:actionmessage/>
-  <ww:form method="post" action="addProxiedRepository" namespace="/admin" validate="true">
-    <ww:textfield name="id" label="Identifier" size="10"/>
-    <%@ include file="/WEB-INF/jsp/admin/include/proxiedRepositoryForm.jspf" %>
-
-    <ww:submit value="Add Repository"/>
-  </ww:form>
-
-  <script type="text/javascript">
-    document.getElementById("addProxiedRepository_id").focus();
-  </script>
-
-</div>
-
-</body>
-</html>
index ad97aa4563e0e9591f4900b85029292fd71d5341..6d4502a3d365d0a45245b30b22aa1ca43310d626 100644 (file)
@@ -35,9 +35,8 @@
 
   <ww:actionmessage/>
   <ww:form method="post" action="addRepository" namespace="/admin" validate="true">
-    <ww:textfield name="id" label="Identifier" size="10" required="true"/>
+    <ww:textfield name="model.id" label="Identifier" size="10" required="true"/>
     <%@ include file="/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf" %>
-    <ww:checkbox name="indexed" fieldValue="true" value="true" label="Indexed"/>
     <ww:submit value="Add Repository"/>
   </ww:form>
 
diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addSyncedRepository.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addSyncedRepository.jsp
deleted file mode 100644 (file)
index 52d4fbf..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<%--
-  ~ 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.
-  --%>
-
-<%@ taglib prefix="ww" uri="/webwork" %>
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
-
-<html>
-<head>
-  <title>Configuration</title>
-  <ww:head/>
-</head>
-
-<body>
-
-<h1>Configuration</h1>
-
-<div id="contentArea">
-
-  <h2>Add Synced Repository</h2>
-
-  <%@ include file="errorMessages.jsp" %>
-
-  <ww:actionmessage/>
-  <ww:form method="post" action="addSelectedSyncedRepository" namespace="/admin" validate="true">
-    <ww:textfield name="id" label="Identifier" size="10" required="true"/>
-    <%@ include file="/WEB-INF/jsp/admin/include/syncedRepositoryForm.jspf" %>
-
-    <ww:submit value="Add Repository"/>
-  </ww:form>
-
-  <script type="text/javascript">
-    document.getElementById("addSelectedSyncedRepository_id").focus();
-  </script>
-
-</div>
-
-</body>
-</html>
diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteProxiedRepository.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteProxiedRepository.jsp
deleted file mode 100644 (file)
index b293cca..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<%--
-  ~ 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.
-  --%>
-
-<%@ taglib prefix="ww" uri="/webwork" %>
-
-<html>
-<head>
-  <title>Configuration</title>
-  <ww:head/>
-</head>
-
-<body>
-
-<h1>Configuration</h1>
-
-<div id="contentArea">
-
-  <h2>Delete Proxied Repository</h2>
-
-  <blockquote>
-    <strong><span class="statusFailed">WARNING:</span> This operation can not be undone.</strong>
-  </blockquote>
-
-  <ww:form method="post" action="deleteProxiedRepository" namespace="/admin" validate="true">
-    <ww:hidden name="repoId"/>
-    <ww:radio list="#@java.util.LinkedHashMap@{
-    'delete-contents' : 'Remove the repository and delete its contents from managed repositories',
-    'delete-entry' : 'Remove the repository from the available list, but leave the contents in the managed repositories',
-    'unmodified' : 'Leave the repository unmodified'}" name="operation" theme="archiva"/>
-    <ww:submit value="Go"/>
-  </ww:form>
-</div>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteSyncedRepository.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteSyncedRepository.jsp
deleted file mode 100644 (file)
index d208726..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<%--
-  ~ 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.
-  --%>
-
-<%@ taglib prefix="ww" uri="/webwork" %>
-
-<html>
-<head>
-  <title>Configuration</title>
-  <ww:head/>
-</head>
-
-<body>
-
-<h1>Configuration</h1>
-
-<div id="contentArea">
-
-  <h2>Delete Synced Repository</h2>
-
-  <blockquote>
-    <strong><span class="statusFailed">WARNING:</span> This operation can not be undone.</strong>
-  </blockquote>
-
-  <ww:form method="post" action="deleteSyncedRepository" namespace="/admin" validate="true">
-    <ww:hidden name="repoId"/>
-    <ww:radio list="#@java.util.LinkedHashMap@{
-    'delete-contents' : 'Remove the repository and delete its contents from managed repositories',
-    'delete-entry' : 'Remove the repository from the available list, but leave the contents in the managed repositories',
-    'unmodified' : 'Leave the repository unmodified'}" name="operation" theme="archiva"/>
-    <ww:submit value="Go"/>
-  </ww:form>
-</div>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editProxiedRepository.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editProxiedRepository.jsp
deleted file mode 100644 (file)
index 7d00338..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-<%--
-  ~ 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.
-  --%>
-
-<%@ taglib prefix="ww" uri="/webwork" %>
-
-<html>
-<head>
-  <title>Configuration</title>
-  <ww:head/>
-</head>
-
-<body>
-
-<h1>Configuration</h1>
-
-<div id="contentArea">
-
-  <h2>Edit Proxied Repository</h2>
-
-  <%@ include file="errorMessages.jsp" %>
-
-  <ww:actionmessage/>
-  <ww:form method="post" action="editProxiedRepository" namespace="/admin" validate="true">
-    <ww:hidden name="id"/>
-    <%@ include file="/WEB-INF/jsp/admin/include/proxiedRepositoryForm.jspf" %>
-    <ww:submit value="Update Repository"/>
-  </ww:form>
-
-  <script type="text/javascript">
-    document.getElementById("editProxiedRepository_name").focus();
-  </script>
-
-</div>
-
-</body>
-</html>
index aa072a67d744f4dec5249446a99afdca1fd25dd5..929246fd682632487c628ddddcc3867062569cea 100644 (file)
   <h2>Edit Managed Repository</h2>
 
   <ww:actionmessage/>
-  <ww:form method="post" action="editRepository" namespace="/admin" validate="true">
+  <ww:form method="post" action="saveRepository" namespace="/admin" validate="false">
+    <ww:hidden name="mode"/>  
     <ww:hidden name="id"/>
     <%@ include file="/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf" %>
-    <ww:checkbox name="indexed" fieldValue="true" label="Indexed"/>
     <ww:submit value="Update Repository"/>
   </ww:form>
 
diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editSyncedRepository.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editSyncedRepository.jsp
deleted file mode 100644 (file)
index 186586b..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<%--
-  ~ 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.
-  --%>
-
-<%@ taglib prefix="ww" uri="/webwork" %>
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
-
-<html>
-<head>
-  <title>Configuration</title>
-  <ww:head/>
-</head>
-
-<body>
-
-<h1>Configuration</h1>
-
-<div id="contentArea">
-
-  <h2>Edit Synced Repository</h2>
-
-  <%@ include file="errorMessages.jsp" %>
-
-  <ww:actionmessage/>
-  <ww:form method="post" action="editSyncedRepository" namespace="/admin" validate="true">
-    <ww:hidden name="id"/>
-    <%@ include file="/WEB-INF/jsp/admin/include/syncedRepositoryForm.jspf" %>
-
-    <ww:submit value="Update Repository"/>
-  </ww:form>
-
-  <script type="text/javascript">
-    document.getElementById("editSyncedRepository_name").focus();
-  </script>
-
-</div>
-
-</body>
-</html>
index 9158c510325f7ce4e8e6c831796251ef1941a93e..f8907b6caa38a582a53d21c9752236d11fbad5f2 100644 (file)
 <%@ taglib prefix="ww" uri="/webwork" %>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 
-<c:set var="urlbase">${pageContext.request.scheme}://${pageContext.request.serverName}
-  :${pageContext.request.serverPort}${pageContext.request.contextPath}/repository/
-</c:set>
-
-<tr>
-  <td>
-    <ww:label for="urlName" theme="simple">URL Name*:</ww:label>
-  </td>
-  <td>
-    <c:out value="${urlbase}"/>
-    <ww:textfield name="urlName" id="urlName" size="20" theme="simple" required="true"/>
-  </td>
-</tr>
-
 <ww:textfield name="name" label="Name" size="50" required="true"/>
 <ww:textfield name="directory" label="Directory" size="100" required="true"/>
 <ww:select list="#@java.util.LinkedHashMap@{'default' : 'Maven 2.x Repository', 'legacy' : 'Maven 1.x Repository'}"
            name="layout" label="Type"/>
-<ww:checkbox name="includeSnapshots" fieldValue="true" label="Snapshots Included"/>
+<ww:textfield name="refreshCronExpression" label="Cron" size="100" required="true" />
+<ww:checkbox name="releases" fieldValue="true" label="Releases Included"/>
+<ww:checkbox name="snapshots" fieldValue="false" label="Snapshots Included"/>
+<ww:checkbox name="indexed" fieldValue="true" label="Indexed"/>
diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/managedRepositories.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/managedRepositories.jsp
deleted file mode 100644 (file)
index ec4c59c..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-<%--
-  ~ 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.
-  --%>
-
-<%@ taglib prefix="ww" uri="/webwork" %>
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
-<%@ taglib prefix="pss" uri="/plexusSecuritySystem" %>
-
-<html>
-<head>
-  <title>Administration</title>
-  <ww:head/>
-</head>
-
-<body>
-
-<h1>Administration</h1>
-
-<div id="contentArea">
-
-<%-- DO NOT REFORMAT THIS LINE --%>
-<c:set var="urlbase">${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/repository/</c:set>
-
-<div>
-  <div style="float: right">
-    <%-- TODO replace with icons --%>
-    <pss:ifAuthorized permission="archiva-manage-configuration">
-      <ww:url id="addRepositoryUrl" action="addRepository" method="input"/>
-      <ww:a href="%{addRepositoryUrl}">Add Repository</ww:a>
-    </pss:ifAuthorized>
-  </div>
-  <h2>Managed Repositories</h2>
-</div>
-
-<ww:set name="repositories" value="repositories"/>
-<c:if test="${empty(repositories)}">
-  <strong>There are no managed repositories configured yet.</strong>
-</c:if>
-<c:forEach items="${repositories}" var="repository" varStatus="i">
-  
-    <div>
-      <div style="float: right">
-      <pss:ifAnyAuthorized permissions="archiva-manage-configuration">
-        <ww:url id="editRepositoryUrl" action="editRepository" method="input">
-          <ww:param name="repoId" value="%{'${repository.id}'}"/>
-        </ww:url>
-        <ww:url id="deleteRepositoryUrl" action="deleteRepository" method="input">
-          <ww:param name="repoId" value="%{'${repository.id}'}"/>
-        </ww:url>
-          <%-- TODO replace with icons --%>
-        <ww:a href="%{editRepositoryUrl}">Edit Repository</ww:a>
-        <ww:a href="%{deleteRepositoryUrl}">Delete Repository</ww:a>
-        </pss:ifAnyAuthorized>
-      </div>
-      <h3>${repository.name}</h3>
-      <table class="infoTable">
-        <tr>
-          <th>Identifier</th>
-          <td>
-            <code>${repository.id}</code>
-          </td>
-        </tr>
-        <tr>
-          <th>Directory</th>
-          <td>${repository.directory}</td>
-        </tr>
-        <tr>
-          <th>WebDAV URL</th>
-          <td><a href="${urlbase}${repository.urlName}/">${urlbase}${repository.urlName}/</a></td>
-        </tr>
-        <tr>
-          <th>Type</th>
-            <%-- TODO: can probably just use layout appended to a key prefix in i18n to simplify this --%>
-          <td>
-            <c:choose>
-              <c:when test="${repository.layout == 'default'}">
-                Maven 2.x Repository
-              </c:when>
-              <c:otherwise>
-                Maven 1.x Repository
-              </c:otherwise>
-            </c:choose>
-          </td>
-        </tr>
-        <tr>
-          <th>Snapshots Included</th>
-          <td class="${repository.includeSnapshots ? 'donemark' : 'errormark'} booleanIcon"> ${repository.includeSnapshots}</td>
-        </tr>
-        <tr>
-          <th>Indexed</th>
-          <td class="${repository.indexed ? 'donemark' : 'errormark'} booleanIcon"> ${repository.indexed}</td>
-        </tr>
-        <tr>
-          <th>POM Snippet</th>
-          <td><a href="#" onclick="Effect.toggle('repoPom${repository.id}','slide'); return false;">Show POM Snippet</a><br/>
-              <%-- DO NOT REFORMAT THIS SECTION --%>
-<pre class="pom" style="display: none;" id="repoPom${repository.id}"><code>&lt;project>
-  ...
-  &lt;distributionManagement>
-  &lt;${repository.includeSnapshots ? 'snapshotRepository' : 'repository'}>
-  &lt;id>${repository.id}&lt;/id>
-  &lt;url>dav:${urlbase}${repository.urlName}&lt;/url>
-  <c:if test="${repository.layout != 'default'}">
-    &lt;layout>${repository.layout}&lt;/layout>
-  </c:if>
-  &lt;/${repository.includeSnapshots ? 'snapshotRepository' : 'repository'}>
-  &lt;/distributionManagement>
-
-  &lt;repositories>
-  &lt;repository>
-  &lt;id>${repository.id}&lt;/id>
-  &lt;name>${repository.name}&lt;/name>
-  &lt;url>${urlbase}${repository.urlName}/&lt;/url>
-  <c:if test="${repository.layout != 'default'}">
-    &lt;layout>${repository.layout}&lt;/layout>
-  </c:if>
-  &lt;releases>
-  &lt;enabled>${repository.includeSnapshots ? 'false' : 'true'}&lt;/enabled>
-  &lt;/releases>
-  &lt;snapshots>
-  &lt;enabled>${repository.includeSnapshots ? 'true' : 'false'}&lt;/enabled>
-  &lt;/snapshots>
-  &lt;/repository>
-  &lt;/repositories>
-  ...
-  &lt;/project>
-</code></pre>
-          </td>
-        </tr>
-      </table>
-    </div>
-</c:forEach>
-</div>
-
-</body>
-</html>
diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxiedRepositories.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxiedRepositories.jsp
deleted file mode 100644 (file)
index de64798..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-<%--
-  ~ 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.
-  --%>
-
-<%@ taglib prefix="ww" uri="/webwork" %>
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
-<%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>
-<%@ taglib prefix="pss" uri="/plexusSecuritySystem" %>
-
-<html>
-<head>
-  <title>Administration</title>
-  <ww:head/>
-</head>
-
-<body>
-
-<h1>Administration</h1>
-
-<div id="contentArea">
-  <div>
-   
-    <%-- TODO replace with icons --%>
-    <div style="float: right">
-      <pss:ifAuthorized permission="archiva-manage-configuration">
-        <a href="<ww:url action="addProxiedRepository" method="input" />">Add Repository</a>
-      </pss:ifAuthorized>
-    </div>
-    
-    <h2>Proxied Repositories</h2>
-  </div>
-
-  <ww:set name="proxiedRepositories" value="proxiedRepositories"/>
-  <c:if test="${empty(proxiedRepositories)}">
-    <strong>There are no proxied repositories configured yet.</strong>
-  </c:if>
-  <c:forEach items="${proxiedRepositories}" var="repository" varStatus="i">
-    <div>
-      <div style="float: right">
-          <%-- TODO replace with icons --%>
-        <pss:ifAuthorized permission="archiva-manage-configuration">
-          <a href="<ww:url action="editProxiedRepository" method="input"><ww:param name="repoId" value="%{'${repository.id}'}" /></ww:url>">Edit
-          Repository</a> | <a
-          href="<ww:url action="deleteProxiedRepository" method="input"><ww:param name="repoId" value="%{'${repository.id}'}" /></ww:url>">Delete
-          Repository</a>
-        </pss:ifAuthorized>
-      </div>
-      <h3>${repository.name}</h3>
-      <table class="infoTable">
-        <tr>
-          <th>Identifier</th>
-          <td>
-            <code>${repository.id}</code>
-          </td>
-        </tr>
-        <tr>
-          <th>URL</th>
-          <td><a href="${repository.url}">${repository.url}</a></td>
-        </tr>
-        <tr>
-          <th>Type</th>
-            <%-- TODO: can probably just use layout appended to a key prefix in i18n to simplify this --%>
-          <td>
-            <c:choose>
-              <c:when test="${repository.layout == 'default'}">
-                Maven 2.x Repository
-              </c:when>
-              <c:otherwise>
-                Maven 1.x Repository
-              </c:otherwise>
-            </c:choose>
-          </td>
-        </tr>
-        <tr>
-          <th>Snapshots</th>
-          <td>
-            <my:displayUpdatePolicy policy="${repository.snapshotsPolicy}" interval="${repository.snapshotsInterval}"/>
-          </td>
-        </tr>
-        <tr>
-          <th>Releases</th>
-          <td>
-            <my:displayUpdatePolicy policy="${repository.releasesPolicy}" interval="${repository.releasesInterval}"/>
-          </td>
-        </tr>
-        <tr>
-          <th>Proxied through</th>
-          <td>
-              <%-- TODO: this is the hard way! would be nice if there was a ref in the model so it was directly linked --%>
-              ${repositoriesMap[repository.managedRepository].name}
-            (<code>${repositoriesMap[repository.managedRepository].id}</code>)
-          </td>
-        </tr>
-        <tr>
-          <th>Use HTTP Proxy</th>
-          <td class="${repository.useNetworkProxy ? 'donemark' : 'errormark'} booleanIcon"></td>
-        </tr>
-        <tr>
-          <th>Cache Failures</th>
-          <td class="${repository.cacheFailures ? 'donemark' : 'errormark'} booleanIcon"></td>
-        </tr>
-        <tr>
-          <th>Fail Whole Group</th>
-          <td class="${repository.hardFail ? 'donemark' : 'errormark'} booleanIcon"></td>
-        </tr>
-      </table>
-    </div>
-  </c:forEach>
-</div>
-
-</body>
-</html>
\ No newline at end of file
index 32f4d935743247d27c7b71ac261135637fd2df56..e0a92ae75ae30688878c55b74a13fd2781cef7d2 100644 (file)
@@ -20,6 +20,7 @@
 <%@ taglib prefix="ww" uri="/webwork" %>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <%@ taglib prefix="pss" uri="/plexusSecuritySystem" %>
+<%@ taglib prefix="archiva" uri="http://maven.apache.org/archiva" %>
 
 <html>
 <head>
 
 <div id="contentArea">
 
+<ww:actionerror />
+<ww:actionmessage />
+
 <div>
   <div style="float: right">
     <%-- TODO replace with icons --%>
     <pss:ifAuthorized permission="archiva-manage-configuration">
-      <ww:url id="addRepositoryUrl" action="addRepository" method="input"/>
+      <ww:url id="addRepositoryUrl" action="addRepository"/>
       <ww:a href="%{addRepositoryUrl}">Add Repository</ww:a>
     </pss:ifAuthorized>
   </div>
   <h2>Managed Repositories</h2>
 </div>
 
-<ww:set name="repositories" value="model.repositories"/>
-<c:if test="${empty(repositories)}">
-  <strong>There are no managed repositories configured yet.</strong>
-</c:if>
-
-<%--
-<c:forEach items="${repositories}" var="repository" varStatus="i">
+<c:choose>
+  <c:when test="${empty(model.managedRepositories)}">
+    <%-- No Managed Repositories. --%>
+    <strong>There are no managed repositories configured yet.</strong>
+  </c:when>
+  <c:otherwise>
+    <%-- Display the repositories. --%>
+    
+       <c:forEach items="${model.managedRepositories}" var="repository" varStatus="i">
   
-    <div>
-      <div style="float: right">
-      <pss:ifAnyAuthorized permissions="archiva-manage-configuration">
-        <ww:url id="editRepositoryUrl" action="editRepository" method="input">
-          <ww:param name="repoId" value="%{'${repository.id}'}"/>
-        </ww:url>
-        <ww:url id="deleteRepositoryUrl" action="deleteRepository" method="input">
-          <ww:param name="repoId" value="%{'${repository.id}'}"/>
-        </ww:url>
-        <ww:a href="%{editRepositoryUrl}">Edit Repository</ww:a>
-        <ww:a href="%{deleteRepositoryUrl}">Delete Repository</ww:a>
-        </pss:ifAnyAuthorized>
+      <div>
+
+        <div style="float: right">
+          <%-- TODO: make some icons --%>
+          <pss:ifAnyAuthorized permissions="archiva-manage-configuration">
+            <ww:url id="editRepositoryUrl" action="editRepository">
+              <ww:param name="repoid" value="%{'${repository.id}'}" />
+            </ww:url>
+            <ww:url id="deleteRepositoryUrl" action="deleteRepository" method="confirm">
+              <ww:param name="repoid" value="%{'${repository.id}'}" />
+            </ww:url>
+            <ww:a href="%{editRepositoryUrl}">Edit Repository</ww:a>
+            <ww:a href="%{deleteRepositoryUrl}">Delete Repository</ww:a>
+          </pss:ifAnyAuthorized>
+        </div>
+        
+        <h3>${repository.name}</h3>
+        
+        <table class="infoTable">
+          <tr>
+            <th>Identifier</th>
+            <td>
+              <code>${repository.id}</code>
+            </td>
+          </tr>
+          <tr>
+            <th>Directory</th>
+            <td>${repository.directory} 
+            <c:if test="${not(repository.directoryExists)}">
+              <span class="missing">Directory Does Not Exist</span>
+            </c:if>
+            </td>
+          </tr>
+          <tr>
+            <th>WebDAV URL</th>
+            <td><a href="${model.baseUrl}/${repository.id}/">${model.baseUrl}/${repository.id}/</a></td>
+          </tr>
+          <tr>
+            <th>Type</th>
+              <%-- TODO: can probably just use layout appended to a key prefix in i18n to simplify this --%>
+            <td>
+              <c:choose>
+                <c:when test="${repository.layout == 'default'}">
+                  Maven 2.x Repository
+                </c:when>
+                <c:otherwise>
+                  Maven 1.x Repository
+                </c:otherwise>
+              </c:choose>
+            </td>
+          </tr>
+          <tr>
+            <th>Releases Included</th>
+            <td class="${repository.releases ? 'donemark' : 'errormark'} booleanIcon"> ${repository.releases}</td>
+          </tr>
+          <tr>
+            <th>Snapshots Included</th>
+            <td class="${repository.snapshots ? 'donemark' : 'errormark'} booleanIcon"> ${repository.snapshots}</td>
+          </tr>
+          <tr>
+            <th>Indexed</th>
+            <td class="${repository.indexed ? 'donemark' : 'errormark'} booleanIcon"> ${repository.indexed}</td>
+          </tr>
+          <c:if test="${repository.indexed}">
+            <tr>
+              <th>Indexing Cron</th>
+              <td>${repository.refreshCronExpression}</td>
+            </tr>
+            <tr>
+              <th>Stats</th>
+              <td>
+                <div style="float: right">
+                  <pss:ifAuthorized permission="archiva-run-indexer">
+                    <ww:url id="indexRepositoryUrl" action="indexRepository">
+                      <ww:param name="repoid" value="%{'${repository.id}'}" />
+                    </ww:url>
+                    <ww:a href="%{indexRepositoryUrl}">Index Repository</ww:a>
+                  </pss:ifAuthorized>
+                </div>
+                <c:choose>
+                  <c:when test="${empty(repository.stats)}">
+                    Never indexed.
+                  </c:when>
+                  <c:otherwise>
+                    <table>
+                      <tr>
+                        <th>Last Indexed</th>
+                        <td>${repository.stats.whenStarted}</td>
+                      </tr>
+                      <tr>
+                        <th>Duration</th>
+                        <td>${repository.stats.duration} ms</td>
+                      </tr>
+                      <tr>
+                        <th>Total File Count</th>
+                        <td>${repository.stats.totalFileCount}
+                      </tr>
+                      <tr>
+                        <th>New Files Found</th>
+                        <td>${repository.stats.newFileCount}
+                      </tr>
+                    </table>
+                  </c:otherwise>
+                </c:choose>
+              </td>
+            </tr>
+          </c:if>
+          <tr>
+            <th>POM Snippet</th>
+            <td><a href="#" onclick="Effect.toggle('repoPom${repository.id}','slide'); return false;">Show POM Snippet</a><br/>
+<pre class="pom" style="display: none;" id="repoPom${repository.id}"><code><archiva:copy-paste-snippet object="${repository}" /></code></pre>
+            </td>
+          </tr>
+        </table>
+      
       </div>
-      <h3>${repository.name}</h3>
-      <table class="infoTable">
-        <tr>
-          <th>Identifier</th>
-          <td>
-            <code>${repository.id}</code>
-          </td>
-        </tr>
-        <tr>
-          <th>Directory</th>
-          <td>${repository.directory}</td>
-        </tr>
-        <tr>
-          <th>WebDAV URL</th>
-          <td><a href="${urlbase}${repository.urlName}/">${urlbase}${repository.urlName}/</a></td>
-        </tr>
-        <tr>
-          <th>Type</th>
-            <% - - TODO: can probably just use layout appended to a key prefix in i18n to simplify this - - %>
-          <td>
-            <c:choose>
-              <c:when test="${repository.layout == 'default'}">
-                Maven 2.x Repository
-              </c:when>
-              <c:otherwise>
-                Maven 1.x Repository
-              </c:otherwise>
-            </c:choose>
-          </td>
-        </tr>
-        <tr>
-          <th>Snapshots Included</th>
-          <td class="${repository.includeSnapshots ? 'donemark' : 'errormark'} booleanIcon"> ${repository.includeSnapshots}</td>
-        </tr>
-        <tr>
-          <th>Indexed</th>
-          <td class="${repository.indexed ? 'donemark' : 'errormark'} booleanIcon"> ${repository.indexed}</td>
-        </tr>
-        <tr>
-          <th>POM Snippet</th>
-          <td><a href="#" onclick="Effect.toggle('repoPom${repository.id}','slide'); return false;">Show POM Snippet</a><br/>
-              <% - - DO NOT REFORMAT THIS SECTION - - %>
-<pre class="pom" style="display: none;" id="repoPom${repository.id}"><code>&lt;project>
-  ...
-  &lt;distributionManagement>
-  &lt;${repository.includeSnapshots ? 'snapshotRepository' : 'repository'}>
-  &lt;id>${repository.id}&lt;/id>
-  &lt;url>dav:${urlbase}${repository.urlName}&lt;/url>
-  <c:if test="${repository.layout != 'default'}">
-    &lt;layout>${repository.layout}&lt;/layout>
-  </c:if>
-  &lt;/${repository.includeSnapshots ? 'snapshotRepository' : 'repository'}>
-  &lt;/distributionManagement>
+       </c:forEach>
+       
+  </c:otherwise>
+</c:choose>
 
-  &lt;repositories>
-  &lt;repository>
-  &lt;id>${repository.id}&lt;/id>
-  &lt;name>${repository.name}&lt;/name>
-  &lt;url>${urlbase}${repository.urlName}/&lt;/url>
-  <c:if test="${repository.layout != 'default'}">
-    &lt;layout>${repository.layout}&lt;/layout>
-  </c:if>
-  &lt;releases>
-  &lt;enabled>${repository.includeSnapshots ? 'false' : 'true'}&lt;/enabled>
-  &lt;/releases>
-  &lt;snapshots>
-  &lt;enabled>${repository.includeSnapshots ? 'true' : 'false'}&lt;/enabled>
-  &lt;/snapshots>
-  &lt;/repository>
-  &lt;/repositories>
-  ...
-  &lt;/project>
-</code></pre>
-          </td>
-        </tr>
-      </table>
-    </div>
-</c:forEach>
-  --%>
 </div>
 
 </body>
diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/selectSyncedRepository.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/selectSyncedRepository.jsp
deleted file mode 100644 (file)
index 3a5b264..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<%--
-  ~ 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.
-  --%>
-
-<%@ taglib prefix="ww" uri="/webwork" %>
-
-<html>
-<head>
-  <title>Configuration</title>
-  <ww:head/>
-</head>
-
-<body>
-
-<h1>Configuration</h1>
-
-<div id="contentArea">
-
-  <h2>Add Synced Repository</h2>
-
-  <ww:actionmessage/>
-  <ww:form method="post" action="addSyncedRepository" namespace="/admin" validate="true">
-    <ww:select list="#@java.util.LinkedHashMap@{
-      'rsync' : 'Rsync', 
-      'svn' : 'Subversion',
-      'cvs' : 'CVS',
-      'file': 'Local File System'}" name="method" label="Method"/>
-
-    <ww:submit value="Continue"/>
-  </ww:form>
-</div>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/syncedRepositories.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/syncedRepositories.jsp
deleted file mode 100644 (file)
index d173f37..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-<%--
-  ~ 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.
-  --%>
-
-<%@ taglib prefix="ww" uri="/webwork" %>
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
-
-<html>
-<head>
-  <title>Administration</title>
-  <ww:head/>
-</head>
-
-<body>
-
-<h1>Administration</h1>
-
-<div id="contentArea">
-<div>
-  <%-- TODO replace with icons --%>
-  <div style="float: right">
-    <a href="<ww:url action="addSyncedRepository" method="input" />">Add Repository</a>
-  </div>
-  <h2>Synced Repositories</h2>
-</div>
-
-<ww:set name="syncedRepositories" value="syncedRepositories"/>
-<c:if test="${empty(syncedRepositories)}">
-  <strong>There are no synced repositories configured yet.</strong>
-</c:if>
-<c:forEach items="${syncedRepositories}" var="repository" varStatus="i">
-  <div>
-    <div style="float: right">
-        <%-- TODO replace with icons --%>
-      <a href="<ww:url action="editSyncedRepository" method="input"><ww:param name="repoId" value="%{'${repository.id}'}" /></ww:url>">Edit
-        Repository</a> | <a
-        href="<ww:url action="deleteSyncedRepository" method="input"><ww:param name="repoId" value="%{'${repository.id}'}" /></ww:url>">Delete
-      Repository</a>
-    </div>
-    <h3>${repository.name}</h3>
-    <table class="infoTable">
-      <tr>
-        <th>Identifier</th>
-        <td>
-          <code>${repository.id}</code>
-        </td>
-      </tr>
-      <tr>
-        <th>Method</th>
-        <td>${repository.method}</td>
-      </tr>
-      <c:choose>
-        <c:when test="${repository.method == 'cvs'}">
-          <tr>
-            <th>CVS Root</th>
-            <td>${repository.properties['cvsRoot']}</td>
-          </tr>
-        </c:when>
-        <c:when test="${repository.method == 'svn'}">
-          <tr>
-            <th>Subversion URL</th>
-            <td>${repository.properties['svnUrl']}</td>
-          </tr>
-          <tr>
-            <th>Subversion Username</th>
-            <td>${repository.properties['username']}</td>
-          </tr>
-        </c:when>
-        <c:when test="${repository.method == 'rsync'}">
-          <tr>
-            <th>Rsync Host</th>
-            <td>${repository.properties['rsyncHost']}</td>
-          </tr>
-          <tr>
-            <th>Rsync Directory</th>
-            <td>${repository.properties['rsyncDirectory']}</td>
-          </tr>
-          <tr>
-            <th>Rsync Method</th>
-            <td>
-              <c:choose>
-                <c:when test="${repository.properties['rsyncMethod'] == 'rsync'}">
-                  Anonymous
-                </c:when>
-                <c:when test="${repository.properties['rsyncMethod'] == 'ssh'}">
-                  SSH
-                </c:when>
-              </c:choose>
-            </td>
-          </tr>
-          <tr>
-            <th>Username</th>
-            <td>${repository.properties['username']}</td>
-          </tr>
-        </c:when>
-        <c:when test="${repository.method == 'file'}">
-          <tr>
-            <th>Directory</th>
-            <td>${repository.properties['directory']}</td>
-          </tr>
-        </c:when>
-      </c:choose>
-      <tr>
-        <th>Type</th>
-          <%-- TODO: can probably just use layout appended to a key prefix in i18n to simplify this --%>
-        <td>
-          <c:choose>
-            <c:when test="${repository.layout == 'default'}">
-              Maven 2.x Repository
-            </c:when>
-            <c:otherwise>
-              Maven 1.x Repository
-            </c:otherwise>
-          </c:choose>
-        </td>
-      </tr>
-      <tr>
-        <th>Synced to</th>
-        <td>
-            <%-- TODO: this is the hard way! would be nice if there was a ref in the model so it was directly linked --%>
-            ${repositoriesMap[repository.managedRepository].name}
-          (<code>${repositoriesMap[repository.managedRepository].id}</code>)
-        </td>
-      </tr>
-      <tr>
-        <th>Schedule</th>
-        <td>${repository.cronExpression}</td>
-      </tr>
-    </table>
-  </div>
-</c:forEach>
-</div>
-
-</body>
-</html>
\ No newline at end of file
index 14b2d1b05e5adee868d02c925d361ee705ea9a24..848aaaf6bcb7382e8cc8d13a316521fc7f50c076 100644 (file)
@@ -38,6 +38,7 @@
     @import url( "<c:url value="/css/site.css" />" );
   </style>
   <link rel="stylesheet" href="<c:url value="/css/print.css"/>" type="text/css" media="print"/>
+  <link rel="shortcut icon" href="<c:url value="/favicon.ico" />" />
   <script type="text/javascript" src="<c:url value="/js/scriptaculous/prototype.js"/>"></script>
   <script type="text/javascript" src="<c:url value="/js/scriptaculous/scriptaculous.js"/>"></script>
   <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
             <my:currentWWUrl action="index" namespace="/admin">Settings</my:currentWWUrl>
           </li>
           <li class="none">
-            <my:currentWWUrl action="managedRepositories" namespace="/admin">Managed Repositories</my:currentWWUrl>
+            <my:currentWWUrl action="repositories" namespace="/admin">Repositories</my:currentWWUrl>
           </li>
+          <%-- 
           <li class="none">
             <my:currentWWUrl action="proxiedRepositories" namespace="/admin">Proxied Repositories</my:currentWWUrl>
           </li>
+          --%>
 
                 <%-- TODO: add back after synced repos are implemented
                           <li class="none">
index dfb3ca2d6bf43016fea6cef66b2ad50d3387b060..4241af88886919d5e24414a2225579630b308e1a 100644 (file)
 <c:set var="text">\r
   <jsp:doBody/>\r
 </c:set>\r
-<c:choose>\r
+<a href="${url}">\r
+<c:choose>
   <c:when test="${currentUrl == url}">\r
     <b>${text}</b>\r
   </c:when>\r
   <c:otherwise>\r
-    <a href="${url}">${text}</a>\r
-  </c:otherwise>\r
-</c:choose>\r
+    ${text}\r
+  </c:otherwise>
+</c:choose>
+</a>\r
index b2de4ebf3be382b6e3824eaa0ec337277f48c217..c0e7f81ebdff5356401b43ee058e4d6e7e68999d 100644 (file)
@@ -62,6 +62,8 @@
   <servlet>
     <servlet-name>RepositoryServlet</servlet-name>
     <servlet-class>org.apache.maven.archiva.web.repository.RepositoryServlet</servlet-class>
+    <!-- Loading this on startup so as to take advantage of configuration listeners -->
+    <load-on-startup>1</load-on-startup>
   </servlet>
 
   <servlet-mapping>
index ebb494a73157924deb858b6cc245027f5a463ed0..983e387b24089afd941503c3424a680fc8597052 100644 (file)
@@ -23,11 +23,26 @@ body {
 
 body, td, th, select, input, li {
     font-family: Verdana, Helvetica, Arial, sans-serif;
-    font-size: 13px;
+    font-size: 11pt;
 }
 
 select, input {
-    font-size: x-small;
+    font-size: 0.9em;
+    border: 1px solid #AAAAAA;
+}
+
+select {
+    padding-left: 3px;
+       height: 1.4em;  
+}
+
+input {
+    padding: 2px;
+}
+
+label .required {
+       color: red;
+       font-weight: bold;
 }
 
 th {
@@ -303,3 +318,13 @@ blockquote {
     border-left: 1px solid #DFDEDE;
     padding-left: 1em;
 }
+
+.missing {
+       background-color: red;
+       color: white;
+       font-weight: bold;
+       padding: 4px;
+       margin-left: 20px;
+       margin-right: 20px;
+       
+}