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;
}
Aggregations