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();
}
}
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();
}
}
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\"");
}
}
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;
}
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;
}
Aggregations