org.alfresco.service.cmr.repository.MimetypeService Java Examples

The following examples show how to use org.alfresco.service.cmr.repository.MimetypeService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransformerPropertyGetter.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void appendUnconfiguredTransformerSettings(StringBuilder sb, MimetypeService mimetypeService,
        Set<String> alreadySpecified, List<ContentTransformer> availableTransformers,
        ContentTransformerRegistry transformerRegistry)
{
    boolean first = true;
    for (ContentTransformer transformer: transformerRegistry.getAllTransformers())
    {
        String name = transformer.getName();
        if (!alreadySpecified.contains(name))
        {
            if (first)
            {
                sb.append("\n");
                sb.append("# Transformers without extra configuration settings\n");
                sb.append("# =================================================\n\n");
                first = false;
            }
            else
            {
                sb.append('\n');
            }
            boolean available = availableTransformers.contains(transformer);
            sb.append(transformer.getComments(available));
        }
    }
}
 
Example #2
Source File: TransformerPropertyNameExtractorTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Mock up the responses from the mimetypeService so that it:
 * a) returns all the supplied mimetypes
 * b) returns the extension given the mimetype
 * c) returns the mimetype given the extension.
 * @param mimetypeService mimetype service
 * @param mimetypesAndExtensions sequence of mimetypes and extenstions.
 * @throws IllegalStateException if there is not an extension for every mimetype
 */
public static void mockMimetypes(MimetypeService mimetypeService, String... mimetypesAndExtensions)
{
    if (mimetypesAndExtensions.length % 2 != 0)
    {
        // Not using IllegalArgumentException as this is thrown by classes under test
        throw new java.lang.IllegalStateException("There should be an extension for every mimetype");
    }

    final Set<String> allMimetypes = new HashSet<String>();
    for (int i=0; i < mimetypesAndExtensions.length; i+=2)
    {
        allMimetypes.add(mimetypesAndExtensions[i]);
        when(mimetypeService.getExtension(mimetypesAndExtensions[i])).thenReturn(mimetypesAndExtensions[i+1]);
        when(mimetypeService.getMimetype(mimetypesAndExtensions[i+1])).thenReturn(mimetypesAndExtensions[i]);
    }
    when(mimetypeService.getMimetypes()).thenReturn(new ArrayList<String>(allMimetypes));
}
 
Example #3
Source File: ContentTransformerRegistryTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public DummyTransformer(
        MimetypeService mimetypeService,
        String name,
        TransformerDebug transformerDebug, TransformerConfig transformerConfig,
        ContentTransformerRegistry registry, String sourceMimetype, String targetMimetype, long transformationTime)
{
    super.setMimetypeService(mimetypeService);
    super.setTransformerDebug(transformerDebug);
    super.setTransformerConfig(transformerConfig);
    super.setRegistry(registry);
    this.sourceMimetype = sourceMimetype;
    this.targetMimetype = targetMimetype;
    this.transformationTime = transformationTime;
    setRegisterTransformer(true);
    setBeanName(name+'.'+System.currentTimeMillis()%100000);

    // register
    register();
}
 
Example #4
Source File: AbstractEmailMessageHandler.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Extracts the attachments from the given message and adds them to the space.  All attachments
 * are linked back to the original node that they are attached to.
 * 
 * @param spaceNodeRef      the space to add the documents into
 * @param nodeRef           the node to which the documents will be attached
 * @param message           the email message
 */
protected void addAttachments(NodeRef spaceNodeRef, NodeRef nodeRef, EmailMessage message)
{
    // Add attachments
    EmailMessagePart[] attachments = message.getAttachments();
    for (EmailMessagePart attachment : attachments)
    {
        String fileName = attachment.getFileName();

        InputStream contentIs = attachment.getContent();
        
        MimetypeService mimetypeService = getMimetypeService();
        String mimetype = mimetypeService.guessMimetype(fileName);
        String encoding = attachment.getEncoding();

        NodeRef attachmentNode = addAttachment(getNodeService(), spaceNodeRef, nodeRef, fileName);
        writeContent(attachmentNode, contentIs, mimetype, encoding);
    }
}
 
