use of org.alfresco.service.cmr.repository.TransformationOptionLimits in project alfresco-repository by Alfresco.
the class TextToPdfContentTransformer method transformRemote.
@Override
protected void transformRemote(RemoteTransformerClient remoteTransformerClient, ContentReader reader, ContentWriter writer, TransformationOptions options, String sourceMimetype, String targetMimetype, String sourceExtension, String targetExtension, String targetEncoding) throws Exception {
String sourceEncoding = reader.getEncoding();
long timeoutMs = options.getTimeoutMs();
TransformationOptionLimits limits = getLimits(reader, writer, options);
TransformationOptionPair pageLimits = limits.getPagesPair();
int pageLimit = (int) pageLimits.getValue();
remoteTransformerClient.request(reader, writer, sourceMimetype, sourceExtension, targetExtension, timeoutMs, logger, "transformName", "textToPdf", "sourceMimetype", sourceMimetype, "targetMimetype", targetMimetype, "targetExtension", targetExtension, SOURCE_ENCODING, sourceEncoding, "pageLimit", String.valueOf(pageLimit));
}
use of org.alfresco.service.cmr.repository.TransformationOptionLimits in project alfresco-repository by Alfresco.
the class ProxyContentTransformer method transformInternal.
protected void transformInternal(ContentReader reader, ContentWriter writer, TransformationOptions options) throws Exception {
TransformationOptionLimits original = options.getLimits();
try {
// Combine the transformer's limit values into the options so they are available to the worker
options.setLimits(getLimits(reader, writer, options));
// Perform the transformation
this.worker.transform(reader, writer, options);
} finally {
options.setLimits(original);
}
}
use of org.alfresco.service.cmr.repository.TransformationOptionLimits in project alfresco-repository by Alfresco.
the class TransformerConfigLimits method newTransformationOptionLimits.
/**
* Creates a new TransformationOptionLimits for the use, transformer and mimetype combination,
* defaulting values from lower levels.
* @param wildCardLimits if not null this is a limit found using a wildcard so should
* form the basis of the new object.
*/
private TransformationOptionLimits newTransformationOptionLimits(String transformerName, String sourceMimetype, String targetMimetype, TransformationOptionLimits wildCardLimits, String use) {
int origLevel = getLevel(transformerName, sourceMimetype);
TransformationOptionLimits limits = new TransformationOptionLimits();
// defaults from the most general get used if there is not something more specific.
for (int level = 0; level < origLevel; level++) {
TransformationOptionLimits defaultLimits = level < 2 ? level == 0 ? // 0
getOrCreateTransformerOptionLimits(DEFAULT_TRANSFORMER, ANY, ANY, use) : // 1
getOrCreateTransformerOptionLimits(DEFAULT_TRANSFORMER, sourceMimetype, targetMimetype, use) : level == 2 ? // 2
getOrCreateTransformerOptionLimits(transformerName, ANY, ANY, use) : // 3
getOrCreateTransformerOptionLimits(transformerName, sourceMimetype, targetMimetype, use);
defaultLimits.defaultTo(limits);
}
if (wildCardLimits != null) {
wildCardLimits.defaultTo(limits);
}
debug("N", transformerName, sourceMimetype, targetMimetype, use, limits);
return limits;
}
use of org.alfresco.service.cmr.repository.TransformationOptionLimits in project alfresco-repository by Alfresco.
the class TransformerConfigLimits method getLimits.
/**
* See {@link TransformerConfig#getLimits(ContentTransformer, String, String, String)}.
*/
public TransformationOptionLimits getLimits(ContentTransformer transformer, String sourceMimetype, String targetMimetype, String use) {
String transformerName = (transformer == null) ? DEFAULT_TRANSFORMER : transformer.getName();
if (sourceMimetype == null) {
sourceMimetype = ANY;
}
if (targetMimetype == null) {
targetMimetype = ANY;
}
if (use == null) {
use = ANY;
}
debug(null, transformerName, sourceMimetype, targetMimetype, use, null);
String searchUse = uses.contains(use) ? use : ANY;
TransformationOptionLimits limits = getOrCreateTransformerOptionLimits(transformerName, sourceMimetype, targetMimetype, searchUse);
debug("S", transformerName, sourceMimetype, targetMimetype, use, limits);
return limits;
}
use of org.alfresco.service.cmr.repository.TransformationOptionLimits in project alfresco-repository by Alfresco.
the class TransformerConfigLimits method getOrCreateTransformerOptionLimits.
/**
* Returns the TransformationOptionLimits for the use, transformer and mimetype combination,
* creating and adding one if not already included.
*/
private TransformationOptionLimits getOrCreateTransformerOptionLimits(String transformerName, String sourceMimetype, String targetMimetype, String use) {
Map<String, DoubleMap<String, String, TransformationOptionLimits>> transformerLimits = limitsMap.get(use);
if (transformerLimits == null) {
transformerLimits = new ConcurrentHashMap<String, DoubleMap<String, String, TransformationOptionLimits>>();
limitsMap.put(use, transformerLimits);
}
DoubleMap<String, String, TransformationOptionLimits> mimetypeLimits = transformerLimits.get(transformerName);
if (mimetypeLimits == null) {
mimetypeLimits = new DoubleMap<String, String, TransformationOptionLimits>(ANY, ANY);
transformerLimits.put(transformerName, mimetypeLimits);
}
TransformationOptionLimits limits = mimetypeLimits.getNoWildcards(sourceMimetype, targetMimetype);
if (limits == null) {
// Try the wildcard version, and use any match as the basis for a new entry
limits = mimetypeLimits.get(sourceMimetype, targetMimetype);
limits = newTransformationOptionLimits(transformerName, sourceMimetype, targetMimetype, limits, use);
mimetypeLimits.put(sourceMimetype, targetMimetype, limits);
} else {
debug("G", transformerName, sourceMimetype, targetMimetype, use, limits);
}
return limits;
}
Aggregations