You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ev...@apache.org on 2007/05/11 18:22:23 UTC

svn commit: r537223 [2/2] - in /maven/continuum/trunk: ./ continuum-webapp/ continuum-webapp/src/main/java/org/apache/maven/continuum/web/xmlrpc/ continuum-webapp/src/main/resources/META-INF/plexus/ continuum-webapp/src/main/webapp/WEB-INF/ continuum-x...

Added: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java?view=auto&rev=537223
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java (added)
+++ maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java Fri May 11 09:22:15 2007
@@ -0,0 +1,488 @@
+package org.apache.maven.continuum.xmlrpc.server;
+
+/*
+ * 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.continuum.Continuum;
+import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.project.ContinuumProjectState;
+import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
+import org.apache.maven.continuum.xmlrpc.ContinuumService;
+import org.apache.maven.continuum.xmlrpc.project.AddingResult;
+import org.apache.maven.continuum.xmlrpc.project.BuildResult;
+import org.apache.maven.continuum.xmlrpc.project.BuildResultSummary;
+import org.apache.maven.continuum.xmlrpc.project.Project;
+import org.apache.maven.continuum.xmlrpc.project.ProjectDependency;
+import org.apache.maven.continuum.xmlrpc.project.ProjectGroup;
+import org.apache.maven.continuum.xmlrpc.project.ProjectGroupSummary;
+import org.apache.maven.continuum.xmlrpc.project.ProjectSummary;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ * @plexus.component role="org.apache.maven.continuum.xmlrpc.ContinuumXmlRpcComponent" role-hint="org.apache.maven.continuum.xmlrpc.ContinuumService"
+ */
+public class ContinuumServiceImpl
+    implements ContinuumService, ContinuumXmlRpcComponent
+{
+    /**
+     * @plexus.requirement
+     */
+    private Continuum continuum;
+
+    private ContinuumXmlRpcConfig config;
+
+    public void setConfig( ContinuumXmlRpcConfig config )
+    {
+        this.config = config;
+    }
+
+    // ----------------------------------------------------------------------
+    // Projects
+    // ----------------------------------------------------------------------
+
+    public List getProjects()
+        throws ContinuumException
+    {
+        List projectsList = new ArrayList();
+
+        Collection projects = continuum.getProjects();
+        if ( projects != null )
+        {
+            for ( Iterator i = projects.iterator(); i.hasNext(); )
+            {
+                org.apache.maven.continuum.model.project.Project project =
+                    (org.apache.maven.continuum.model.project.Project) i.next();
+                ProjectSummary ps = populateProjectSummary( project );
+                projectsList.add( ps );
+            }
+        }
+        return projectsList;
+    }
+
+    public ProjectSummary getProjectSummary( int projectId )
+        throws ContinuumException
+    {
+        org.apache.maven.continuum.model.project.Project project = continuum.getProject( projectId );
+        return populateProjectSummary( project );
+    }
+
+    public Project getProjectWithAllDetails( int projectId )
+        throws ContinuumException
+    {
+        org.apache.maven.continuum.model.project.Project project = continuum.getProjectWithAllDetails( projectId );
+        return populateProject( project );
+    }
+
+
+    public int removeProject( int projectId )
+        throws ContinuumException
+    {
+        continuum.removeProject( projectId );
+        return 0;
+    }
+
+    // ----------------------------------------------------------------------
+    // Projects Groups
+    // ----------------------------------------------------------------------
+
+    public ProjectGroupSummary getProjectGroupSummary( int projectGroupId )
+        throws ContinuumException
+    {
+        org.apache.maven.continuum.model.project.ProjectGroup projectGroup =
+            continuum.getProjectGroup( projectGroupId );
+        return populateProjectGroupSummary( projectGroup );
+    }
+
+    public ProjectGroup getProjectGroupWithProjects( int projectGroupId )
+        throws ContinuumException
+    {
+        org.apache.maven.continuum.model.project.ProjectGroup projectGroup =
+            continuum.getProjectGroupWithProjects( projectGroupId );
+        return populateProjectGroupWithProjects( projectGroup );
+    }
+
+    public int removeProjectGroup( int projectGroupId )
+        throws ContinuumException
+    {
+        continuum.removeProjectGroup( projectGroupId );
+        return 0;
+    }
+
+    // ----------------------------------------------------------------------
+    // Building
+    // ----------------------------------------------------------------------
+
+    public int addProjectToBuildQueue( int projectId )
+        throws ContinuumException
+    {
+        continuum.buildProject( projectId, ContinuumProjectState.TRIGGER_SCHEDULED );
+        return 0;
+    }
+
+    public int addProjectToBuildQueue( int projectId, int buildDefinitionId )
+        throws ContinuumException
+    {
+        continuum.buildProject( projectId, buildDefinitionId, ContinuumProjectState.TRIGGER_SCHEDULED );
+        return 0;
+    }
+
+    public int buildProject( int projectId )
+        throws ContinuumException
+    {
+        continuum.buildProject( projectId );
+        return 0;
+    }
+
+    public int buildProject( int projectId, int buildDefintionId )
+        throws ContinuumException
+    {
+        continuum.buildProject( projectId, buildDefintionId );
+        return 0;
+    }
+
+    // ----------------------------------------------------------------------
+    // Build Results
+    // ----------------------------------------------------------------------
+
+    public BuildResult getBuildResult( int projectId, int buildId )
+        throws ContinuumException
+    {
+        return populateBuildResult( continuum.getBuildResult( buildId ) );
+    }
+
+    public List getBuildResultsForProject( int projectId )
+        throws ContinuumException
+    {
+        List result = new ArrayList();
+        Collection buildResults = continuum.getBuildResultsForProject( projectId );
+        if ( buildResults != null )
+        {
+            for ( Iterator i = buildResults.iterator(); i.hasNext(); )
+            {
+                org.apache.maven.continuum.model.project.BuildResult buildResult =
+                    (org.apache.maven.continuum.model.project.BuildResult) i.next();
+                BuildResultSummary br = populateBuildResultSummary( buildResult );
+                result.add( br );
+            }
+        }
+
+        return result;
+    }
+
+    public String getBuildOutput( int projectId, int buildId )
+        throws ContinuumException
+    {
+        return continuum.getBuildOutput( projectId, buildId );
+    }
+
+    // ----------------------------------------------------------------------
+    // Maven 2.x projects
+    // ----------------------------------------------------------------------
+
+    public AddingResult addMavenTwoProject( String url )
+        throws ContinuumException
+    {
+        ContinuumProjectBuildingResult result = continuum.addMavenTwoProject( url );
+        return populateAddingResult( result );
+    }
+
+    public AddingResult addMavenTwoProject( String url, int projectGroupId )
+        throws ContinuumException
+    {
+        ContinuumProjectBuildingResult result = continuum.addMavenTwoProject( url, projectGroupId );
+        return populateAddingResult( result );
+    }
+
+    // ----------------------------------------------------------------------
+    // Maven 1.x projects
+    // ----------------------------------------------------------------------
+
+    public AddingResult addMavenOneProject( String url )
+        throws ContinuumException
+    {
+        ContinuumProjectBuildingResult result = continuum.addMavenOneProject( url );
+        return populateAddingResult( result );
+    }
+
+    public AddingResult addMavenOneProject( String url, int projectGroupId )
+        throws ContinuumException
+    {
+        ContinuumProjectBuildingResult result = continuum.addMavenOneProject( url, projectGroupId );
+        return populateAddingResult( result );
+    }
+
+    // ----------------------------------------------------------------------
+    // Maven ANT projects
+    // ----------------------------------------------------------------------
+
+    public ProjectSummary addAntProject( ProjectSummary project )
+        throws ContinuumException
+    {
+        int projectId = continuum.addProject( populateProject( project ), "ant" );
+        return getProjectSummary( projectId );
+    }
+
+    // ----------------------------------------------------------------------
+    // Maven Shell projects
+    // ----------------------------------------------------------------------
+
+    public ProjectSummary addShellProject( ProjectSummary project )
+        throws ContinuumException
+    {
+        int projectId = continuum.addProject( populateProject( project ), "shell" );
+        return getProjectSummary( projectId );
+    }
+
+    // ----------------------------------------------------------------------
+    // Converters
+    // ----------------------------------------------------------------------
+
+    private ProjectSummary populateProjectSummary( org.apache.maven.continuum.model.project.Project project )
+    {
+        if ( project == null )
+        {
+            return null;
+        }
+
+        Project ps = new Project();
+        ps.setArtifactId( project.getArtifactId() );
+        ps.setBuildNumber( project.getBuildNumber() );
+        ps.setDescription( project.getDescription() );
+        ps.setExecutorId( project.getExecutorId() );
+        ps.setGroupId( project.getGroupId() );
+        ps.setId( project.getId() );
+        ps.setLatestBuildId( project.getLatestBuildId() );
+        ps.setName( project.getName() );
+        ps.setProjectGroup( populateProjectGroupSummary( project.getProjectGroup() ) );
+        ps.setScmTag( project.getScmTag() );
+        ps.setScmUrl( project.getScmUrl() );
+        ps.setScmUseCache( project.isScmUseCache() );
+        ps.setScmUsername( project.getScmUsername() );
+        ps.setState( project.getState() );
+        ps.setUrl( project.getUrl() );
+        ps.setVersion( project.getVersion() );
+        ps.setWorkingDirectory( project.getWorkingDirectory() );
+        return ps;
+    }
+
+    private Project populateProject( org.apache.maven.continuum.model.project.Project project )
+    {
+        if ( project == null )
+        {
+            return null;
+        }
+
+        Project p = (Project) populateProjectSummary( project );
+
+        p.setParent( populateProjectDependency( project.getParent() ) );
+
+        if ( project.getDependencies() != null )
+        {
+            List deps = new ArrayList();
+            for ( Iterator i = project.getDependencies().iterator(); i.hasNext(); )
+            {
+                org.apache.maven.continuum.model.project.ProjectDependency d =
+                    (org.apache.maven.continuum.model.project.ProjectDependency) i.next();
+                deps.add( populateProjectDependency( d ) );
+            }
+            p.setDependencies( deps );
+        }
+
+        //TODO
+        //p.setBuildDefinitions( );
+        //p.setDevelopers( );
+        //p.setNotifiers( );
+        return p;
+    }
+
+    private org.apache.maven.continuum.model.project.Project populateProject( ProjectSummary projectSummary )
+    {
+        if ( projectSummary == null )
+        {
+            return null;
+        }
+
+        org.apache.maven.continuum.model.project.Project project =
+            new org.apache.maven.continuum.model.project.Project();
+        project.setArtifactId( projectSummary.getArtifactId() );
+        project.setBuildNumber( projectSummary.getBuildNumber() );
+        project.setDescription( projectSummary.getDescription() );
+        project.setExecutorId( projectSummary.getExecutorId() );
+        project.setGroupId( projectSummary.getGroupId() );
+        project.setId( projectSummary.getId() );
+        project.setLatestBuildId( projectSummary.getLatestBuildId() );
+        project.setName( projectSummary.getName() );
+        //project.setProjectGroup( populateProjectGroupSummary( projectSummary.getProjectGroup() ) );
+        project.setScmTag( projectSummary.getScmTag() );
+        project.setScmUrl( projectSummary.getScmUrl() );
+        project.setScmUseCache( projectSummary.isScmUseCache() );
+        project.setScmUsername( projectSummary.getScmUsername() );
+        project.setState( projectSummary.getState() );
+        project.setUrl( projectSummary.getUrl() );
+        project.setVersion( projectSummary.getVersion() );
+        project.setWorkingDirectory( projectSummary.getWorkingDirectory() );
+        return project;
+    }
+
+    private ProjectDependency populateProjectDependency(
+        org.apache.maven.continuum.model.project.ProjectDependency dependency )
+    {
+        if ( dependency == null )
+        {
+            return null;
+        }
+
+        ProjectDependency dep = new ProjectDependency();
+        dep.setArtifactId( dependency.getArtifactId() );
+        dep.setGroupId( dependency.getGroupId() );
+        dep.setVersion( dependency.getVersion() );
+        return dep;
+    }
+
+    private ProjectGroupSummary populateProjectGroupSummary(
+        org.apache.maven.continuum.model.project.ProjectGroup group )
+    {
+        if ( group == null )
+        {
+            return null;
+        }
+
+        ProjectGroup g = new ProjectGroup();
+        g.setDescription( group.getDescription() );
+        g.setGroupId( group.getGroupId() );
+        g.setId( group.getId() );
+        g.setName( group.getName() );
+        return g;
+    }
+
+    private ProjectGroup populateProjectGroupWithProjects( org.apache.maven.continuum.model.project.ProjectGroup group )
+    {
+        if ( group == null )
+        {
+            return null;
+        }
+        ProjectGroup g = (ProjectGroup) populateProjectGroupSummary( group );
+
+        if ( group.getProjects() != null )
+        {
+            List projects = new ArrayList();
+            for ( Iterator i = group.getProjects().iterator(); i.hasNext(); )
+            {
+                org.apache.maven.continuum.model.project.Project p =
+                    (org.apache.maven.continuum.model.project.Project) i.next();
+                ProjectSummary ps = populateProjectSummary( p );
+                projects.add( ps );
+            }
+            g.setProjects( projects );
+        }
+        return g;
+    }
+
+    private BuildResultSummary populateBuildResultSummary(
+        org.apache.maven.continuum.model.project.BuildResult buildResult )
+    {
+        if ( buildResult == null )
+        {
+            return null;
+        }
+        BuildResult br = new BuildResult();
+        br.setBuildNumber( buildResult.getBuildNumber() );
+        br.setEndTime( buildResult.getEndTime() );
+        br.setError( buildResult.getError() );
+        br.setExitCode( buildResult.getExitCode() );
+        br.setId( buildResult.getId() );
+        br.setStartTime( buildResult.getStartTime() );
+        br.setState( buildResult.getState() );
+        br.setSuccess( buildResult.isSuccess() );
+        br.setTrigger( buildResult.getTrigger() );
+        return br;
+    }
+
+    private BuildResult populateBuildResult( org.apache.maven.continuum.model.project.BuildResult buildResult )
+    {
+        if ( buildResult == null )
+        {
+            return null;
+        }
+        BuildResult br = (BuildResult) populateBuildResultSummary( buildResult );
+        //TODO:
+        //br.setScmResult( populateScmResult(br.getScmResult()));
+        if ( buildResult.getModifiedDependencies() != null )
+        {
+            List deps = new ArrayList();
+            for ( Iterator i = buildResult.getModifiedDependencies().iterator(); i.hasNext(); )
+            {
+                org.apache.maven.continuum.model.project.ProjectDependency dependency =
+                    (org.apache.maven.continuum.model.project.ProjectDependency) i.next();
+                ProjectDependency dep = populateProjectDependency( dependency );
+                deps.add( dep );
+            }
+            //br.setModifiedDependencies( deps );
+        }
+        //br.setProject( populateProjectSummary(buildResult.getProject() ) );
+        //br.setTestResult( populateTestResult( buildResult.getTestResult() ) );
+        return br;
+    }
+
+    private AddingResult populateAddingResult( ContinuumProjectBuildingResult result )
+    {
+        if ( result == null )
+        {
+            return null;
+        }
+        AddingResult res = new AddingResult();
+
+        if ( result.hasErrors() )
+        {
+            for ( Iterator i = result.getErrors().iterator(); i.hasNext(); )
+            {
+                String error = (String) i.next();
+                res.addError( error );
+            }
+        }
+
+        if ( result.getProjects() != null )
+        {
+            for ( Iterator i = result.getProjects().iterator(); i.hasNext(); )
+            {
+                org.apache.maven.continuum.model.project.Project project =
+                    (org.apache.maven.continuum.model.project.Project) i.next();
+                res.addProject( populateProjectSummary( project ) );
+            }
+        }
+
+        if ( result.getProjectGroups() != null )
+        {
+            for ( Iterator i = result.getProjectGroups().iterator(); i.hasNext(); )
+            {
+                org.apache.maven.continuum.model.project.ProjectGroup projectGroup =
+                    (org.apache.maven.continuum.model.project.ProjectGroup) i.next();
+                res.addProjectGroup( populateProjectGroupSummary( projectGroup ) );
+            }
+        }
+
+        return res;
+    }
+}

