// 1) Check authentication
String jobName = null;
ObjectId jobId = null;
CustomMapReduceJobPojo customJob = null;
BasicDBObject query = new BasicDBObject();
// (already authenticated by this point)
try {
jobId = new ObjectId(jobNameOrShareId);
query.put(CustomMapReduceJobPojo._id_, jobId);
customJob = CustomMapReduceJobPojo.fromDb(
MongoDbManager.getCustom().getLookup().findOne(query),
CustomMapReduceJobPojo.class);
}
catch (Exception e) {
// it's a job name
jobName = jobNameOrShareId;
query.put(CustomMapReduceJobPojo.jobtitle_, jobName);
customJob = CustomMapReduceJobPojo.fromDb(
MongoDbManager.getCustom().getLookup().findOne(query),
CustomMapReduceJobPojo.class);
}
if (null == customJob) {
throw new RuntimeException("Authentication failure or no matching custom job");
}
jobName = customJob.jobtitle;
jobId = customJob._id;
DBCollection cacheCollection = MongoDbManager.getCollection(customJob.getOutputDatabase(), customJob.outputCollection);
// 2) Do we already have this cache?
CustomCacheInJavascript cacheElement = _customCache.get(jobNameOrShareId);