Example #5
Source File: TransformerPropertyNameExtractor.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Gets the extensions of the mimetypes that match the given expression.
 * However if the expression is "*", only the ANY ("*") extension is returned.
 * @param expression which may contain '*' to represent zero or more characters.
 * @param mimetypeService MimetypeService
 * @return the list of extensions of mimetypes that match
 */
List<String> getMatchingExtensionsFromMimetypes(
        String expression, MimetypeService mimetypeService)
{
    if (ANY.equals(expression))
    {
        return Collections.singletonList(ANY);
    }
    Pattern pattern = pattern(expression);
    List<String> matchingMimetypes = new ArrayList<String>(1);
    for (String mimetype : mimetypeService.getMimetypes())
    {
        if (pattern.matcher(mimetype).matches())
        {
            String ext = mimetypeService.getExtension(mimetype);
            matchingMimetypes.add(ext);
        }
    }
    return matchingMimetypes;
}
 
Example #6
Source File: AbstractLocalTransform.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
AbstractLocalTransform(String name, TransformerDebug transformerDebug,
                       MimetypeService mimetypeService, boolean strictMimeTypeCheck,
                       Map<String, Set<String>> strictMimetypeExceptions, boolean retryTransformOnDifferentMimeType,
                       Set<TransformOption> transformsTransformOptions,
                       LocalTransformServiceRegistry localTransformServiceRegistry)
{
    this.name = name;
    this.transformerDebug = transformerDebug;
    this.mimetypeService = mimetypeService;
    this.strictMimeTypeCheck = strictMimeTypeCheck;
    this.strictMimetypeExceptions = strictMimetypeExceptions;
    this.retryTransformOnDifferentMimeType = retryTransformOnDifferentMimeType;
    this.localTransformServiceRegistry = localTransformServiceRegistry;

    addOptionNames(transformsTransformOptionNames, transformsTransformOptions);
}
 
Example #7
Source File: TransformerConfigProperty.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Sets the transformer values created from system properties.  
 */
private void setValues(TransformerProperties transformerProperties, MimetypeService mimetypeService,
        String suffix, String defaultValue)
{
    values = new HashMap<String, DoubleMap<String, String, String>>();

    // Gets all the transformer, source and target combinations in properties that define
    // this value.
    Map<TransformerSourceTargetSuffixKey, TransformerSourceTargetSuffixValue> properties =
            getTransformerSourceTargetValuesMap(Collections.singletonList(suffix), true, true, false, transformerProperties, mimetypeService);

    // Add the system wide default if it does not exist, as we always need this one
    TransformerSourceTargetSuffixValue transformerSourceTargetValue = 
            new TransformerSourceTargetSuffixValue(DEFAULT_TRANSFORMER, ANY, ANY, suffix, null, defaultValue, mimetypeService);
    TransformerSourceTargetSuffixKey key = transformerSourceTargetValue.key();
    if (!properties.containsKey(key))
    {
        properties.put(key, transformerSourceTargetValue);
    }
    
    // Populate the transformer values
    for (TransformerSourceTargetSuffixValue property: properties.values())
    {
        DoubleMap<String, String, String> mimetypeValues = values.get(property.transformerName);
        if (mimetypeValues == null)
        {
            mimetypeValues = new DoubleMap<String, String, String>(ANY, ANY);
            values.put(property.transformerName, mimetypeValues);
        }
        mimetypeValues.put(property.sourceMimetype, property.targetMimetype, property.value);
    }
}
 
Example #8
Source File: VirtualFileFolderServiceExtensionTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private String addWildCardInName(String name, String mimetype)
{
    MimetypeService mimetypeService = ctx.getBean("mimetypeService",
                                                  MimetypeService.class);
    String extension = mimetypeService.getExtension(mimetype);
    return name.substring(0,
                          name.length() - (extension.length() + 1))
                    .concat("*." + extension);
}
 
Example #9
Source File: ACPExportPackageHandler.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Construct
 * 
 * @param destDir File
 * @param zipFile File
 * @param dataFile File
 * @param contentDir File
 * @param overwrite boolean
 * @param mimetypeService MimetypeService
 */