Propchange: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcComponent.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcComponent.java?view=auto&rev=537223
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcComponent.java (added)
+++ maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcComponent.java Fri May 11 09:22:15 2007
@@ -0,0 +1,29 @@
+package org.apache.maven.continuum.xmlrpc.server;
+
+/*
+ * 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.
+ */
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public interface ContinuumXmlRpcComponent
+{
+    public void setConfig( ContinuumXmlRpcConfig config );
+}

Propchange: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcComponent.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcConfig.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcConfig.java?view=auto&rev=537223
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcConfig.java (added)
+++ maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcConfig.java Fri May 11 09:22:15 2007
@@ -0,0 +1,44 @@
+package org.apache.maven.continuum.xmlrpc.server;
+
+/*
+ * 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.xmlrpc.common.XmlRpcHttpRequestConfigImpl;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class ContinuumXmlRpcConfig
+    extends XmlRpcHttpRequestConfigImpl
+{
+    private HttpServletRequest httpServletRequest;
+
+    public HttpServletRequest getHttpServletRequest()
+    {
+        return httpServletRequest;
+    }
+
+    public void setHttpServletRequest( HttpServletRequest httpServletRequest )
+    {
+        this.httpServletRequest = httpServletRequest;
+    }
+}

Propchange: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcConfig.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcConfig.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcServlet.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcServlet.java?view=auto&rev=537223
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcServlet.java (added)
+++ maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcServlet.java Fri May 11 09:22:15 2007
@@ -0,0 +1,219 @@
+package org.apache.maven.continuum.xmlrpc.server;
+
+/*
+ * 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.xmlrpc.XmlRpcException;
+import org.apache.xmlrpc.XmlRpcRequest;
+import org.apache.xmlrpc.common.XmlRpcHttpRequestConfig;
+import org.apache.xmlrpc.server.AbstractReflectiveHandlerMapping;
+import org.apache.xmlrpc.server.PropertyHandlerMapping;
+import org.apache.xmlrpc.server.RequestProcessorFactoryFactory;
+import org.apache.xmlrpc.server.XmlRpcServerConfigImpl;
+import org.codehaus.plexus.DefaultPlexusContainer;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.PlexusContainerException;
+import org.codehaus.plexus.classworlds.ClassWorld;
+import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.xwork.PlexusLifecycleListener;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class ContinuumXmlRpcServlet
+    extends HttpServlet
+{
+    private ContinuumXmlRpcServletServer server;
+
+    public String getServletInfo()
+    {
+        return "Continuum XMLRPC Servlet";
+    }
+
+    public void destroy()
+    {
+        if ( server != null )
+        {
+            try
+            {
+                getPlexusContainer().release( server );
+            }
+            catch ( ServletException e )
+            {
+                log( "Unable to release XmlRpcServletServer.", e );
+            }
+            catch ( ComponentLifecycleException e )
+            {
+                log( "Unable to release XmlRpcServletServer.", e );
+            }
+        }
+    }
+
+    public void init( ServletConfig servletConfig )
+        throws ServletException
+    {
+        super.init( servletConfig );
+
+        ensureContainerSet( servletConfig );
+
+        initServer();
+    }
+
+    public void initServer()
+        throws ServletException
+    {
+        server = new ContinuumXmlRpcServletServer();
+        try
+        {
+            XmlRpcServerConfigImpl cfg = (XmlRpcServerConfigImpl) server.getConfig();
+            cfg.setEnabledForExtensions( true );
+            PropertiesHandlerMapping mapping =
+                (PropertiesHandlerMapping) lookup( PropertyHandlerMapping.class.getName() );
+            mapping.setRequestProcessorFactoryFactory(
+                (RequestProcessorFactoryFactory) lookup( RequestProcessorFactoryFactory.class.getName() ) );
+            mapping.load();
+            mapping.setAuthenticationHandler( getAuthenticationHandler() );
+            server.setHandlerMapping( mapping );
+        }
+        catch ( XmlRpcException e )
+        {
+            throw new ServletException( "Can't init the xml rpc server", e );
+        }
+    }
+
+    private AbstractReflectiveHandlerMapping.AuthenticationHandler getAuthenticationHandler()
+    {
+        AbstractReflectiveHandlerMapping.AuthenticationHandler handler =
+            new AbstractReflectiveHandlerMapping.AuthenticationHandler()
+            {
+                public boolean isAuthorized( XmlRpcRequest pRequest )
+                {
+                    XmlRpcHttpRequestConfig config = (XmlRpcHttpRequestConfig) pRequest.getConfig();
+                    return isAuthenticated( config.getBasicUserName(), config.getBasicPassword() );
+                }
+            };
+        return handler;
+    }
+
+    protected boolean isAuthenticated( String username, String password )
+    {
+        //TODO: Add authentication there.
+        return true;
+    }
+
+    public void doPost( HttpServletRequest pRequest, HttpServletResponse pResponse )
+        throws IOException, ServletException
+    {
+        server.execute( pRequest, pResponse );
+    }
+
+    private void ensureContainerSet( ServletConfig sc )
+        throws ServletException
+    {
+        // TODO: unify this code with the lifecycle listener and application server
+
+        ServletContext context = sc.getServletContext();
+
+        // Attempt to find it already loaded by xwork.
+        PlexusContainer xworkContainer = (PlexusContainer) context.getAttribute( PlexusLifecycleListener.KEY );
+
+        if ( xworkContainer != null )
+        {
+            context.setAttribute( PlexusConstants.PLEXUS_KEY, xworkContainer );
+
+            return;
+        }
+
+        // Container not found.
+
+        if ( context.getAttribute( PlexusConstants.PLEXUS_KEY ) != null )
+        {
+            context.log( "Plexus container already in context." );
+
+            return;
+        }
+
+        // Create container.
+
+        Map keys = new HashMap();
+
+        PlexusContainer pc;
+        try
+        {
+            pc = new DefaultPlexusContainer( "default", keys, "META-INF/plexus/application.xml",
+                                             new ClassWorld( "plexus.core", getClass().getClassLoader() ) );
+
+            context.setAttribute( PlexusConstants.PLEXUS_KEY, pc );
+        }
+        catch ( PlexusContainerException e )
+        {
+            throw new ServletException( "Unable to initialize Plexus Container.", e );
+        }
+    }
+
+    private PlexusContainer getPlexusContainer()
+        throws ServletException
+    {
+        PlexusContainer container = (PlexusContainer) getServletContext().getAttribute( PlexusConstants.PLEXUS_KEY );
+        if ( container == null )
+        {
+            throw new ServletException( "Unable to find plexus container." );
+        }
+        return container;
+    }
+
+    public Object lookup( String role )
+        throws ServletException
+    {
+        try
+        {
+            return getPlexusContainer().lookup( role );
+        }
+        catch ( ComponentLookupException e )
+        {
+            throw new ServletException( "Unable to lookup role [" + role + "]", e );
+        }
+    }
+
+    public Object lookup( String role, String hint )
+        throws ServletException
+    {
+        try
+        {
+            return getPlexusContainer().lookup( role, hint );
+        }
+        catch ( ComponentLookupException e )
+        {
+            throw new ServletException( "Unable to lookup role [" + role + "] hint [" + hint + "]", e );
+        }
+    }
+}

Propchange: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcServlet.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcServletServer.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcServletServer.java?view=auto&rev=537223
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcServletServer.java (added)
+++ maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcServletServer.java Fri May 11 09:22:15 2007
@@ -0,0 +1,40 @@
+package org.apache.maven.continuum.xmlrpc.server;
+
+/*
+ * 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.xmlrpc.common.XmlRpcHttpRequestConfigImpl;
+import org.apache.xmlrpc.webserver.XmlRpcServletServer;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class ContinuumXmlRpcServletServer
+    extends XmlRpcServletServer
+{
+    protected XmlRpcHttpRequestConfigImpl newConfig( HttpServletRequest request )
+    {
+        ContinuumXmlRpcConfig config = new ContinuumXmlRpcConfig();
+        config.setHttpServletRequest( request );
+        return config;
+    }
+}

Propchange: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcServletServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcServletServer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/Listener.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/Listener.java?view=auto&rev=537223
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/Listener.java (added)
+++ maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/Listener.java Fri May 11 09:22:15 2007
@@ -0,0 +1,37 @@
+package org.apache.maven.continuum.xmlrpc.server;
+
+/*
+ * 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.logging.AbstractLogEnabled;
+import org.codehaus.plexus.logging.Logger;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ * @plexus.component role="org.apache.maven.continuum.xmlrpc.server.Listener"
+ */
+public class Listener
+    extends AbstractLogEnabled
+{
+    public Logger getLogger()
+    {
+        return super.getLogger();
+    }
+}

