Search in sources :

Example 1 with ImportHandlerDto

use of org.pentaho.platform.plugin.services.importer.mimeType.bindings.ImportHandlerDto in project pentaho-platform by pentaho.

the class MimeTypeListFactory method createMimeTypeList.

public List<IMimeType> createMimeTypeList(String handlerClass) {
    List<IMimeType> mimeTypeList = new ArrayList<IMimeType>();
    for (ImportHandlerDto importHandler : importHandlerMimeTypeDefinitions.getImportHandler()) {
        if (importHandler.getClazz().equals(handlerClass)) {
            for (MimeTypeDefinitionDto mimeTypeDef : importHandler.getMimeTypeDefinitions().getMimeTypeDefinition()) {
                MimeType mimeType = new MimeType(mimeTypeDef.getMimeType(), mimeTypeDef.getExtension());
                mimeType.setHidden(mimeTypeDef.isHidden());
                mimeType.setLocale(mimeTypeDef.isLocale());
                mimeType.setVersionEnabled(mimeTypeDef.isVersionEnabled());
                mimeType.setVersionCommentEnabled(mimeTypeDef.isVersionCommentEnabled());
                Converter converter = null;
                String converterBeanName = mimeTypeDef.getConverter() != null && !mimeTypeDef.getConverter().isEmpty() ? mimeTypeDef.getConverter() : "streamConverter";
                converter = PentahoSystem.get(Converter.class, /*session*/
                null, Collections.singletonMap("name", converterBeanName));
                if (converter == null) {
                    log.error("Could not find converter class \"" + converterBeanName + "\" for mimeType \"" + mimeTypeDef.getMimeType() + "\" in import handler " + handlerClass);
                }
                mimeType.setConverter(converter);
                mimeTypeList.add(mimeType);
            }
        }
    }
    return mimeTypeList;
}
Also used : MimeTypeDefinitionDto(org.pentaho.platform.plugin.services.importer.mimeType.bindings.MimeTypeDefinitionDto) IMimeType(org.pentaho.platform.api.mimetype.IMimeType) ImportHandlerDto(org.pentaho.platform.plugin.services.importer.mimeType.bindings.ImportHandlerDto) ArrayList(java.util.ArrayList) Converter(org.pentaho.platform.api.repository2.unified.Converter) IMimeType(org.pentaho.platform.api.mimetype.IMimeType) MimeType(org.pentaho.platform.core.mimetype.MimeType)

Aggregations

ArrayList (java.util.ArrayList)1 IMimeType (org.pentaho.platform.api.mimetype.IMimeType)1 Converter (org.pentaho.platform.api.repository2.unified.Converter)1 MimeType (org.pentaho.platform.core.mimetype.MimeType)1 ImportHandlerDto (org.pentaho.platform.plugin.services.importer.mimeType.bindings.ImportHandlerDto)1 MimeTypeDefinitionDto (org.pentaho.platform.plugin.services.importer.mimeType.bindings.MimeTypeDefinitionDto)1