import javax.jws.WebParam class ImageArchiveService { public static final String IMAGEID = "iid2" public static final String PROJECTID = "projectid" boolean transactional = true static expose = ['xfire'] boolean archiveImage(@WebParam (name = "pathToFile", header = true) String pathToFile, @WebParam (name = "projectId", header = true) String projectId) { boolean status = false if ( pathToFile ) { def file = new File(pathToFile) if ( file.exists() ) { String baseDir = (file.isDirectory()) ? file.absolutePath : file.parentFile.absolutePath Repository repository = Repository.findByBaseDir(baseDir) if ( !repository ) { repository = new Repository(baseDir: baseDir) repository.scanStartDate = new Date() repository.scanEndDate = null repository.save(flush: true) } def Stager stager = new Stager(repository) if ( projectId ) { stager.parser.additionalTags = [PROJECTID: projectId] } stager.scan(pathToFile as File) repository.scanEndDate = new Date() status = repository.save(flush: true) } } return status } String findImage(@WebParam (name = "imageId", header = true) String imageId, @WebParam (name = "projectId", header = true) String projectId) { def query = "from RasterEntry r where " def params = [max: 1] if ( imageId ) { query += "r in (select t.rasterEntry from MetadataTag t inner join t.rasterEntry where lower(t.name)=lower(:imageIdName) and lower(t.value) like lower(:imageIdValue))" params["imageIdName"] = IMAGEID params["imageIdValue"] = "%${imageId}%" } if ( imageId && projectId ) { query += " and " } if ( projectId ) { query += "r in (select t.rasterEntry from MetadataTag t inner join t.rasterEntry where lower(t.name)=lower(:projectIdName) and lower(t.value) like lower(:projectIdValue))" params["projectIdName"] = PROJECTID params["projectIdValue"] = "%${projectId}%" } def images = RasterEntry.executeQuery(query, params) return images[0]?.mainFile?.name } boolean updatePath(@WebParam (name = "imageId", header = true) String imageId, @WebParam (name = "oldPath", header = true) String oldPath, @WebParam (name = "newPath", header = true) String newPath) { return false } }