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;
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 );
+ "> 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() );
import java.io.IOException;
import java.io.Writer;
+import java.text.DecimalFormat;
import java.util.Iterator;
import java.util.List;
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
// 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"
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 )
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 )
{