public ACPExportPackageHandler(File destDir, File zipFile, File dataFile, File contentDir, boolean overwrite, MimetypeService mimetypeService)
{
    try
    {
        // Ensure ACP file has appropriate ACP extension
        String zipFilePath = zipFile.getPath();
        if (!zipFilePath.endsWith("." + ACP_EXTENSION))
        {
            zipFilePath += (zipFilePath.charAt(zipFilePath.length() -1) == '.') ? ACP_EXTENSION : "." + ACP_EXTENSION;
        }

        File absZipFile = new File(destDir, zipFilePath);
        log("Exporting to package zip file " + absZipFile.getAbsolutePath());

        if (absZipFile.exists())
        {
            if (overwrite == false)
            {
                throw new ExporterException("Package zip file " + absZipFile.getAbsolutePath() + " already exists.");
            }
            log("Warning: Overwriting existing package zip file " + absZipFile.getAbsolutePath());
        }
        
        this.outputStream = new FileOutputStream(absZipFile);
        this.dataFile = dataFile;
        this.contentDir = contentDir;
        this.mimetypeService = mimetypeService;
    }
    catch (FileNotFoundException e)
    {
        throw new ExporterException("Failed to create zip file", e);
    }
}
 
Example #10
Source File: DeduplicatingContentWriter.java    From alfresco-simple-content-stores with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setMimetypeService(final MimetypeService mimetypeService)
{
    this.mimetypeService = mimetypeService;
    super.setMimetypeService(mimetypeService);

    if (this.temporaryWriter instanceof MimetypeServiceAware)
    {
        ((MimetypeServiceAware) this.temporaryWriter).setMimetypeService(mimetypeService);
    }
}
 
Example #11
Source File: AbstractContentTransformerLimitsTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Before
public void setUp() throws Exception
{
    ApplicationContext ctx = MiscContextTestSuite.getMinimalContext();
    ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    MimetypeService mimetypeService = serviceRegistry.getMimetypeService();
    TransformerDebug transformerDebug = (TransformerDebug) ctx.getBean("transformerDebug");
    TransformerConfig transformerConfig = (TransformerConfig) ctx.getBean("transformerConfig");

    transformer = new AbstractContentTransformer2()
    {
        @Override
        public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype,
                TransformationOptions options)
        {
            return false;
        }

        @Override
        protected void transformInternal(ContentReader reader, ContentWriter writer,
                TransformationOptions options) throws Exception
        {
        }
    };
    transformer.setMimetypeService(mimetypeService);
    transformer.setTransformerDebug(transformerDebug);
    transformer.setTransformerConfig(transformerConfig);
    transformer.setBeanName("transformer.test"+System.currentTimeMillis()%100000);
    
    limits = new TransformationOptionLimits();
    options = new TransformationOptions();
}
 
Example #12
Source File: OpenOfficeContentNetworkFile.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Class constructor
 * 
 * @param nodeService NodeService
 * @param contentService ContentService
 * @param mimetypeService MimetypeService
 * @param nodeRef NodeRef
 * @param name String
 */
protected OpenOfficeContentNetworkFile(
        NodeService nodeService,
        ContentService contentService,
        MimetypeService mimetypeService,
        NodeRef nodeRef,
        String name)
{
    super(nodeService, contentService, mimetypeService, nodeRef, name);
    
    // DEBUG
    
    if (logger.isDebugEnabled())
        logger.debug("Using OpenOffice network file for " + name + ", versionLabel=" + nodeService.getProperty( nodeRef, ContentModel.PROP_VERSION_LABEL));
}
 
Example #13
Source File: MSOfficeContentNetworkFile.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Class constructor
 * 
 * @param nodeService NodeService
 * @param contentService ContentService
 * @param mimetypeService MimetypeService
 * @param nodeRef NodeRef
 * @param name String
 */
protected MSOfficeContentNetworkFile(
        NodeService nodeService,
        ContentService contentService,
        MimetypeService mimetypeService,
        NodeRef nodeRef,
        String name)
{
    super(nodeService, contentService, mimetypeService, nodeRef, name);

    // Create the buffered write list
    
    m_writeList = new ArrayList<BufferedWrite>(); 
}
 
Example #14
Source File: Export.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected @Override
/*package*/ int execute()
	throws ToolException
{
    ExporterService exporter = getServiceRegistry().getExporterService();
    MimetypeService mimetypeService = getServiceRegistry().getMimetypeService();

    // create export package handler
    ExportPackageHandler exportHandler = null;
    if (context.zipped)
    {
        exportHandler = new ZipHandler(context.getDestDir(), context.getZipFile(), context.getPackageFile(), context.getPackageDir(), context.overwrite, mimetypeService);
    }
    else
    {
        exportHandler = new FileHandler(context.getDestDir(), context.getPackageFile(), context.getPackageDir(), context.overwrite, mimetypeService);
    }

    // export Repository content to export package
    ExporterCrawlerParameters parameters = new ExporterCrawlerParameters();
    parameters.setExportFrom(context.getLocation());
    parameters.setCrawlSelf(context.self);
    parameters.setCrawlChildNodes(context.children);
    
    try
    {
        exporter.exportView(exportHandler, parameters, new ExportProgress());
    }
    catch(ExporterException e)
    {
        throw new ToolException("Failed to export", e);
    }
    
    return 0;
}
 
Example #15
Source File: AbstractRemoteContentTransformer.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void transformInternal(ContentReader reader, ContentWriter writer, TransformationOptions options)
        throws Exception
{
    if (remoteTransformerClientConfigured())
    {
        String sourceMimetype = getMimetype(reader);
        String targetMimetype = writer.getMimetype();
        String targetEncoding = writer.getEncoding();

        MimetypeService mimetypeService = getMimetypeService();
        String sourceExtension = mimetypeService.getExtension(sourceMimetype);
        String targetExtension = mimetypeService.getExtension(targetMimetype);
        if (sourceExtension == null || targetExtension == null)
        {
            throw new AlfrescoRuntimeException("Unknown extensions for mimetypes: \n" +
                    "   source mimetype: " + sourceMimetype + "\n" +
                    "   source extension: " + sourceExtension + "\n" +
                    "   target mimetype: " + targetMimetype + "\n" +
                    "   target extension: " + targetExtension + "\n" +
                    "   target encoding: " + targetEncoding);
        }

        transformRemote(remoteTransformerClient, reader, writer, options, sourceMimetype, targetMimetype,
                sourceExtension, targetExtension, targetEncoding);
    }
    else
    {
        transformLocal(reader, writer, options);
    }

    Log logger = getLogger();
    if (logger.isDebugEnabled())
    {
        logger.debug("Transformation completed: \n" +
                "   source: " + reader + "\n" +
                "   target: " + writer + "\n" +
                "   options: " + options);
    }
}
 
Example #16
Source File: EncryptingContentWriterFacade.java    From alfresco-simple-content-stores with Apache License 2.0 5 votes vote down vote up
/**
 * @param mimetypeService
 *            the mimetypeService to set
 */
@Override
public void setMimetypeService(final MimetypeService mimetypeService)
{
    super.setMimetypeService(mimetypeService);
    this.mimetypeService = mimetypeService;
}
 
Example #17
Source File: TransformerPropertyNameExtractor.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public TransformerSourceTargetSuffixValue(String transformerName, String sourceExt,
        String targetExt, String suffix, String use, String value, MimetypeService mimetypeService)
{
    super(transformerName, sourceExt, targetExt, suffix, use);
    
    this.value = value;
    this.sourceMimetype = ANY.equals(sourceExt) ? ANY : mimetypeService.getMimetype(sourceExt);
    this.targetMimetype = ANY.equals(targetExt) ? ANY : mimetypeService.getMimetype(targetExt);
}
 
Example #18
Source File: LocalFailoverTransform.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public LocalFailoverTransform(String name, TransformerDebug transformerDebug,
                              MimetypeService mimetypeService, boolean strictMimeTypeCheck,
                              Map<String, Set<String>> strictMimetypeExceptions,
                              boolean retryTransformOnDifferentMimeType,
                              Set<TransformOption> transformsTransformOptions,
                              LocalTransformServiceRegistry localTransformServiceRegistry)
{
    super(name, transformerDebug, mimetypeService, strictMimeTypeCheck, strictMimetypeExceptions,
            retryTransformOnDifferentMimeType, transformsTransformOptions, localTransformServiceRegistry);
}
 
