diff options
3 files changed, 91 insertions, 12 deletions
diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java index 4a3938f1d..b02cf1106 100644 --- a/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java +++ b/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java @@ -31,10 +31,9 @@ import org.codehaus.plexus.jdo.JdoFactory; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; +import org.jpox.PMFConfiguration; import org.jpox.SchemaTool; -import sun.security.action.GetLongAction; - import java.io.File; import java.io.PrintStream; import java.net.URL; @@ -79,23 +78,37 @@ public class JdoAccess throws InitializationException { pmf = jdoFactory.getPersistenceManagerFactory(); - + + /* Primitive (and failed) attempt at creating the schema on startup. + Just to prevent the multiple stack trace warnings on auto-gen of schema. + // Create the schema (if needed) URL jdoFileUrls[] = new URL[] { getClass().getResource( "/org/apache/maven/archiva/model/package.jdo" ) }; File propsFile = null; // intentional boolean verbose = true; - + try { + String connectionFactoryName = pmf.getConnectionFactoryName(); + if ( StringUtils.isNotBlank( connectionFactoryName ) && connectionFactoryName.startsWith( "java:comp" ) ) + { + // We have a JNDI datasource! + String jndiDatasource = connectionFactoryName; + System.setProperty( PMFConfiguration.JDO_DATASTORE_URL_PROPERTY, jndiDatasource ); + } + + // TODO: figure out how to get the jdbc driver details from JNDI to pass into SchemaTool. + SchemaTool.createSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose, null ); } catch ( Exception e ) { getLogger().error( "Unable to create schema: " + e.getMessage(), e ); } - + pmf.getPersistenceManager(); + */ // Add the lifecycle listener. pmf.addInstanceLifecycleListener( this, null ); @@ -352,7 +365,7 @@ public class JdoAccess + "> declared parameters, yet there are <" + constraint.getParameters().length + "> parameter objects to use. This should be equal." ); } - + query.declareParameters( StringUtils.join( constraint.getDeclaredParameters(), ", " ) ); return processParameterizedQuery( query, constraint.getParameters() ); diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DownloadArtifact.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DownloadArtifact.java index a637fd549..691062b99 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DownloadArtifact.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DownloadArtifact.java @@ -39,6 +39,7 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti import java.io.IOException; import java.io.Writer; +import java.text.DecimalFormat; import java.util.Iterator; import java.util.List; @@ -80,9 +81,12 @@ public class DownloadArtifact private boolean mini = false; + private DecimalFormat decimalFormat; + public DownloadArtifact( OgnlValueStack stack, PageContext pageContext ) { super( stack ); + decimalFormat = new DecimalFormat( "#,#00" ); this.req = (HttpServletRequest) pageContext.getRequest(); this.res = (HttpServletResponse) pageContext.getResponse(); try @@ -198,13 +202,29 @@ public class DownloadArtifact // Body sb.append( "<p class=\"body\">" ); + sb.append( "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" ); Iterator it = relatedArtifacts.iterator(); while ( it.hasNext() ) { ArchivaArtifact artifact = (ArchivaArtifact) it.next(); - + sb.append("\n<tr>"); + + sb.append( "<td class=\"icon\">" ); + appendImageLink( sb, prefix, layout, artifact ); + sb.append( "</td>" ); + + sb.append( "<td class=\"type\">" ); appendLink( sb, prefix, layout, artifact ); + sb.append( "</td>" ); + + sb.append( "<td class=\"size\">" ); + appendFilesize( sb, artifact ); + sb.append( "</td>" ); + + sb.append("</tr>"); } + sb.append( "</table>" ); + sb.append( "</p>" ); sb.append( "</div>" ); // close "downloadbox.bd.c" sb.append( "</div>" ); // close "downloadbox.bd" @@ -212,6 +232,27 @@ public class DownloadArtifact sb.append( "<div class=\"ft\"><div class=\"c\"></div></div>" ); sb.append( "</div>" ); // close "download" } + + private void appendImageLink( StringBuffer sb, String prefix, BidirectionalRepositoryLayout layout, ArchivaArtifact artifact ) + { + StringBuffer url = new StringBuffer(); + String path = layout.toPath( artifact ); + String type = artifact.getType(); + + url.append( prefix ); + url.append( "/" ).append( path ); + + String filename = path.substring( path.lastIndexOf( "/" ) + 1 ); + + sb.append( "<a href=\"" ).append( StringEscapeUtils.escapeXml( url.toString() ) ).append( "\"" ); + sb.append( " title=\"" ).append( "Download " ).append( StringEscapeUtils.escapeXml( filename ) ).append( "\"" ); + sb.append( ">" ); + + sb.append( "<img src=\"" ).append( req.getContextPath() ); + sb.append( "/images/download-type-" ).append( type ).append( ".png\" />" ); + + sb.append( "</a>" ); + } private void appendLink( StringBuffer sb, String prefix, BidirectionalRepositoryLayout layout, ArchivaArtifact artifact ) @@ -229,13 +270,14 @@ public class DownloadArtifact sb.append( " title=\"" ).append( "Download " ).append( StringEscapeUtils.escapeXml( filename ) ).append( "\"" ); sb.append( ">" ); - sb.append( "<img src=\"" ).append( req.getContextPath() ); - sb.append( "/images/download-type-" ).append( type ).append( ".png\" />" ); - - // TODO: Include file size / date in output ? sb.append( StringUtils.capitalize( type ) ); sb.append( "</a>" ); } + + private void appendFilesize( StringBuffer sb, ArchivaArtifact artifact ) + { + sb.append( decimalFormat.format( artifact.getModel().getSize() ) ); + } public void setArtifactId( String artifactId ) { diff --git a/archiva-web/archiva-webapp/src/main/webapp/css/site.css b/archiva-web/archiva-webapp/src/main/webapp/css/site.css index 73c65f9db..03f6a4f6f 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/css/site.css +++ b/archiva-web/archiva-webapp/src/main/webapp/css/site.css @@ -107,6 +107,30 @@ text-decoration: none; } +.download p.body { + font-weight: bold; +} + +.download table { + margin-left: 5px; + width: 140px; +} + +.download .icon { + width: 16px; +} + +.download .type { + font-size: 0.9em; + text-align: right; +} + +.download .size { + font-weight: normal; + font-size: 0.8em; + text-align: right; +} + #contentArea { /* margin-right: 15em; */ padding: 1em; @@ -342,4 +366,4 @@ div.admin table.consumers th { div.admin table.consumers td strong { font-size: 0.8em; -}
\ No newline at end of file +} |