use of org.bimserver.longaction.DownloadParameters in project BIMserver by opensourceBIM.
the class ServiceImpl method checkout.
@Override
public Long checkout(Long roid, Long serializerOid, Boolean sync) throws ServerException, UserException {
requireAuthenticationAndRunningServer();
getAuthorization().canDownload(roid);
DatabaseSession session = getBimServer().getDatabase().createSession();
User user = null;
try {
SerializerPluginConfiguration serializerPluginConfiguration = (SerializerPluginConfiguration) session.get(serializerOid, OldQuery.getDefault());
// org.bimserver.plugins.serializers.Serializer serializer = getBimServer().getEmfSerializerFactory().get(serializerOid).createSerializer(new org.bimserver.plugins.serializers.PluginConfiguration());
if (serializerPluginConfiguration == null) {
throw new UserException("No serializer with id " + serializerOid + " could be found");
}
if (!serializerPluginConfiguration.getPluginDescriptor().getPluginClassName().equals("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin") && !serializerPluginConfiguration.getPluginDescriptor().getPluginClassName().equals("org.bimserver.ifc.xml.serializer.IfcXmlSerializerPlugin")) {
throw new UserException("Only IFC or IFCXML allowed when checking out");
}
DownloadParameters downloadParameters = new DownloadParameters(getBimServer(), DownloadType.DOWNLOAD_PROJECTS);
downloadParameters.setRoid(roid);
downloadParameters.setSerializerOid(serializerOid);
user = (User) session.get(StorePackage.eINSTANCE.getUser(), getAuthorization().getUoid(), OldQuery.getDefault());
LongDownloadOrCheckoutAction longDownloadAction = new LongCheckoutAction(getBimServer(), user.getName(), user.getUsername(), downloadParameters, getAuthorization(), getInternalAccessMethod());
try {
getBimServer().getLongActionManager().start(longDownloadAction);
} catch (CannotBeScheduledException e) {
LOGGER.error("", e);
}
if (sync) {
longDownloadAction.waitForCompletion();
}
return longDownloadAction.getProgressTopic().getKey().getId();
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.longaction.DownloadParameters in project BIMserver by opensourceBIM.
the class ServiceImpl method download.
@Override
public Long download(Set<Long> roids, String jsonQuery, Long serializerOid, Boolean sync) throws ServerException, UserException {
try {
User user = null;
DatabaseSession session = getBimServer().getDatabase().createSession();
Plugin plugin = null;
try {
SerializerPluginConfiguration serializerPluginConfiguration = session.get(StorePackage.eINSTANCE.getSerializerPluginConfiguration(), serializerOid, OldQuery.getDefault());
plugin = getBimServer().getPluginManager().getPlugin(serializerPluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
user = (User) session.get(StorePackage.eINSTANCE.getUser(), getAuthorization().getUoid(), OldQuery.getDefault());
} catch (BimserverDatabaseException e) {
throw new UserException(e);
} finally {
session.close();
}
if (plugin instanceof StreamingSerializerPlugin || plugin instanceof MessagingStreamingSerializerPlugin) {
LongStreamingDownloadAction longDownloadAction = new LongStreamingDownloadAction(getBimServer(), user == null ? "Unknown" : user.getName(), user == null ? "Unknown" : user.getUsername(), getAuthorization(), serializerOid, jsonQuery, roids);
try {
getBimServer().getLongActionManager().start(longDownloadAction);
} catch (Exception e) {
LOGGER.error("", e);
}
if (sync) {
longDownloadAction.waitForCompletion();
}
return longDownloadAction.getProgressTopic().getKey().getId();
} else if (plugin instanceof MessagingSerializerPlugin) {
requireAuthenticationAndRunningServer();
DownloadParameters downloadParameters = new DownloadParameters(getBimServer(), DownloadType.DOWNLOAD_BY_NEW_JSON_QUERY);
downloadParameters.setRoids(roids);
downloadParameters.setJsonQuery(jsonQuery);
downloadParameters.setSerializerOid(serializerOid);
return download(downloadParameters, sync);
} else if (plugin instanceof SerializerPlugin) {
requireAuthenticationAndRunningServer();
DownloadParameters downloadParameters = new DownloadParameters(getBimServer(), DownloadType.DOWNLOAD_BY_NEW_JSON_QUERY);
downloadParameters.setRoids(roids);
downloadParameters.setJsonQuery(jsonQuery);
downloadParameters.setSerializerOid(serializerOid);
return download(downloadParameters, sync);
} else {
throw new UserException("Unimplemented");
}
} catch (Exception e) {
return handleException(e);
}
}
use of org.bimserver.longaction.DownloadParameters in project BIMserver by opensourceBIM.
the class ServiceImpl method downloadCompareResults.
@Override
public Long downloadCompareResults(Long serializerOid, Long roid1, Long roid2, Long mcid, SCompareType type, Boolean sync) throws ServerException, UserException {
requireAuthenticationAndRunningServer();
DownloadParameters downloadParameters = new DownloadParameters(getBimServer(), DownloadType.DOWNLOAD_COMPARE);
downloadParameters.setModelCompareIdentifier(mcid);
downloadParameters.setCompareType(getBimServer().getSConverter().convertFromSObject(type));
downloadParameters.setSerializerOid(serializerOid);
Set<Long> roids = new LinkedHashSet<>();
roids.add(roid1);
roids.add(roid2);
downloadParameters.setRoids(roids);
return download(downloadParameters, sync);
}
Aggregations