use of org.bimserver.shared.exceptions.PublicInterfaceNotFoundException in project BIMserver by opensourceBIM.
the class ClientIfcModel method getAll.
@Override
public <T extends IdEObject> List<T> getAll(EClass eClass) {
if (!loadedClasses.contains(eClass.getName()) && modelState != ModelState.FULLY_LOADED) {
LOGGER.info("Loading all " + eClass.getName());
try {
modelState = ModelState.LOADING;
Query query = new Query(getPackageMetaData());
QueryPart queryPart = query.createQueryPart();
queryPart.addType(eClass, false);
if (includeGeometry && getPackageMetaData().getEClass("IfcProduct").isSuperTypeOf(eClass)) {
Include include = queryPart.createInclude();
include.addType(eClass, false);
include.addField("geometry");
}
JsonQueryObjectModelConverter converter = new JsonQueryObjectModelConverter(getPackageMetaData());
long topicId = bimServerClient.getServiceInterface().download(Collections.singleton(roid), converter.toJson(query).toString(), getJsonSerializerOid(), false);
waitForDonePreparing(topicId);
processDownload(topicId);
bimServerClient.getServiceInterface().cleanupLongAction(topicId);
loadedClasses.add(eClass.getName());
rebuildIndexPerClass(eClass);
modelState = ModelState.NONE;
} catch (Exception e) {
LOGGER.error("", e);
}
}
List<T> result = super.getAll(eClass);
try {
if (modelState != ModelState.FULLY_LOADED) {
loadGeometry();
}
} catch (ServerException e) {
e.printStackTrace();
} catch (UserException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (QueryException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (GeometryException e) {
e.printStackTrace();
} catch (IfcModelInterfaceException e) {
e.printStackTrace();
}
return result;
}
use of org.bimserver.shared.exceptions.PublicInterfaceNotFoundException in project BIMserver by opensourceBIM.
the class TriggerImportDataRemote method main.
public static void main(String[] args) {
/*
* Args:
* 0: Address of new server
* 1: Username
* 2: Password
* 3: Address of old server
* 4: Local path to incoming folder of old server, this local path has to be available on the new server, so you have to copy it from the old server
*/
try {
Path home = Paths.get("home");
Path tmp = home.resolve("tmp");
PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(home);
MetaDataManager metaDataManager = new MetaDataManager(tmp);
pluginManager.setMetaDataManager(metaDataManager);
try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory(metaDataManager, args[0])) {
BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo(args[1], args[2]));
client.getServiceInterface().importData(args[3], args[1], args[2], args[4]);
} catch (Exception e) {
e.printStackTrace();
}
} catch (PluginException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
}
}
use of org.bimserver.shared.exceptions.PublicInterfaceNotFoundException in project BIMserver by opensourceBIM.
the class ClientIfcModel method set.
@Override
public void set(IdEObject idEObject, EStructuralFeature eFeature, Object newValue) {
if (!recordChanges) {
return;
}
if (!eFeature.isMany()) {
if (getModelState() != ModelState.LOADING && ((IdEObjectImpl) idEObject).getLoadingState() != State.LOADING) {
try {
if (newValue != EStructuralFeature.Internal.DynamicValueHolder.NIL) {
LowLevelInterface lowLevelInterface = getBimServerClient().getLowLevelInterface();
if (eFeature.getName().equals("wrappedValue")) {
// Wrapped objects get the same oid as their
// "parent" object, so we know which object the
// client wants to update. That's why we can use
// idEObject.getOid() here
// We are making this crazy hack ever crazier, let's
// iterate over our parents features, and see if
// there is one matching our wrapped type...
// Seriously, when there are multiple fields of the
// same type, this fails miserably, a real fix
// should probably store the parent-oid + feature
// name in the wrapped object (requires two extra,
// volatile, fields),
// or we just don't support this (just create a new
// wrapped object too), we could even throw some
// sort of exception. Hack morally okay because it's
// client-side...
EReference foundReference = null;
if (contains(idEObject.getOid())) {
IdEObject parentObject = get(idEObject.getOid());
int found = 0;
foundReference = null;
for (EReference testReference : parentObject.eClass().getEAllReferences()) {
if (((EClass) testReference.getEType()).isSuperTypeOf(idEObject.eClass())) {
foundReference = testReference;
found++;
if (found > 1) {
throw new RuntimeException("Sorry, crazy hack could not resolve the right field, please let BIMserver developer know (debug info: " + parentObject.eClass().getName() + ", " + idEObject.eClass().getName() + ")");
}
}
}
if (eFeature.getEType() == EcorePackage.eINSTANCE.getEString()) {
lowLevelInterface.setWrappedStringAttribute(getTransactionId(), idEObject.getOid(), foundReference.getName(), idEObject.eClass().getName(), (String) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getELong() || eFeature.getEType() == EcorePackage.eINSTANCE.getELongObject()) {
lowLevelInterface.setWrappedLongAttribute(getTransactionId(), idEObject.getOid(), foundReference.getName(), idEObject.eClass().getName(), (Long) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEDouble() || eFeature.getEType() == EcorePackage.eINSTANCE.getEDoubleObject()) {
lowLevelInterface.setWrappedDoubleAttribute(getTransactionId(), idEObject.getOid(), foundReference.getName(), idEObject.eClass().getName(), (Double) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEBoolean() || eFeature.getEType() == EcorePackage.eINSTANCE.getEBooleanObject()) {
lowLevelInterface.setWrappedBooleanAttribute(getTransactionId(), idEObject.getOid(), foundReference.getName(), idEObject.eClass().getName(), (Boolean) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEInt() || eFeature.getEType() == EcorePackage.eINSTANCE.getEIntegerObject()) {
lowLevelInterface.setWrappedIntegerAttribute(getTransactionId(), idEObject.getOid(), foundReference.getName(), idEObject.eClass().getName(), (Integer) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEByteArray()) {
throw new RuntimeException("Unimplemented " + eFeature.getEType().getName() + " " + newValue);
}
} else {
if (eFeature.getEType() == EcorePackage.eINSTANCE.getEString()) {
lowLevelInterface.setStringAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (String) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getELong() || eFeature.getEType() == EcorePackage.eINSTANCE.getELongObject()) {
lowLevelInterface.setLongAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Long) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEDouble() || eFeature.getEType() == EcorePackage.eINSTANCE.getEDoubleObject()) {
lowLevelInterface.setDoubleAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Double) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEBoolean() || eFeature.getEType() == EcorePackage.eINSTANCE.getEBooleanObject()) {
lowLevelInterface.setBooleanAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Boolean) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEInt() || eFeature.getEType() == EcorePackage.eINSTANCE.getEIntegerObject()) {
lowLevelInterface.setIntegerAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Integer) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEByteArray()) {
lowLevelInterface.setByteArrayAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Byte[]) newValue);
} else if (eFeature.getEType() instanceof EEnum) {
lowLevelInterface.setEnumAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), ((Enum<?>) newValue).toString());
} else if (eFeature instanceof EReference) {
if (newValue == null) {
lowLevelInterface.setReference(getTransactionId(), idEObject.getOid(), eFeature.getName(), -1L);
} else {
lowLevelInterface.setReference(getTransactionId(), idEObject.getOid(), eFeature.getName(), ((IdEObject) newValue).getOid());
}
} else {
throw new RuntimeException("Unimplemented " + eFeature.getEType().getName() + " " + newValue);
}
}
} else {
if (eFeature.getEType() == EcorePackage.eINSTANCE.getEString()) {
lowLevelInterface.setStringAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (String) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getELong() || eFeature.getEType() == EcorePackage.eINSTANCE.getELongObject()) {
lowLevelInterface.setLongAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Long) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEDouble() || eFeature.getEType() == EcorePackage.eINSTANCE.getEDoubleObject()) {
lowLevelInterface.setDoubleAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Double) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEBoolean() || eFeature.getEType() == EcorePackage.eINSTANCE.getEBooleanObject()) {
lowLevelInterface.setBooleanAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Boolean) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEInt() || eFeature.getEType() == EcorePackage.eINSTANCE.getEIntegerObject()) {
lowLevelInterface.setIntegerAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Integer) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEByteArray()) {
if (newValue instanceof byte[]) {
Byte[] n = new Byte[((byte[]) newValue).length];
for (int i = 0; i < n.length; i++) {
n[i] = ((byte[]) newValue)[i];
}
newValue = n;
}
lowLevelInterface.setByteArrayAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Byte[]) newValue);
} else if (eFeature.getEType() instanceof EEnum) {
lowLevelInterface.setEnumAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), ((Enum<?>) newValue).toString());
} else if (eFeature instanceof EReference) {
if (newValue == null) {
lowLevelInterface.setReference(getTransactionId(), idEObject.getOid(), eFeature.getName(), -1L);
} else {
lowLevelInterface.setReference(getTransactionId(), idEObject.getOid(), eFeature.getName(), ((IdEObject) newValue).getOid());
}
} else {
throw new RuntimeException("Unimplemented " + eFeature.getEType().getName() + " " + newValue);
}
}
}
} catch (ServiceException e) {
LOGGER.error("", e);
} catch (PublicInterfaceNotFoundException e) {
LOGGER.error("", e);
}
}
}
}
use of org.bimserver.shared.exceptions.PublicInterfaceNotFoundException in project BIMserver by opensourceBIM.
the class AbstractService method register.
@Override
public void register(long uoid, SInternalServicePluginConfiguration internalService, final PluginConfiguration pluginConfiguration) {
name = internalService.getName();
ServiceDescriptor serviceDescriptor = StoreFactory.eINSTANCE.createServiceDescriptor();
serviceDescriptor.setProviderName("BIMserver");
serviceDescriptor.setIdentifier("" + internalService.getOid());
serviceDescriptor.setName(internalService.getName());
serviceDescriptor.setDescription(internalService.getDescription());
serviceDescriptor.setNotificationProtocol(AccessMethod.INTERNAL);
serviceDescriptor.setTrigger(Trigger.NEW_REVISION);
addRequiredRights(serviceDescriptor);
serviceDescriptor.setReadRevision(true);
registerNewRevisionHandler(uoid, serviceDescriptor, new NewRevisionHandler() {
@Override
public void newRevision(BimServerClientInterface bimServerClientInterface, long poid, long roid, String userToken, long soid, SObjectType settings) throws ServerException, UserException {
try {
Long topicId = bimServerClientInterface.getRegistry().registerProgressOnRevisionTopic(SProgressTopicType.RUNNING_SERVICE, poid, roid, "Running " + name);
RunningService runningService = new RunningService(topicId, bimServerClientInterface, pluginConfiguration);
try {
SLongActionState state = new SLongActionState();
state.setProgress(getProgressType() == ProgressType.KNOWN ? 0 : -1);
state.setTitle(name);
state.setState(SActionState.STARTED);
state.setStart(runningService.getStartDate());
bimServerClientInterface.getRegistry().updateProgressTopic(topicId, state);
AbstractService.this.newRevision(runningService, bimServerClientInterface, poid, roid, userToken, soid, settings);
state = new SLongActionState();
state.setProgress(100);
state.setTitle(name);
state.setState(SActionState.FINISHED);
state.setStart(runningService.getStartDate());
state.setEnd(new Date());
bimServerClientInterface.getRegistry().updateProgressTopic(topicId, state);
} catch (BimServerClientException e) {
LOGGER.error("", e);
} catch (Exception e) {
LOGGER.error("", e);
} finally {
bimServerClientInterface.getRegistry().unregisterProgressTopic(topicId);
}
} catch (PublicInterfaceNotFoundException e) {
LOGGER.error("", e);
}
}
});
}
use of org.bimserver.shared.exceptions.PublicInterfaceNotFoundException in project BIMserver by opensourceBIM.
the class TestGuid method main.
public static void main(String[] args) {
BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
try {
SProject project = client.getServiceInterface().addProject("testProject2", "ifc2x3tc1");
Long tid = client.getLowLevelInterface().startTransaction(project.getOid());
client.getLowLevelInterface().createObject(tid, "IfcWall", false);
Long roid = client.getLowLevelInterface().commitTransaction(tid, "test commit");
SSerializerPluginConfiguration serializer = client.getServiceInterface().getSerializerByContentType("application/ifc");
client.download(roid, serializer.getOid(), Paths.get("test2.ifc"));
} catch (ServerException | UserException | PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (BimServerClientException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations