Search in sources :

Example 11 with PublicInterfaceNotFoundException

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;
}
Also used : JsonQueryObjectModelConverter(org.bimserver.database.queries.om.JsonQueryObjectModelConverter) ServerException(org.bimserver.shared.exceptions.ServerException) Query(org.bimserver.database.queries.om.Query) QueryPart(org.bimserver.database.queries.om.QueryPart) Include(org.bimserver.database.queries.om.Include) IOException(java.io.IOException) QueryException(org.bimserver.database.queries.om.QueryException) EOFException(java.io.EOFException) IfcModelInterfaceException(org.bimserver.emf.IfcModelInterfaceException) UserException(org.bimserver.shared.exceptions.UserException) ServiceException(org.bimserver.shared.exceptions.ServiceException) ObjectAlreadyExistsException(org.bimserver.plugins.ObjectAlreadyExistsException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) IOException(java.io.IOException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) IfcModelInterfaceException(org.bimserver.emf.IfcModelInterfaceException) QueryException(org.bimserver.database.queries.om.QueryException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) UserException(org.bimserver.shared.exceptions.UserException)

Example 12 with PublicInterfaceNotFoundException

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();
    }
}
Also used : Path(java.nio.file.Path) PluginManager(org.bimserver.plugins.PluginManager) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) PluginException(org.bimserver.shared.exceptions.PluginException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) MetaDataManager(org.bimserver.emf.MetaDataManager) BimServerClient(org.bimserver.client.BimServerClient) PluginException(org.bimserver.shared.exceptions.PluginException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)

Example 13 with PublicInterfaceNotFoundException

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);
            }
        }
    }
}
Also used : IdEObjectImpl(org.bimserver.emf.IdEObjectImpl) IdEObject(org.bimserver.emf.IdEObject) EEnum(org.eclipse.emf.ecore.EEnum) EClass(org.eclipse.emf.ecore.EClass) ServiceException(org.bimserver.shared.exceptions.ServiceException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) LowLevelInterface(org.bimserver.shared.interfaces.LowLevelInterface) EReference(org.eclipse.emf.ecore.EReference)

Example 14 with PublicInterfaceNotFoundException

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);
            }
        }
    });
}
Also used : SObjectType(org.bimserver.interfaces.objects.SObjectType) ServerException(org.bimserver.shared.exceptions.ServerException) SLongActionState(org.bimserver.interfaces.objects.SLongActionState) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) Date(java.util.Date) PluginException(org.bimserver.shared.exceptions.PluginException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) UserException(org.bimserver.shared.exceptions.UserException) ServerException(org.bimserver.shared.exceptions.ServerException) ServiceDescriptor(org.bimserver.models.store.ServiceDescriptor) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) UserException(org.bimserver.shared.exceptions.UserException)

Example 15 with PublicInterfaceNotFoundException

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();
    }
}
Also used : ServerException(org.bimserver.shared.exceptions.ServerException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) UserException(org.bimserver.shared.exceptions.UserException) IOException(java.io.IOException) SProject(org.bimserver.interfaces.objects.SProject) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException)

Aggregations

PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)38 SProject (org.bimserver.interfaces.objects.SProject)22 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)20 ServiceException (org.bimserver.shared.exceptions.ServiceException)20 IOException (java.io.IOException)19 ServerException (org.bimserver.shared.exceptions.ServerException)18 UserException (org.bimserver.shared.exceptions.UserException)18 BimServerClientException (org.bimserver.shared.exceptions.BimServerClientException)15 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)12 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)10 Path (java.nio.file.Path)9 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)8 JsonBimServerClientFactory (org.bimserver.client.json.JsonBimServerClientFactory)7 ChannelConnectionException (org.bimserver.shared.ChannelConnectionException)6 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)4 IfcModelInterface (org.bimserver.emf.IfcModelInterface)4 FileNotFoundException (java.io.FileNotFoundException)3 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3