org.apache.archiva.web.api
Class DefaultFileUploadService

java.lang.Object
  extended by org.apache.archiva.rest.services.AbstractRestService
      extended by org.apache.archiva.web.api.DefaultFileUploadService
All Implemented Interfaces:
FileUploadService

@Service(value="fileUploadService#rest")
public class DefaultFileUploadService
extends AbstractRestService
implements FileUploadService

Author:
Olivier Lamy

Field Summary
private  ChecksumAlgorithm[] algorithms
           
private  ArchivaAdministration archivaAdministration
           
private  javax.servlet.http.HttpServletRequest httpServletRequest
           
private  org.slf4j.Logger log
           
private  ManagedRepositoryAdmin managedRepositoryAdmin
           
private  RepositoryContentFactory repositoryFactory
           
private  ArchivaTaskScheduler scheduler
           
 
Fields inherited from class org.apache.archiva.rest.services.AbstractRestService
config, repositoryContentFactory, repositorySessionFactory, repositoryTaskScheduler, userRepositories
 
Fields inherited from interface org.apache.archiva.web.api.FileUploadService
FILES_SESSION_KEY
 
Constructor Summary
DefaultFileUploadService()
           
 
Method Summary
 Boolean clearUploadedFiles()
           
private  void copyFile(File sourceFile, File targetPath, String targetFilename, boolean fixChecksums)
           
private  File createPom(File targetPath, String filename, FileMetadata fileMetadata, String groupId, String artifactId, String version, String packaging)
           
 Boolean deleteFile(String fileName)
           
private  void fixChecksums(File file)
           
private  ArchivaRepositoryMetadata getMetadata(File metadataFile)
           
 List<FileMetadata> getSessionFileMetadatas()
           
protected  List<FileMetadata> getSessionFilesList()
          FIXME must be per session synchronized not globally
private  String getStringValue(org.apache.cxf.jaxrs.ext.multipart.MultipartBody multipartBody, String attachmentId)
           
 FileMetadata post(org.apache.cxf.jaxrs.ext.multipart.MultipartBody multipartBody)
           
private  void queueRepositoryTask(String repositoryId, File localFile)
           
 Boolean save(String repositoryId, String groupId, String artifactId, String version, String packaging, boolean generatePom)
           
protected  void saveFile(String repositoryId, FileMetadata fileMetadata, boolean generatePom, String groupId, String artifactId, String version, String packaging)
           
protected  void savePomFile(String repositoryId, FileMetadata fileMetadata, String groupId, String artifactId, String version, String packaging)
           
private  void updateProjectMetadata(String targetPath, Date lastUpdatedTimestamp, String timestamp, int buildNumber, boolean fixChecksums, FileMetadata fileMetadata, String groupId, String artifactId, String version, String packaging)
          Update artifact level metadata.
private  void updateVersionMetadata(ArchivaRepositoryMetadata metadata, File metadataFile, Date lastUpdatedTimestamp, String timestamp, int buildNumber, boolean fixChecksums, FileMetadata fileMetadata, String groupId, String artifactId, String version, String packaging)
          Update version level metadata for snapshot artifacts.
 
Methods inherited from class org.apache.archiva.rest.services.AbstractRestService
buildArtifacts, doScanRepository, getArtifactUrl, getAuditInformation, getAuditListeners, getBaseUrl, getBeansOfType, getObservableRepos, getPrincipal, setAuditListeners, triggerAuditEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private org.slf4j.Logger log

httpServletRequest

@Context
private javax.servlet.http.HttpServletRequest httpServletRequest

managedRepositoryAdmin

@Inject
private ManagedRepositoryAdmin managedRepositoryAdmin

repositoryFactory

@Inject
private RepositoryContentFactory repositoryFactory

archivaAdministration

@Inject
private ArchivaAdministration archivaAdministration

algorithms

private ChecksumAlgorithm[] algorithms

scheduler

@Inject
@Named(value="archivaTaskScheduler#repository")
private ArchivaTaskScheduler scheduler
Constructor Detail

