use of org.bimserver.shared.exceptions.ServiceException in project BIMserver by opensourceBIM.
the class TestAddExtendedData method start.
private void start() {
try {
BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
SFile file = new SFile();
file.setData("test".getBytes(Charsets.UTF_8));
file.setMime("text");
file.setFilename("test.txt");
long fileId = client.getServiceInterface().uploadFile(file);
System.out.println(client.getServiceInterface().getFile(fileId));
SProject project = client.getServiceInterface().addProject("test23", "ifc2x3tc1");
SDeserializerPluginConfiguration deserializerForExtension = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
client.checkin(project.getOid(), "initial", deserializerForExtension.getOid(), false, Flow.SYNC, Paths.get("../TestData/data/AC11-FZK-Haus-IFC.ifc"));
project = client.getServiceInterface().getProjectByPoid(project.getOid());
SExtendedDataSchema extendedDataSchemaByNamespace = client.getServiceInterface().getExtendedDataSchemaByName("http://extend.bimserver.org/validationreport");
SExtendedData extendedData = new SExtendedData();
extendedData.setFileId(fileId);
extendedData.setTitle("test3");
extendedData.setSchemaId(extendedDataSchemaByNamespace.getOid());
client.getServiceInterface().addExtendedDataToRevision(project.getLastRevisionId(), extendedData);
} catch (ServiceException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.bimserver.shared.exceptions.ServiceException in project BIMserver by opensourceBIM.
the class JsonHandler method handleThrowable.
private void handleThrowable(JsonWriter writer, Throwable throwable) {
if (!(throwable instanceof ServiceException)) {
LoggerFactory.getLogger(JsonHandler.class).error("", throwable);
} else {
if (LoggerFactory.getLogger(JsonHandler.class).isDebugEnabled()) {
LoggerFactory.getLogger(JsonHandler.class).debug("", throwable);
}
}
try {
writer.beginObject();
writer.name("exception");
writer.beginObject();
writer.name("__type");
writer.value(throwable.getClass().getSimpleName());
writer.name("message");
writer.value(throwable.getMessage() == null ? throwable.toString() : throwable.getMessage());
if (throwable instanceof ServiceException) {
ServiceException serviceException = (ServiceException) throwable;
if (serviceException.getErrorCode() != null) {
writer.name("errorCode");
writer.value(serviceException.getErrorCode().getCode());
}
}
writer.endObject();
writer.endObject();
} catch (IOException e) {
LOGGER.error("", e);
}
}
use of org.bimserver.shared.exceptions.ServiceException in project BIMserver by opensourceBIM.
the class LocalDevSetup method setupJson.
/**
* @param address
* @return
*/
@SuppressWarnings("resource")
public static final BimServerClientInterface setupJson(String address) {
try {
Path home = Paths.get("home");
if (!Files.isDirectory(home)) {
Files.createDirectory(home);
}
Path tmp = home.resolve("tmp");
if (!Files.isDirectory(tmp)) {
Files.createDirectory(tmp);
}
MavenPluginRepository mavenPluginRepository = new MavenPluginRepository();
PluginManager pluginManager = new PluginManager(tmp, System.getProperty("java.class.path"), null, null, null, null);
PluginBundleManager pluginBundleManager = new PluginBundleManager(pluginManager, mavenPluginRepository, home.resolve("plugins"));
pluginBundleManager.loadAllPluginsFromEclipseWorkspace(Paths.get("../"), true);
MetaDataManager metaDataManager = new MetaDataManager(tmp);
pluginManager.setMetaDataManager(metaDataManager);
metaDataManager.init(false);
pluginManager.initAllLoadedPlugins();
BimServerClientFactory factory = new JsonBimServerClientFactory(metaDataManager, address);
return factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
} catch (PluginException e) {
LOGGER.error("", e);
} catch (ServiceException e) {
LOGGER.error("", e);
} catch (ChannelConnectionException e) {
LOGGER.error("", e);
} catch (IOException e) {
LOGGER.error("", e);
} catch (BimServerClientException e) {
LOGGER.error("", e);
}
return null;
}
use of org.bimserver.shared.exceptions.ServiceException in project BIMserver by opensourceBIM.
the class LocalDevSetup method setupProtocolBuffers.
public static final BimServerClientInterface setupProtocolBuffers(String address) {
Path home = Paths.get("home");
Path tmp = home.resolve("tmp");
MetaDataManager metaDataManager = new MetaDataManager(tmp);
try (BimServerClientFactory factory = new ProtocolBuffersBimServerClientFactory(address, 8000, 8000, null, metaDataManager, new SServicesMap())) {
PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(home);
pluginManager.setMetaDataManager(metaDataManager);
return factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
} catch (PluginException e) {
LOGGER.error("", e);
} catch (ServiceException e) {
LOGGER.error("", e);
} catch (ChannelConnectionException e) {
LOGGER.error("", e);
} catch (BimServerClientException e) {
LOGGER.error("", e);
} catch (Exception e) {
LOGGER.error("", e);
}
return null;
}
use of org.bimserver.shared.exceptions.ServiceException in project BIMserver by opensourceBIM.
the class MemoryLeakTester method start.
public void start(int id, String address, int port, int pbport, Path[] pluginDirectories) {
BimServerConfig config = new BimServerConfig();
config.setHomeDir(Paths.get("home" + id));
config.setResourceFetcher(new LocalDevelopmentResourceFetcher(Paths.get("../")));
config.setStartEmbeddedWebServer(true);
config.setClassPath(System.getProperty("java.class.path"));
config.setStartCommandLine(false);
config.setLocalDev(true);
config.setPort(port);
bimServer = new BimServer(config);
bimServer.getVersionChecker().getLocalVersion().setDate(new Date());
try {
LocalDevPluginLoader.loadPlugins(bimServer.getPluginBundleManager(), pluginDirectories);
bimServer.start();
if (bimServer.getServerInfo().getServerState() == ServerState.NOT_SETUP) {
AdminInterface adminInterface = bimServer.getServiceFactory().get(new SystemAuthorization(1, TimeUnit.HOURS), AccessMethod.INTERNAL).get(AdminInterface.class);
adminInterface.setup("http://localhost:" + port, "Administrator", "admin@bimserver.org", "admin", null, null, null);
SettingsInterface settingsInterface = bimServer.getServiceFactory().get(new SystemAuthorization(1, TimeUnit.HOURS), AccessMethod.INTERNAL).get(SettingsInterface.class);
settingsInterface.setCacheOutputFiles(false);
}
bimServer.stop();
bimServer = null;
Thread.sleep(1000000);
} catch (PluginException e) {
LOGGER.error("", e);
} catch (ServiceException e) {
LOGGER.error("", e);
} catch (DatabaseInitException e) {
LOGGER.error("", e);
} catch (BimserverDatabaseException e) {
LOGGER.error("", e);
} catch (DatabaseRestartRequiredException e) {
LOGGER.error("", e);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Aggregations