Example #19
Source File: AlfrescoPdfRendererContentTransformerWorker.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void transform(ContentReader reader, ContentWriter writer, TransformationOptions options) throws Exception
{
    // get mimetypes
    String sourceMimetype = getMimetype(reader);
    String targetMimetype = getMimetype(writer);

    // get the extensions to use
    MimetypeService mimetypeService = getMimetypeService();
    String sourceExtension = mimetypeService.getExtension(sourceMimetype);
    String targetExtension = mimetypeService.getExtension(targetMimetype);
    if (sourceExtension == null || targetExtension == null)
    {
        throw new AlfrescoRuntimeException("Unknown extensions for mimetypes: \n" +
            "   source mimetype: " + sourceMimetype + "\n" +
            "   source extension: " + sourceExtension + "\n" +
            "   target mimetype: " + targetMimetype + "\n" +
            "   target extension: " + targetExtension);
    }

    if (remoteTransformerClientConfigured())
    {
        transformRemote(reader, writer, options, sourceMimetype, targetMimetype, sourceExtension, targetExtension);
    }
    else
    {
        transformLocal(reader, writer, options, sourceMimetype, targetMimetype, sourceExtension, targetExtension);
    }

    // done
    if (logger.isDebugEnabled())
    {
        logger.debug("Transformation completed: \n" +
            "   source: " + reader + "\n" +
            "   target: " + writer + "\n" +
            "   options: " + options);
    }
}
 
Example #20
Source File: LocalPassThroughTransform.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public LocalPassThroughTransform(String name, TransformerDebug transformerDebug,
                                 MimetypeService mimetypeService, boolean strictMimeTypeCheck,
                                 Map<String, Set<String>> strictMimetypeExceptions,
                                 boolean retryTransformOnDifferentMimeType,
                                 Set<TransformOption> transformsTransformOptions,
                                 LocalTransformServiceRegistry localTransformServiceRegistry)
{
    super(name, transformerDebug, mimetypeService, strictMimeTypeCheck, strictMimetypeExceptions,
            retryTransformOnDifferentMimeType, transformsTransformOptions, localTransformServiceRegistry);
}
 
Example #21
Source File: LocalTransformImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public LocalTransformImpl(String name, TransformerDebug transformerDebug,
                          MimetypeService mimetypeService, boolean strictMimeTypeCheck,
                          Map<String, Set<String>> strictMimetypeExceptions,
                          boolean retryTransformOnDifferentMimeType,
                          Set<TransformOption> transformsTransformOptions,
                          LocalTransformServiceRegistry localTransformServiceRegistry, String baseUrl,
                          int startupRetryPeriodSeconds)
{
    super(name, transformerDebug, mimetypeService, strictMimeTypeCheck, strictMimetypeExceptions,
            retryTransformOnDifferentMimeType, transformsTransformOptions, localTransformServiceRegistry);
    remoteTransformerClient = new RemoteTransformerClient(name, baseUrl);
    remoteTransformerClient.setStartupRetryPeriodSeconds(startupRetryPeriodSeconds);

    checkAvailability();
}
 
Example #22
Source File: TransformerConfigDynamicTransformers.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public TransformerConfigDynamicTransformers(TransformerConfig transformerConfig, TransformerProperties transformerProperties,
        MimetypeService mimetypeService, LegacySynchronousTransformClient legacySynchronousTransformClient, ContentTransformerRegistry transformerRegistry,
        TransformerDebug transformerDebug, ModuleService moduleService, DescriptorService descriptorService,
        Properties globalProperties)
{
    createDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient,
            transformerRegistry, transformerDebug, moduleService, descriptorService, globalProperties);
}
 
Example #23
Source File: LocalPipelineTransform.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public LocalPipelineTransform(String name, TransformerDebug transformerDebug,
                              MimetypeService mimetypeService, boolean strictMimeTypeCheck,
                              Map<String, Set<String>> strictMimetypeExceptions,
                              boolean retryTransformOnDifferentMimeType,
                              Set<TransformOption> transformsTransformOptions,
                              LocalTransformServiceRegistry localTransformServiceRegistry)
{
    super(name, transformerDebug, mimetypeService, strictMimeTypeCheck, strictMimetypeExceptions,
            retryTransformOnDifferentMimeType, transformsTransformOptions, localTransformServiceRegistry);
}
 
Example #24
Source File: TransformerPropertySetter.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public TransformerPropertySetter(TransformerProperties transformerProperties, MimetypeService mimetypeService,
        ContentTransformerRegistry transformerRegistry)
{
    this.transformerProperties = transformerProperties;
    this.mimetypeService = mimetypeService;
    this.transformerRegistry = transformerRegistry;
}
 
Example #25
Source File: ServiceDescriptorRegistry.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public MimetypeService getMimetypeService()
{
    return (MimetypeService)getService(MIMETYPE_SERVICE);
}
 
Example #26
Source File: TransformerPropertyGetter.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void appendTransformerSettings(StringBuilder sb, AtomicInteger start, String transformerName, StringBuilder prefix,
        StringBuilder general, StringBuilder mimetypes, MimetypeService mimetypeService, Set<String> alreadySpecified,
        List<ContentTransformer> availableTransformers, ContentTransformerRegistry transformerRegistry,
        boolean defaultTransformer, String header)
{
    if (start.get() == -1)
    {
        if (sb.length() != 0)
        {
            sb.append('\n');
        }
        sb.append(header);
        start.set(sb.length());
    }
    
    if (!defaultTransformer)
    {
        alreadySpecified.add(transformerName);
        ContentTransformer transformer;
        prefix.insert(0, '\n');
        try
        {
            transformer = transformerRegistry.getTransformer(transformerName);
            boolean available = availableTransformers.contains(transformer);
            prefix.insert(1, transformer.getComments(available));
        }
        catch (IllegalArgumentException e)
        {
            if (transformerName.startsWith(TransformerConfig.TRANSFORMER))
            {
                transformerName = transformerName.substring(TransformerConfig.TRANSFORMER.length());
            }
            prefix.insert(1, ContentTransformerHelper.getCommentName(transformerName)+"# Unregistered transformer\n");
            transformer = null;
        }
        
        sb.append(prefix.toString());
    }

    sb.append(general.toString());
    sb.append(mimetypes.toString());
    
    // Reset for next one
    prefix.setLength(0);
    general.setLength(0);
    mimetypes.setLength(0);
}
 
Example #27
Source File: JSONConversionComponent.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @param mimetypeService    mimetype service
 */
public void setMimetypeService(MimetypeService mimetypeService)
{
    this.mimetypeService = mimetypeService;
}
 
Example #28
Source File: TransformerPropertyGetter.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public TransformerPropertyGetter(boolean changesOnly, TransformerProperties transformerProperties,
        MimetypeService mimetypeService, ContentTransformerRegistry transformerRegistry,
        TransformerLog transformerLog, TransformerDebugLog transformerDebugLog)
{
    List<ContentTransformer> availableTransformers = transformerRegistry.getTransformers();
    StringBuilder sb = new StringBuilder();

    // Log entries
    appendLoggerSetting(sb, changesOnly, transformerLog, transformerDebugLog, transformerProperties);

    // Miscellaneous
    appendMiscellaneousSettings(sb, changesOnly, transformerProperties);

    // Default transformer
    Set<String> alreadySpecified = new HashSet<String>();
    appendConfiguredTransformerSettings(sb, changesOnly, transformerProperties, mimetypeService, availableTransformers,
            transformerRegistry, true, alreadySpecified,
            "# Default transformer settings\n" +
            "# ============================\n");
    
    // Other transformers with configuration properties
    appendConfiguredTransformerSettings(sb, changesOnly, transformerProperties, mimetypeService, availableTransformers,
            transformerRegistry, false, alreadySpecified,
            "# Transformers with configuration settings\n" +
            "# ========================================\n" +
            "# Commented out settings are hard coded values for information purposes\n");

    // Other transformers without configuration properties
    if (!changesOnly)
    {
        appendUnconfiguredTransformerSettings(sb, mimetypeService, alreadySpecified,
                availableTransformers, transformerRegistry);
    }
    
    if (sb.length() == 0)
    {
        sb.append(changesOnly
                ? "No custom transformer properties defined"
                : "No transformer properties defined");
    }

    string = sb.toString();
}
 
Example #29
Source File: AbstractContentTransformer.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @return Returns the mimetype helper
 */
protected MimetypeService getMimetypeService()
{
    return mimetypeService;
}
 
Example #30
Source File: MockedTestServiceRegistry.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public MimetypeService getMimetypeService()
{
    // A mock response
    return null;
}