Web Script unit test base class added, helpers for JSON support in web scripts added (JSON reader, JSON error template), update to test webscript server to support easy submit of content, first cut of site service API (JS and HTTP) - create site and listSites available

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8950 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2008-04-29 10:45:00 +00:00
parent dbf9141c1c
commit c5733ca5ae
17 changed files with 988 additions and 181 deletions

View File

@@ -39,31 +39,6 @@ import org.alfresco.service.cmr.repository.TransformationOptions;
*/
public interface ContentTransformer extends ContentWorker
{
/**
* Transform option constants
*
* It is up to the transformation implementation whether these
* options are used, but they should be considered optional and their absence
* should not interfere with the execution of the transformer.
*/
//public static final String OPT_SOURCE_NODEREF = "sourceNodeRef";
//public static final String OPT_DESTINATION_NODEREF = "destinationNodeRef";
/**
* Provides the approximate accuracy with which this transformer can
* transform from one mimetype to another.
* <p>
* This method is used to determine, up front, which of a set of
* transformers will be used to perform a specific transformation.
*
* @param sourceMimetype the source mimetype
* @param targetMimetype the target mimetype
* @return Returns a score 0.0 to 1.0. 0.0 indicates that the
* transformation cannot be performed at all. 1.0 indicates that
* the transformation can be performed perfectly.
*/
//public double getReliability(String sourceMimetype, String targetMimetype);
/**
* Indicates whether the provided source mimetype can be transformed into the target mimetype with
* the options specified by this content transformer.
@@ -76,11 +51,16 @@ public interface ContentTransformer extends ContentWorker
public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options);
/**
* Indicates whether given the provided transformation parmaters this transformer can prvide an explict
* transformation.
*
* @param sourceMimetype
* @param targetMimetype
* @param options
* @return
* An explict transformation indicates that the transformation happens directly and not as a result of
* another transformation process. Explict transformation always take presidence over normal transformations.
*
* @param sourceMimetype the source mimetype
* @param targetMimetype the target mimetype
* @param options the transformation options
* @return boolean true if it is an explicit transformation, flase otherwise
*/
public boolean isExplicitTransformation(String sourceMimetype, String targetMimetype, TransformationOptions options);

View File

@@ -48,13 +48,6 @@ public class ContentTransformerRegistry
private static final Log logger = LogFactory.getLog(ContentTransformerRegistry.class);
private List<ContentTransformer> transformers;
/** Cache of previously used transactions */
//private Map<TransformationKey, List<ContentTransformer>> transformationCache;
/** Controls read access to the transformation cache */
//private Lock transformationCacheReadLock;
/** controls write access to the transformation cache */
//private Lock transformationCacheWriteLock;
/**
* @param mimetypeMap all the mimetypes available to the system
@@ -62,34 +55,8 @@ public class ContentTransformerRegistry
public ContentTransformerRegistry()
{
this.transformers = new ArrayList<ContentTransformer>(10);
//transformationCache = new HashMap<TransformationKey, List<ContentTransformer>>(17);
// create lock objects for access to the cache
//ReadWriteLock transformationCacheLock = new ReentrantReadWriteLock();
//transformationCacheReadLock = transformationCacheLock.readLock();
//transformationCacheWriteLock = transformationCacheLock.writeLock();
}
/**
* Register an individual transformer against a specific transformation. This transformation
* will take precedence over any of the generally-registered transformers.
*
* @param key the mapping from one mimetype to the next
* @param transformer the content transformer
*/
//public void addExplicitTransformer(TransformationKey key, ContentTransformer transformer)
//{
// transformationCache.put(key, Collections.singletonList(transformer));
// done
// if (logger.isDebugEnabled())
// {
// logger.debug("Registered explicit transformation: \n" +
// " key: " + key + "\n" +
// " transformer: " + transformer);
// }
// }
/**
* Registers an individual transformer that can be queried to check for applicability.
*
@@ -105,29 +72,6 @@ public class ContentTransformerRegistry
" transformer: " + transformer);
}
}
/**
* Resets the transformation cache. This allows a fresh analysis of the best
* conversions based on actual average performance of the transformers.
*/
// public void resetCache()
// {
// // get a write lock on the cache
// transformationCacheWriteLock.lock();
// try
// {
// transformationCache.clear();
// }
// finally
// {
// transformationCacheWriteLock.unlock();
// }
// // done
// if (logger.isDebugEnabled())
// {
// logger.debug("Content transformation cache reset");
// }
// }
/**
* Gets the best transformer possible. This is a combination of the most reliable
@@ -137,41 +81,9 @@ public class ContentTransformerRegistry
*/
public ContentTransformer getTransformer(String sourceMimetype, String targetMimetype, TransformationOptions options)
{
//TransformationKey key = new TransformationKey(sourceMimetype, targetMimetype);
List<ContentTransformer> transformers = null;
//transformationCacheReadLock.lock();
//try
//{
// if (transformationCache.containsKey(key))
// {
// the translation has been requested before
// it might have been null
// transformers = transformationCache.get(key);
// }
//}
// finally
// {
// transformationCacheReadLock.unlock();
// }
// if (transformers == null)
// {
// the translation has not been requested before
// get a write lock on the cache
// no double check done as it is not an expensive task
// transformationCacheWriteLock.lock();
// try
// {
// find the most suitable transformer - may be empty list
transformers = findTransformers(sourceMimetype, targetMimetype, options);
// store the result even if it is null
// transformationCache.put(key, transformers);
// }
// finally
// {
// transformationCacheWriteLock.unlock();
// }
//}
// Get the list of transformers
List<ContentTransformer> transformers = findTransformers(sourceMimetype, targetMimetype, options);
// select the most performant transformer
long bestTime = -1L;
ContentTransformer bestTransformer = null;
@@ -257,30 +169,6 @@ public class ContentTransformerRegistry
}
}
}
// double reliability = transformer.getReliability(sourceMimetype, targetMimetype);
// if (reliability <= 0.0)
// {
// // it is unusable
// continue;
// }
// else if (reliability < maxReliability)
// {
// // it is not the best one to use
// continue;
// }
// else if (reliability == maxReliability)
// {
// // it is as reliable as a previous transformer
// }
// else
// {
// // it is better than any previous transformer - wipe them
// bestTransformers.clear();
// maxReliability = reliability;
// }
// // add the transformer to the list
// bestTransformers.add(transformer);
}
// done
return transformers;