use of org.opencadc.tap.TapClient in project caom2db by opencadc.
the class InventoryArtifactStore method init.
private void init() {
Subject subject = AuthenticationUtil.getCurrentSubject();
AuthMethod authMethod = AuthenticationUtil.getAuthMethodFromCredentials(subject);
URI securityMethod = Standards.getSecurityMethod(authMethod);
if (storageInventoryTapURL == null) {
try {
TapClient tapClient = new TapClient<>(queryServiceResourceID);
storageInventoryTapURL = tapClient.getSyncURL(securityMethod);
} catch (Throwable t) {
String message = "Failed to initialize Storage-Inventory TAP URL";
throw new RuntimeException(message, t);
}
}
}
use of org.opencadc.tap.TapClient in project caom2db by opencadc.
the class ArtifactValidator method getLogicalMetadata.
private TreeSet<ArtifactMetadata> getLogicalMetadata() throws Exception {
TreeSet<ArtifactMetadata> result = new TreeSet<>(ArtifactMetadata.getComparator());
if (StringUtil.hasText(source)) {
// use database <server.database.schema>
// HarvestSkipURI table is not supported in 'diff' mode, i.e. reportOnly = true
this.supportSkipURITable = !reportOnly;
long t1 = System.currentTimeMillis();
List<ObservationState> states = observationDAO.getObservationList(collection, null, null, null);
long t2 = System.currentTimeMillis();
long dt = t2 - t1;
log.info("get-state-list: size=" + states.size() + " in " + dt + " ms");
int depth = 3;
ListIterator<ObservationState> iter = states.listIterator();
t1 = System.currentTimeMillis();
while (iter.hasNext()) {
ObservationState s = iter.next();
// GC
iter.remove();
ObservationResponse resp = observationDAO.getObservationResponse(s, depth);
if (resp == null) {
log.error("Null response from Observation DAO, ObservationURI: " + s.getURI().toString() + ", depth: " + depth);
} else if (resp.observation == null) {
log.error("Observation is null, ObservationURI: " + s.getURI().toString() + ", depth: " + depth);
} else {
for (Plane plane : resp.observation.getPlanes()) {
for (Artifact artifact : plane.getArtifacts()) {
String observationID = s.getURI().getObservationID();
result.add(getMetadata(observationID, artifact, plane.dataRelease, plane.metaRelease));
}
}
}
}
log.info("Finished logical metadata query in " + (System.currentTimeMillis() - t1) + " ms");
} else {
this.supportSkipURITable = false;
if (caomTapResourceID != null) {
// source is a TAP resource ID
AuthMethod authMethod = AuthenticationUtil.getAuthMethodFromCredentials(AuthenticationUtil.getCurrentSubject());
TapClient tapClient = new TapClient(caomTapResourceID);
try {
this.caomTapURL = tapClient.getSyncURL(authMethod);
} catch (ResourceNotFoundException ex) {
if (ex.getMessage().contains("with password")) {
throw new ResourceNotFoundException("TAP service for " + caomTapResourceID + " does not support password authentication.", ex);
}
}
}
// source is a TAP service URL or a TAP resource ID
String adql = "select distinct(a.uri), a.contentChecksum, a.contentLength, a.contentType, o.observationID, " + "a.productType, a.releaseType, p.dataRelease, p.metaRelease " + "from caom2.Artifact a " + "join caom2.Plane p on a.planeID = p.planeID " + "join caom2.Observation o on p.obsID = o.obsID " + "where o.collection='" + collection + "'";
log.debug("logical query: " + adql);
long start = System.currentTimeMillis();
result = query(caomTapURL, adql);
log.info("Finished caom2 query in " + (System.currentTimeMillis() - start) + " ms");
}
return result;
}
Aggregations