Search in sources :

Example 6 with PublicInterfaceNotFoundException

use of org.bimserver.shared.exceptions.PublicInterfaceNotFoundException in project BIMserver by opensourceBIM.

the class TestProtocolBuffers method main.

public static void main(String[] args) {
    try {
        BimServerClientInterface client = LocalDevSetup.setupSoap("http://localhost:8080");
        System.out.println(client.getServiceInterface().getAllProjects(true, true));
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    }
}
Also used : ServiceException(org.bimserver.shared.exceptions.ServiceException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface)

Example 7 with PublicInterfaceNotFoundException

use of org.bimserver.shared.exceptions.PublicInterfaceNotFoundException in project BIMserver by opensourceBIM.

the class TestUploadDir method start.

private void start() {
    try {
        client = LocalDevSetup.setupJson("http://localhost:8080");
        client.getSettingsInterface().setGenerateGeometryOnCheckin(false);
        Path directory = Paths.get("d:\\testfiles");
        for (Path f : PathUtils.list(directory)) {
            process(f, null);
        }
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Path(java.nio.file.Path) ServiceException(org.bimserver.shared.exceptions.ServiceException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) IOException(java.io.IOException)

Example 8 with PublicInterfaceNotFoundException

use of org.bimserver.shared.exceptions.PublicInterfaceNotFoundException in project BIMserver by opensourceBIM.

the class SyndicationServlet method service.

@Override
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    if (request.getHeader("Origin") != null && !getBimServer().getServerSettingsCache().isHostAllowed(request.getHeader("Origin"))) {
        response.setStatus(403);
        return;
    }
    if (request.getHeader("Authorization") != null) {
        String authorization = request.getHeader("Authorization");
        String usernamePasswordEncoded = authorization.substring(6);
        String decodeBase64 = new String(Base64.decodeBase64(usernamePasswordEncoded.getBytes(Charsets.UTF_8)), Charsets.UTF_8);
        if (decodeBase64.equals(":")) {
            response.getWriter().print("Not authenticated");
            return;
        }
        String[] split = decodeBase64.split(":");
        String username = split[0];
        String password = split[1];
        String token = (String) getServletContext().getAttribute("token");
        ServiceMap serviceMap = null;
        try {
            if (token == null) {
                serviceMap = getBimServer().getServiceFactory().get(AccessMethod.SYNDICATION);
            } else {
                serviceMap = getBimServer().getServiceFactory().get(token, AccessMethod.SYNDICATION);
            }
            if (serviceMap.getAuthInterface().login(username, password) != null) {
                String requestURI = request.getRequestURI();
                response.setContentType("application/atom+xml");
                try {
                    if (requestURI.endsWith("/projects")) {
                        writeProjectsFeed(request, response, serviceMap);
                    } else if (requestURI.contains("/revisions")) {
                        writeRevisionsFeed(request, response, serviceMap);
                    } else if (requestURI.contains("/checkouts")) {
                        writeCheckoutsFeed(request, response, serviceMap);
                    }
                } catch (ServiceException e) {
                    response.setContentType("text/html");
                    response.getWriter().println(e.getUserMessage());
                } catch (FeedException e) {
                    LOGGER.error("", e);
                }
            } else {
                response.setStatus(401);
                response.setHeader("WWW-Authenticate", "Basic realm=\"Secure Area\"");
            }
        } catch (ServiceException e) {
            LOGGER.error("", e);
        } catch (PublicInterfaceNotFoundException e) {
            LOGGER.error("", e);
        }
    } else {
        response.setStatus(401);
        response.setHeader("WWW-Authenticate", "Basic realm=\"Secure Area\"");
    }
}
Also used : ServiceMap(org.bimserver.webservices.ServiceMap) ServiceException(org.bimserver.shared.exceptions.ServiceException) FeedException(com.rometools.rome.io.FeedException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)

Example 9 with PublicInterfaceNotFoundException

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

Example 10 with PublicInterfaceNotFoundException

use of org.bimserver.shared.exceptions.PublicInterfaceNotFoundException 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;
}
Also used : IdEObjectImpl(org.bimserver.emf.IdEObjectImpl) ServerException(org.bimserver.shared.exceptions.ServerException) IdEObject(org.bimserver.emf.IdEObject) HashMap(java.util.HashMap) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) IfcModelInterfaceException(org.bimserver.emf.IfcModelInterfaceException) QueryException(org.bimserver.database.queries.om.QueryException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) IdEObject(org.bimserver.emf.IdEObject) List(java.util.List) ArrayList(java.util.ArrayList) UserException(org.bimserver.shared.exceptions.UserException) EReference(org.eclipse.emf.ecore.EReference)

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