use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.
the class BimServerClient method getGeometry.
@Override
public Geometry getGeometry(long roid, IdEObject ifcProduct) {
try {
SSerializerPluginConfiguration serializerByPluginClassName = getPluginInterface().getSerializerByPluginClassName("org.bimserver.serializers.binarygeometry.BinaryGeometrySerializerPlugin");
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
download(roid, serializerByPluginClassName.getOid(), outputStream);
Files.write(Paths.get("bin.bin"), outputStream.toByteArray());
ByteArrayInputStream bain = new ByteArrayInputStream(outputStream.toByteArray());
return new Geometry(bain, ifcProduct.getOid());
} catch (ServerException e) {
e.printStackTrace();
} catch (UserException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (BimServerClientException e) {
e.printStackTrace();
}
return null;
}
use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.
the class ClientIfcModel method branch.
@SuppressWarnings({ "unchecked", "rawtypes" })
public ClientIfcModel branch(long poid, boolean recordChanges) {
// TODO this should of course be done server side, without any copying
ClientIfcModel branch = new ClientIfcModel(bimServerClient, getPackageMetaData(), poid, recordChanges);
try {
loadDeep();
} catch (ServerException e) {
LOGGER.error("", e);
} catch (UserException e) {
LOGGER.error("", e);
} catch (PublicInterfaceNotFoundException e) {
LOGGER.error("", e);
} catch (QueryException e) {
LOGGER.error("", e);
}
Map<IdEObject, IdEObject> map = new HashMap<IdEObject, IdEObject>();
for (IdEObject sourceObject : getValues()) {
try {
IdEObjectImpl targetObject = branch.create(sourceObject.eClass());
targetObject.setLoadingState(State.LOADED);
map.put(sourceObject, targetObject);
} catch (IfcModelInterfaceException e) {
LOGGER.error("", e);
}
}
for (IdEObject sourceObject : getObjects().values()) {
IdEObject targetObject = map.get(sourceObject);
for (EStructuralFeature eStructuralFeature : sourceObject.eClass().getEAllStructuralFeatures()) {
Object sourceValue = sourceObject.eGet(eStructuralFeature);
if (eStructuralFeature instanceof EReference) {
if (eStructuralFeature.isMany()) {
List sourceList = (List) sourceValue;
List targetList = (List) targetObject.eGet(eStructuralFeature);
for (Object sourceItem : sourceList) {
IdEObject e = map.get(sourceItem);
if (e != null) {
targetList.add(e);
}
}
} else {
targetObject.eSet(eStructuralFeature, map.get(sourceValue));
}
} else {
if (eStructuralFeature.isMany()) {
List sourceList = (List) sourceValue;
List targetList = (List) targetObject.eGet(eStructuralFeature);
for (Object sourceItem : sourceList) {
targetList.add(sourceItem);
}
} else {
targetObject.eSet(eStructuralFeature, sourceValue);
}
}
}
}
branch.setModelState(ModelState.FULLY_LOADED);
return branch;
}
use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.
the class AddExtendedDataToProjectDatabaseAction method execute.
@Override
public Long execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
super.execute();
User actingUser = getUserByUoid(authorization.getUoid());
Project project = getProjectByPoid(poid);
if (project == null) {
throw new UserException("Project with poid " + poid + " not found");
}
project.getExtendedData().add(getIdEObject());
getDatabaseSession().store(project);
final ExtendedDataAddedToProject extendedDataAddedToProject = getDatabaseSession().create(ExtendedDataAddedToProject.class);
extendedDataAddedToProject.setAccessMethod(getAccessMethod());
extendedDataAddedToProject.setDate(new Date());
extendedDataAddedToProject.setExecutor(actingUser);
extendedDataAddedToProject.setExtendedData(getIdEObject());
extendedDataAddedToProject.setProject(project);
getDatabaseSession().addPostCommitAction(new PostCommitAction() {
@Override
public void execute() throws UserException {
bimServer.getNotificationsManager().notify(new SConverter().convertToSObject(extendedDataAddedToProject));
}
});
return null;
}
use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.
the class AddNewServiceToProjectDatabaseAction method execute.
@Override
public Long execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
Project project = getDatabaseSession().get(StorePackage.eINSTANCE.getProject(), poid, OldQuery.getDefault());
// service.setUser(user);
for (org.bimserver.models.store.Service existing : project.getServices()) {
if (existing.getName().equals(service.getName())) {
throw new UserException("Service name \"" + service.getName() + "\" already used in this project");
}
}
service.setAction(action);
service.setStatus(ServiceStatus.NEW);
if (service.getAuthorizationUrl() == null) {
service.setStatus(ServiceStatus.NO_AUTHENTICATION);
}
project.getNewServices().add(service);
service.setProject(project);
long serviceOid = getDatabaseSession().store(service);
getDatabaseSession().store(action);
getDatabaseSession().store(project);
return serviceOid;
}
use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.
the class AddServiceToProjectDatabaseAction method execute.
@Override
public Long execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
Project project = getDatabaseSession().get(StorePackage.eINSTANCE.getProject(), poid, OldQuery.getDefault());
User user = getDatabaseSession().get(StorePackage.eINSTANCE.getUser(), authorization.getUoid(), OldQuery.getDefault());
service.setUser(user);
for (org.bimserver.models.store.Service existing : project.getServices()) {
if (existing.getName().equals(service.getName())) {
throw new UserException("Service name \"" + service.getName() + "\" already used in this project");
}
}
project.getServices().add(service);
service.setProject(project);
long serviceOid = getDatabaseSession().store(service);
getDatabaseSession().store(project);
return serviceOid;
}
Aggregations