Commit a5ffb5f2 authored by Matija Obreza's avatar Matija Obreza

Minor updates

- Dataset API v0 download in DwCA format
- /google/verify-token uses POST
- Reduced logging for AccessionRefs matching
parent d56b408d
......@@ -604,7 +604,7 @@ public class DatasetServiceImpl implements DatasetService {
throw new InvalidApiUsageException("Cannot modify a published Dataset.");
}
LOG.warn("Adding {} accession references to Dataset.", accessionRefs.size());
LOG.debug("Adding {} accession references to Dataset.", accessionRefs.size());
List<DatasetAccessionRef> dArs = Lists.newArrayList();
accessionRefs.forEach(ref -> {
DatasetAccessionRef dAr = new DatasetAccessionRef(ref);
......@@ -613,7 +613,7 @@ public class DatasetServiceImpl implements DatasetService {
});
accessionRefRepository.save(dArs);
loadedDataset.setAccessionCount((int) accessionRefRepository.countByDataset(loadedDataset));
LOG.warn("Done saving {} accession refs, have {} in dataset", accessionRefs.size(), loadedDataset.getAccessionCount());
LOG.info("Done saving {} accession refs, have {} in dataset", accessionRefs.size(), loadedDataset.getAccessionCount());
datasetRepository.save(loadedDataset);
threadPoolTaskExecutor.execute(() -> {
......@@ -963,7 +963,7 @@ public class DatasetServiceImpl implements DatasetService {
LOG.info("Batch {} with size {}", batchCounter.incrementAndGet(), batch.size());
List<Accession> foundAccessions = accessionRepository.find(batch);
LOG.warn("Found {} matches for {} identifiers after {}ms", foundAccessions.size(), batch.size(), stopWatch.getTime());
LOG.info("Found {} matches for {} identifiers after {}ms", foundAccessions.size(), batch.size(), stopWatch.getTime());
// instCode / genus / acceNumb map
Map<String, Map<String, Map<String, Accession>>> instMap = new HashMap<>();
......@@ -1007,7 +1007,7 @@ public class DatasetServiceImpl implements DatasetService {
});
});
LOG.warn("Matched {} accession refs after {}ms", accessionRefs.size(), stopWatch.getTime());
LOG.info("Matched {} accession refs after {}ms", accessionRefs.size(), stopWatch.getTime());
return accessionRefs;
}
......@@ -1028,7 +1028,7 @@ public class DatasetServiceImpl implements DatasetService {
if (dataset == null) {
return dataset;
}
LOG.warn("Linking {} accessions with dataset {}", dataset.getAccessionCount(), dataset.getId());
LOG.info("Linking {} accessions with dataset {}", dataset.getAccessionCount(), dataset.getId());
final AtomicInteger batchCounter = new AtomicInteger(0);
......@@ -1040,7 +1040,7 @@ public class DatasetServiceImpl implements DatasetService {
});
// Save in this transaction
accessionRefRepository.update(accessionRefs);
LOG.warn("Done relinking {} accession refs.", accessionRefs.size());
LOG.info("Done relinking {} accession refs.", accessionRefs.size());
return lazyLoad(dataset);
}
......
......@@ -274,6 +274,28 @@ public class DatasetController extends ApiBaseController {
}
}
@RequestMapping(value = "/{metadataId}/dwca", method = RequestMethod.GET)
public void downloadDwCA(@PathVariable(value = "metadataId") long metadataId, HttpServletResponse response) throws IOException {
LOG.debug("Downloading DwCA data for {}", metadataId);
final Metadata metadata = genesysService.getMetadata(metadataId);
if (metadata == null) {
throw new ResourceNotFoundException();
}
// Write dataset to the stream.
response.setContentType("application/zip");
response.addHeader("Content-Disposition", String.format("attachment; filename=\"genesys-dataset-%1$s.zip\"", metadata.getUuid()));
final OutputStream outputStream = response.getOutputStream();
try {
datasetService.writeDataset(metadata, outputStream);
response.flushBuffer();
} catch (EOFException e) {
LOG.warn("Download was aborted: {}", e.getMessage());
}
}
/**
* Get metadata Methods /datasets/{shortName}/methods
*
......
......@@ -122,7 +122,7 @@ public class GoogleSocialController extends BaseController {
* @param clientId the client id
* @return the object
*/
@RequestMapping(value = "/google/verify-token", method = RequestMethod.GET)
@RequestMapping(value = "/google/verify-token", method = RequestMethod.POST)
@ResponseBody
public Object googleAuth(@RequestParam("tokenId") final String tokenId,
@RequestParam("clientId") final String clientId) throws UserException, IOException, GeneralSecurityException {
......
......@@ -356,7 +356,7 @@ public class SubsetServiceImpl implements SubsetService {
throw new InvalidApiUsageException("Cannot modify a published Subset.");
}
LOG.warn("Adding {} accession references to Subset.", accessionRefs.size());
LOG.info("Adding {} accession references to Subset.", accessionRefs.size());
List<SubsetAccessionRef> sArs = Lists.newArrayList();
accessionRefs.forEach(ref -> {
SubsetAccessionRef sAr = new SubsetAccessionRef(ref);
......@@ -365,7 +365,7 @@ public class SubsetServiceImpl implements SubsetService {
});
accessionRefRepository.save(sArs);
loadedSubset.setAccessionCount((int) accessionRefRepository.countBySubset(loadedSubset));
LOG.warn("Done saving {} accession refs, have {} in subset", accessionRefs.size(), loadedSubset.getAccessionCount());
LOG.info("Done saving {} accession refs, have {} in subset", accessionRefs.size(), loadedSubset.getAccessionCount());
subsetRepository.save(loadedSubset);
threadPoolTaskExecutor.execute(() -> {
......@@ -594,7 +594,7 @@ public class SubsetServiceImpl implements SubsetService {
if (subset == null) {
return subset;
}
LOG.warn("Linking {} accessions with subset {}", subset.getAccessionCount(), subset.getId());
LOG.info("Linking {} accessions with subset {}", subset.getAccessionCount(), subset.getId());
final AtomicInteger batchCounter = new AtomicInteger(0);
......@@ -606,14 +606,14 @@ public class SubsetServiceImpl implements SubsetService {
});
// Save in this transaction
accessionRefRepository.update(accessionRefs);
LOG.warn("Done relinking {} accession refs.", accessionRefs.size());
LOG.info("Done relinking {} accession refs.", accessionRefs.size());
return lazyLoad(subset);
}
@Transactional(readOnly = false)
@PreAuthorize("hasRole('ADMINISTRATOR')")
private List<SubsetAccessionRef> rematchSubsetAccessions(List<SubsetAccessionRef> accessionRefs) {
LOG.warn("Linking {} accession refs with accessions", accessionRefs.size());
LOG.debug("Linking {} accession refs with accessions", accessionRefs.size());
final AtomicInteger batchCounter = new AtomicInteger(0);
......@@ -624,7 +624,7 @@ public class SubsetServiceImpl implements SubsetService {
});
// Save in this transaction
accessionRefRepository.update(accessionRefs);
LOG.warn("Done relinking {} accession refs.", accessionRefs.size());
LOG.info("Done relinking {} accession refs.", accessionRefs.size());
return accessionRefs;
}
......@@ -691,7 +691,7 @@ public class SubsetServiceImpl implements SubsetService {
});
});
LOG.warn("Matched {} accession refs after {}ms", accessionRefs.size(), stopWatch.getTime());
LOG.info("Matched {} accession refs after {}ms", accessionRefs.size(), stopWatch.getTime());
return accessionRefs;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment