Search in sources :

Example 1 with EmfSerializerDataSource

use of org.bimserver.plugins.serializers.EmfSerializerDataSource in project BIMserver by opensourceBIM.

the class LongDownloadOrCheckoutAction method convertModelToCheckoutResult.

protected SCheckoutResult convertModelToCheckoutResult(Project project, String username, IfcModelInterface model, RenderEnginePlugin renderEnginePlugin, DownloadParameters downloadParameters) throws UserException, NoSerializerFoundException {
    SCheckoutResult checkoutResult = new SCheckoutResult();
    checkoutResult.setSerializerOid(downloadParameters.getSerializerOid());
    if (model.isValid()) {
        checkoutResult.setProjectName(project.getName());
        checkoutResult.setRevisionNr(model.getModelMetaData().getRevisionId());
        try {
            Serializer serializer = getBimServer().getSerializerFactory().create(project, username, model, renderEnginePlugin, downloadParameters);
            if (serializer == null) {
                throw new UserException("Error, no serializer found " + downloadParameters.getSerializerOid());
            }
            if (getBimServer().getServerSettingsCache().getServerSettings().getCacheOutputFiles() && serializer.allowCaching()) {
                if (getBimServer().getDiskCacheManager().contains(downloadParameters)) {
                    checkoutResult.setFile(new CachingDataHandler(getBimServer().getDiskCacheManager(), downloadParameters));
                } else {
                    checkoutResult.setFile(new DataHandler(new CacheStoringEmfSerializerDataSource(serializer, model.getModelMetaData().getName(), getBimServer().getDiskCacheManager().startCaching(downloadParameters))));
                }
            } else {
                checkoutResult.setFile(new DataHandler(new EmfSerializerDataSource(serializer, model.getModelMetaData().getName())));
            }
        } catch (SerializerException e) {
            LOGGER.error("", e);
        }
    }
    return checkoutResult;
}
Also used : CacheStoringEmfSerializerDataSource(org.bimserver.plugins.serializers.CacheStoringEmfSerializerDataSource) SCheckoutResult(org.bimserver.interfaces.objects.SCheckoutResult) UserException(org.bimserver.shared.exceptions.UserException) DataHandler(javax.activation.DataHandler) SerializerException(org.bimserver.plugins.serializers.SerializerException) CacheStoringEmfSerializerDataSource(org.bimserver.plugins.serializers.CacheStoringEmfSerializerDataSource) EmfSerializerDataSource(org.bimserver.plugins.serializers.EmfSerializerDataSource) MessagingSerializer(org.bimserver.plugins.serializers.MessagingSerializer) Serializer(org.bimserver.plugins.serializers.Serializer)

Aggregations

DataHandler (javax.activation.DataHandler)1 SCheckoutResult (org.bimserver.interfaces.objects.SCheckoutResult)1 CacheStoringEmfSerializerDataSource (org.bimserver.plugins.serializers.CacheStoringEmfSerializerDataSource)1 EmfSerializerDataSource (org.bimserver.plugins.serializers.EmfSerializerDataSource)1 MessagingSerializer (org.bimserver.plugins.serializers.MessagingSerializer)1 Serializer (org.bimserver.plugins.serializers.Serializer)1 SerializerException (org.bimserver.plugins.serializers.SerializerException)1 UserException (org.bimserver.shared.exceptions.UserException)1