use of org.alfresco.transform.client.registry.TransformServiceRegistry in project alfresco-repository by Alfresco.
the class RenditionDefinitionRegistry2Impl method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
PropertyCheck.mandatory(this, "transformServiceRegistry", transformServiceRegistry);
PropertyCheck.mandatory(this, "timeoutDefault", timeoutDefault);
PropertyCheck.mandatory(this, "jsonObjectMapper", jsonObjectMapper);
// If we have a cronExpression it indicates that we will schedule reading.
if (cronExpression != null) {
PropertyCheck.mandatory(this, "initialAndOnErrorCronExpression", initialAndOnErrorCronExpression);
}
configFileFinder = new ConfigFileFinder(jsonObjectMapper) {
@Override
protected void readJson(JsonNode jsonNode, String readFromMessage, String baseUrl) throws IOException {
try {
JsonNode renditions = jsonNode.get("renditions");
if (renditions != null && renditions.isArray()) {
for (JsonNode rendition : renditions) {
RenditionDef def = jsonObjectMapper.convertValue(rendition, RenditionDef.class);
Map<String, String> map = new HashMap<>();
if (def.options != null) {
def.options.forEach(o -> map.put(o.name, o.value));
}
if (!map.containsKey(RenditionDefinition2.TIMEOUT)) {
map.put(RenditionDefinition2.TIMEOUT, timeoutDefault);
}
RenditionDefinition2 original = getRenditionDefinition(def.renditionName);
new RenditionDefinition2Impl(def.renditionName, def.targetMediaType, map, true, RenditionDefinitionRegistry2Impl.this);
if (original != null) {
log.debug(readFromMessage + " replaced the rendition " + def.renditionName);
}
}
}
} catch (IllegalArgumentException e) {
log.error("Error reading " + readFromMessage + " " + e.getMessage());
}
}
};
configScheduler.run(true, log, cronExpression, initialAndOnErrorCronExpression);
}
Aggregations