DefaultFileUploadService

public DefaultFileUploadService()
Method Detail

getStringValue

private String getStringValue(org.apache.cxf.jaxrs.ext.multipart.MultipartBody multipartBody,
                              String attachmentId)
                       throws IOException
Throws:
IOException

post

public FileMetadata post(org.apache.cxf.jaxrs.ext.multipart.MultipartBody multipartBody)
                  throws ArchivaRestServiceException
Specified by:
post in interface FileUploadService
Throws:
ArchivaRestServiceException

getSessionFilesList

protected List<FileMetadata> getSessionFilesList()
FIXME must be per session synchronized not globally

Returns:

deleteFile

public Boolean deleteFile(String fileName)
                   throws ArchivaRestServiceException
Specified by:
deleteFile in interface FileUploadService
Throws:
ArchivaRestServiceException

clearUploadedFiles

public Boolean clearUploadedFiles()
                           throws ArchivaRestServiceException
Specified by:
clearUploadedFiles in interface FileUploadService
Throws:
ArchivaRestServiceException

getSessionFileMetadatas

public List<FileMetadata> getSessionFileMetadatas()
                                           throws ArchivaRestServiceException
Specified by:
getSessionFileMetadatas in interface FileUploadService
Throws:
ArchivaRestServiceException

save

public Boolean save(String repositoryId,
                    String groupId,
                    String artifactId,
                    String version,
                    String packaging,
                    boolean generatePom)
             throws ArchivaRestServiceException
Specified by:
save in interface FileUploadService
Throws:
ArchivaRestServiceException

savePomFile

protected void savePomFile(String repositoryId,
                           FileMetadata fileMetadata,
                           String groupId,
                           String artifactId,
                           String version,
                           String packaging)
                    throws ArchivaRestServiceException
Throws:
ArchivaRestServiceException

saveFile

protected void saveFile(String repositoryId,
                        FileMetadata fileMetadata,
                        boolean generatePom,
                        String groupId,
                        String artifactId,
                        String version,
                        String packaging)
                 throws ArchivaRestServiceException
Throws:
ArchivaRestServiceException

getMetadata

private ArchivaRepositoryMetadata getMetadata(File metadataFile)
                                       throws RepositoryMetadataException
Throws:
RepositoryMetadataException

createPom

private File createPom(File targetPath,
                       String filename,
                       FileMetadata fileMetadata,
                       String groupId,
                       String artifactId,
                       String version,
                       String packaging)
                throws IOException
Throws:
IOException

fixChecksums

private void fixChecksums(File file)

queueRepositoryTask

private void queueRepositoryTask(String repositoryId,
                                 File localFile)

copyFile

private void copyFile(File sourceFile,
                      File targetPath,
                      String targetFilename,
                      boolean fixChecksums)
               throws IOException
Throws:
IOException

updateProjectMetadata

private void updateProjectMetadata(String targetPath,
                                   Date lastUpdatedTimestamp,
                                   String timestamp,
                                   int buildNumber,
                                   boolean fixChecksums,
                                   FileMetadata fileMetadata,
                                   String groupId,
                                   String artifactId,
                                   String version,
                                   String packaging)
                            throws RepositoryMetadataException
Update artifact level metadata. If it does not exist, create the metadata and fix checksums if necessary.

Throws:
RepositoryMetadataException

updateVersionMetadata

private void updateVersionMetadata(ArchivaRepositoryMetadata metadata,
                                   File metadataFile,
                                   Date lastUpdatedTimestamp,
                                   String timestamp,
                                   int buildNumber,
                                   boolean fixChecksums,
                                   FileMetadata fileMetadata,
                                   String groupId,
                                   String artifactId,
                                   String version,
                                   String packaging)
                            throws RepositoryMetadataException
Update version level metadata for snapshot artifacts. If it does not exist, create the metadata and fix checksums if necessary.

Throws:
RepositoryMetadataException


Copyright © 2006-2013 The Apache Software Foundation. All Rights Reserved.