Propchange: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/Listener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/Listener.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/PropertiesHandlerMapping.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/PropertiesHandlerMapping.java?view=auto&rev=537223
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/PropertiesHandlerMapping.java (added)
+++ maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/PropertiesHandlerMapping.java Fri May 11 09:22:15 2007
@@ -0,0 +1,68 @@
+package org.apache.maven.continuum.xmlrpc.server;
+
+/*
+ * 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.xmlrpc.XmlRpcException;
+import org.apache.xmlrpc.server.PropertyHandlerMapping;
+
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ * @plexus.component role="org.apache.xmlrpc.server.PropertyHandlerMapping"
+ */
+public class PropertiesHandlerMapping
+    extends PropertyHandlerMapping
+{
+    /**
+     * @plexus.requirement role="org.apache.maven.continuum.xmlrpc.ContinuumXmlRpcComponent"
+     */
+    private Map xmlrpcComponents;
+
+    /**
+     * @plexus.requirement
+     */
+    private Listener listener;
+
+    public void load()
+        throws XmlRpcException
+    {
+        for ( Iterator i = xmlrpcComponents.keySet().iterator(); i.hasNext(); )
+        {
+            String key = (String) i.next();
+            Class cl = xmlrpcComponents.get( key ).getClass();
+            listener.getLogger().debug( key + " => " + cl.getName() );
+
+            registerPublicMethods( key, cl );
+        }
+
+        if ( listener.getLogger().isDebugEnabled() )
+        {
+            String[] methods = getListMethods();
+            for ( int i = 0; i < methods.length; i++ )
+            {
+                listener.getLogger().debug( methods[i] );
+            }
+        }
+    }
+
+}

