use of com.google.samples.apps.iosched.server.schedule.server.image.ImageUpdater in project iosched by google.
the class CmsUpdateEndpoint method getDataFromCms.
/**
* Retrieve session data from CMS and make it ready for processing.
*
* @param user User making the request (injected by Endpoints)
* @throws UnauthorizedException
* @throws IOException
*/
@ApiMethod(name = "getDataFromCms", path = "topics")
public void getDataFromCms(User user) throws UnauthorizedException, IOException {
if (user == null || !isAllowed(user)) {
throw new UnauthorizedException("Invalid credentials");
}
// everything ok, let's update
StringBuilder summary = new StringBuilder();
JsonObject contents = new JsonObject();
JsonDataSources sources = new VendorDynamicInput().fetchAllDataSources();
for (String entity : sources) {
JsonArray array = new JsonArray();
JsonDataSource source = sources.getSource(entity);
for (JsonObject obj : source) {
array.add(obj);
}
summary.append(entity).append(": ").append(source.size()).append("\n");
contents.add(entity, array);
}
// Fetch new images and set up serving URLs.
new ImageUpdater().run(sources);
// Write file to cloud storage
CloudFileManager fileManager = new CloudFileManager();
fileManager.createOrUpdate("__raw_session_data.json", contents, true);
}
Aggregations