// 1) Check authentication
String sourceKey = null;
ObjectId sourceId = null;
SourcePojo source = null;
BasicDBObject query = new BasicDBObject();
// (already authenticated by this point)
try {
sourceId = new ObjectId(sourceKeyOrId);
query.put(SourcePojo._id_, sourceId);
source = SourcePojo.fromDb(
MongoDbManager.getIngest().getSource().findOne(query),
SourcePojo.class);
}
catch (Exception e) {
// it's a job name
sourceKey = sourceKeyOrId;
query.put(SourcePojo.key_, sourceKey);
source = SourcePojo.fromDb(
MongoDbManager.getIngest().getSource().findOne(query),
SourcePojo.class);
}
if (null == source) {
throw new RuntimeException("Authentication failure or no matching source");
}
sourceKey = source.getKey();
sourceId = source.getId();
DBCollection cacheCollection = DbManager.getDocument().getMetadata();
// 2) Do we already have this cache?