[MRM-1041]

o show shared basic project info in versions list browse
o fix model not being set in repository browse


git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@745359 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Maria Odea B. Ching 2009-02-18 02:24:09 +00:00
parent 5f39994250
commit f7b27068d7
4 changed files with 206 additions and 20 deletions

View File

@ -318,7 +318,7 @@ public class DefaultRepositoryBrowsing
try
{
dao.getProjectModelDAO().getProjectModel( groupId, artifactId, version );
model = dao.getProjectModelDAO().getProjectModel( groupId, artifactId, version );
}
catch (ObjectNotFoundException e)
{

View File

@ -25,10 +25,12 @@ import java.util.List;
import com.opensymphony.xwork2.ActionContext;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.database.ArchivaDatabaseException;
import org.apache.maven.archiva.database.ObjectNotFoundException;
import org.apache.maven.archiva.database.browsing.BrowsingResults;
import org.apache.maven.archiva.database.browsing.RepositoryBrowsing;
import org.apache.maven.archiva.model.ArchivaProjectModel;
import org.apache.maven.archiva.security.*;
import org.apache.maven.archiva.security.ArchivaXworkUser;
/**
* Browse the repository.
@ -63,7 +65,9 @@ public class BrowseAction
private String artifactId;
private String repositoryId;
private ArchivaProjectModel sharedModel;
public String browse()
{
List<String> selectedRepos = getObservableRepos();
@ -117,11 +121,88 @@ public class BrowseAction
{
return GlobalResults.ACCESS_TO_NO_REPOS;
}
this.results = repoBrowsing.selectArtifactId( getPrincipal(), selectedRepos, groupId, artifactId );
populateSharedModel();
return SUCCESS;
}
private void populateSharedModel()
{
sharedModel = new ArchivaProjectModel();
sharedModel.setGroupId( groupId );
sharedModel.setArtifactId( artifactId );
boolean isFirstVersion = true;
for( String version : this.results.getVersions() )
{
try
{
ArchivaProjectModel model =
repoBrowsing.selectVersion( getPrincipal(), getObservableRepos(), groupId, artifactId, version );
if( isFirstVersion )
{
sharedModel = model;
}
else
{
if ( sharedModel.getPackaging() != null &&
!StringUtils.equalsIgnoreCase( sharedModel.getPackaging(), model.getPackaging() ) )
{
sharedModel.setPackaging( null );
}
if ( sharedModel.getName() != null &&
!StringUtils.equalsIgnoreCase( sharedModel.getName(), model.getName() ) )
{
sharedModel.setName( "" );
}
if ( sharedModel.getDescription() != null &&
!StringUtils.equalsIgnoreCase( sharedModel.getDescription(), model.getDescription() ) )
{
sharedModel.setDescription( null );
}
if ( sharedModel.getIssueManagement() != null &&
!StringUtils.equalsIgnoreCase( sharedModel.getIssueManagement().getUrl(), model.getIssueManagement().getUrl() ) )
{
sharedModel.setIssueManagement( null );
}
if ( sharedModel.getCiManagement() != null &&
!StringUtils.equalsIgnoreCase( sharedModel.getCiManagement().getUrl(), model.getCiManagement().getUrl() ) )
{
sharedModel.setCiManagement( null );
}
if ( sharedModel.getOrganization() != null &&
!StringUtils.equalsIgnoreCase( sharedModel.getOrganization().getName(), model.getOrganization().getName() ) )
{
sharedModel.setOrganization( null );
}
if ( sharedModel.getUrl() != null && !StringUtils.equalsIgnoreCase( sharedModel.getUrl(), model.getUrl() ) )
{
sharedModel.setUrl( null );
}
}
isFirstVersion = false;
}
catch ( ObjectNotFoundException e )
{
getLogger().debug( e.getMessage(), e );
}
catch ( ArchivaDatabaseException e )
{
getLogger().debug( e.getMessage(), e );
}
}
}
private String getPrincipal()
{
@ -184,4 +265,14 @@ public class BrowseAction
this.repositoryId = repositoryId;
}
public ArchivaProjectModel getSharedModel()
{
return sharedModel;
}
public void setSharedModel( ArchivaProjectModel sharedModel )
{
this.sharedModel = sharedModel;
}
}

View File

@ -26,6 +26,19 @@
<head>
<title>Browse Repository</title>
<s:head/>
<script type="text/javascript" src="<c:url value='/js/jquery/jquery-1.2.6.pack.js'/>"></script>
<script type="text/javascript">
$(document).ready(function(){
$("table.infoTable").hide();
$("a.expand").click(function(event){
event.preventDefault();
$(this).next().toggle("slow");
});
});
</script>
</head>
<body>
@ -83,24 +96,95 @@
</c:if>
<c:if test="${not empty results.versions}">
<div id="nameColumn">
<h2>Versions</h2>
<ul>
<c:forEach items="${results.versions}" var="version">
<c:set var="url">
<s:url action="showArtifact" namespace="/">
<s:param name="groupId" value="%{#attr.results.selectedGroupId}"/>
<s:param name="artifactId" value="%{#attr.results.selectedArtifactId}"/>
<s:param name="version" value="%{#attr.version}"/>
</s:url>
</c:set>
<li><a href="${url}">${version}/</a></li>
</c:forEach>
</ul>
</div>
<%-- show shared project information (MRM-1041) --%>
<h2>Versions</h2>
<div id="nameColumn" class="versions">
<a class="expand" href="#">Artifact Info</a>
<table class="infoTable">
<tr>
<th>Group ID</th>
<td>${sharedModel.groupId}</td>
</tr>
<tr>
<th>Artifact ID</th>
<td>${sharedModel.artifactId}</td>
</tr>
<c:if test="${sharedModel.packaging != null}">
<tr>
<th>Packaging</th>
<td><code>${sharedModel.packaging}</code></td>
</tr>
</c:if>
<c:if test="${sharedModel.name != null}">
<tr>
<th>Name</th>
<td><code>${sharedModel.name}</code></td>
</tr>
</c:if>
<c:if test="${sharedModel.organization != null}">
<tr>
<th>Organisation</th>
<td>
<c:choose>
<c:when test="${sharedModel.organization.url != null}">
<a href="${sharedModel.organization.url}">${sharedModel.organization.name}</a>
</c:when>
<c:otherwise>
${sharedModel.organization.name}
</c:otherwise>
</c:choose>
</td>
</tr>
</c:if>
<c:if test="${sharedModel.issueManagement != null}">
<tr>
<th>Issue Tracker</th>
<td>
<c:choose>
<c:when test="${!empty (sharedModel.issueManagement.url)}">
<a href="${sharedModel.issueManagement.url}">${sharedModel.issueManagement.system}</a>
</c:when>
<c:otherwise>
${sharedModel.issueManagement.system}
</c:otherwise>
</c:choose>
</td>
</tr>
</c:if>
<c:if test="${sharedModel.ciManagement != null}">
<tr>
<th>Continuous Integration</th>
<td>
<c:choose>
<c:when test="${!empty (sharedModel.ciManagement.url)}">
<a href="${sharedModel.ciManagement.url}">${sharedModel.ciManagement.system}</a>
</c:when>
<c:otherwise>
${sharedModel.ciManagement.system}
</c:otherwise>
</c:choose>
</td>
</tr>
</c:if>
</table>
</div>
<ul>
<c:forEach items="${results.versions}" var="version">
<c:set var="url">
<s:url action="showArtifact" namespace="/">
<s:param name="groupId" value="%{#attr.results.selectedGroupId}"/>
<s:param name="artifactId" value="%{#attr.results.selectedArtifactId}"/>
<s:param name="version" value="%{#attr.version}"/>
</s:url>
</c:set>
<li><a href="${url}">${version}/</a></li>
</c:forEach>
</ul>
</c:if>
</div>
</body>
</html>
</html>

View File

@ -424,4 +424,15 @@ div.infobox {
div.buttons {
text-align: center;
}
div.versions {
border: 1px dashed #DFDEDE;
margin-bottom: 15px;
padding: 5px;
}
div.versions a.expand {
font-size: 7pt;
color: gray;
}