Propchange: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/PropertiesHandlerMapping.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/PropertiesHandlerMapping.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/continuum/trunk/continuum-xmlrpc/pom.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-xmlrpc/pom.xml?view=diff&rev=537223&r1=537222&r2=537223
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/pom.xml (original)
+++ maven/continuum/trunk/continuum-xmlrpc/pom.xml Fri May 11 09:22:15 2007
@@ -1,3 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <parent>
     <artifactId>continuum-parent</artifactId>
@@ -6,48 +25,11 @@
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <artifactId>continuum-xmlrpc</artifactId>
-  <name>Continuum XMLRPC Interface</name>
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.codehaus.plexus</groupId>
-        <artifactId>plexus-maven-plugin</artifactId>
-        <executions>
-          <execution>
-            <goals>
-              <goal>descriptor</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.maven.continuum</groupId>
-      <artifactId>continuum-test</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven.continuum</groupId>
-      <artifactId>continuum-model</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven.continuum</groupId>
-      <artifactId>continuum-core</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven.continuum</groupId>
-      <artifactId>continuum-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-utils</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>hsqldb</groupId>
-      <artifactId>hsqldb</artifactId>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
+  <name>Continuum XMLRPC :: Parent</name>
+  <packaging>pom</packaging>
+  <modules>
+    <module>continuum-xmlrpc-api</module>
+    <module>continuum-xmlrpc-client</module>
+    <module>continuum-xmlrpc-server</module>
+  </modules>
 </project>

Modified: maven/continuum/trunk/pom.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/pom.xml?view=diff&rev=537223&r1=537222&r2=537223
==============================================================================
--- maven/continuum/trunk/pom.xml (original)
+++ maven/continuum/trunk/pom.xml Fri May 11 09:22:15 2007
@@ -330,7 +330,17 @@
       </dependency>
       <dependency>
         <groupId>org.apache.maven.continuum</groupId>
-        <artifactId>continuum-xmlrpc</artifactId>
+        <artifactId>continuum-xmlrpc-api</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.maven.continuum</groupId>
+        <artifactId>continuum-xmlrpc-client</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.maven.continuum</groupId>
+        <artifactId>continuum-xmlrpc-server</artifactId>
         <version>${pom.version}</version>
       </dependency>
       <dependency>
@@ -485,6 +495,11 @@
         <groupId>org.codehaus.plexus</groupId>
         <artifactId>plexus-quartz</artifactId>
         <version>1.0-alpha-3</version>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-xwork-integration</artifactId>
+        <version>1.0-alpha-6</version>
       </dependency>
       <!--
         Plexus Redback Dependencies