Search in sources :

Example 1 with FilePublish

use of org.commonjava.maven.galley.filearc.internal.FilePublish in project galley by Commonjava.

the class FileTransport method createPublishJob.

@Override
public PublishJob createPublishJob(final ConcreteResource resource, final InputStream stream, final long length, final String contentType, final int timeoutSeconds) throws TransferException {
    final File pubDir = config.getPubDir();
    if (pubDir == null) {
        throw new TransferException("This transport is read-only!");
    }
    final File dest = new File(pubDir, config.getGenerator().getFilePath(resource));
    final File dir = dest.getParentFile();
    if (dir != null && !dir.exists() && !dir.mkdirs()) {
        throw new TransferException("Cannot create directory: %s", dir);
    }
    return new FilePublish(dest, stream);
}
Also used : TransferException(org.commonjava.maven.galley.TransferException) FilePublish(org.commonjava.maven.galley.filearc.internal.FilePublish) File(java.io.File)

Aggregations

File (java.io.File)1 TransferException (org.commonjava.maven.galley.TransferException)1 FilePublish (org.commonjava.maven.galley.filearc.internal.FilePublish)1