use of org.bimserver.shared.exceptions.ServiceException in project BIMserver by opensourceBIM.
the class TestInstall method main.
public static void main(String[] args) {
ArrayList<String> pluginList = new ArrayList<>();
pluginList.add("C:/plugins/ifcplugins-0.0.15.jar");
try (BimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
BimServerClientInterface client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
for (String each : pluginList) {
try {
DataSource fds = new FileDataSource(new File(each));
DataHandler handler = new DataHandler(fds);
client.getPluginInterface().installPluginBundleFromFile(handler, true, true);
System.out.println("Plugin " + each + " successfully installed !");
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (BimServerClientException e1) {
e1.printStackTrace();
} catch (ServiceException e1) {
e1.printStackTrace();
} catch (ChannelConnectionException e1) {
e1.printStackTrace();
} catch (Exception e2) {
e2.printStackTrace();
}
}
use of org.bimserver.shared.exceptions.ServiceException 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.ServiceException 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.ServiceException in project BIMserver by opensourceBIM.
the class NotificationsManager method handleIncoming.
public void handleIncoming(JsonObject request) throws UserException, ConvertException, IOException {
// TODO copied code from JsonHandler
String interfaceName = request.get("interface").getAsString();
String methodName = request.get("method").getAsString();
SService sService = servicesMap.getByName(interfaceName);
if (sService == null) {
sService = servicesMap.getBySimpleName(interfaceName);
}
if (sService == null) {
throw new UserException("No service found with name " + interfaceName);
}
SMethod method = sService.getSMethod(methodName);
if (method == null) {
SMethod alternative = servicesMap.findMethod(methodName);
if (alternative == null) {
throw new UserException("Method " + methodName + " not found on " + interfaceName);
} else {
throw new UserException("Method " + methodName + " not found on " + interfaceName + " (suggestion: " + alternative.getService().getSimpleName() + ")");
}
}
KeyValuePair[] parameters = new KeyValuePair[method.getParameters().size()];
if (request.has("parameters")) {
JsonObject parametersJson = request.getAsJsonObject("parameters");
for (int i = 0; i < method.getParameters().size(); i++) {
SParameter parameter = method.getParameter(i);
if (parametersJson.has(parameter.getName())) {
parameters[i] = new KeyValuePair(parameter.getName(), converter.fromJson(parameter.getType(), parameter.getGenericType(), parametersJson.get(parameter.getName())));
} else {
LOGGER.error("Missing parameters: " + method.getName() + " -> " + parameter.getName());
}
}
} else {
throw new UserException("Missing 'parameters' field");
}
try {
method.invoke(sService.getInterfaceClass(), service, parameters);
} catch (ServiceException e) {
LOGGER.error("", e);
} catch (ReflectorException e) {
LOGGER.error("", e);
}
}
use of org.bimserver.shared.exceptions.ServiceException in project BIMserver by opensourceBIM.
the class LocalDevBimServerStarter method start.
public void start(int id, String address, String name, int port, int pbport, Path[] pluginDirectories, Path home) {
BimServerConfig config = new BimServerConfig();
if (home != null) {
config.setHomeDir(home);
} else {
config.setHomeDir(Paths.get("tmptestdata/home" + (id == -1 ? "" : id)));
}
config.setResourceFetcher(new LocalDevelopmentResourceFetcher(Paths.get("../")));
config.setStartEmbeddedWebServer(true);
config.setClassPath(System.getProperty("java.class.path"));
config.setLocalDev(true);
config.setEnvironment(Environment.LOCAL_DEV);
config.setPort(port);
config.setStartCommandLine(true);
config.setDevelopmentBaseDir(Paths.get("../BimServer"));
try {
fixLogging(config);
} catch (IOException e1) {
e1.printStackTrace();
}
bimServer = new BimServer(config);
bimServer.getVersionChecker().getLocalVersion().setDate(new Date());
bimServer.setEmbeddedWebServer(new EmbeddedWebServer(bimServer, config.getDevelopmentBaseDir(), config.isLocalDev()));
Logger LOGGER = LoggerFactory.getLogger(LocalDevBimServerStarter.class);
try {
bimServer.start();
if (bimServer.getServerInfo().getServerState() == ServerState.MIGRATION_REQUIRED) {
bimServer.getServerInfoManager().registerStateChangeListener(new StateChangeListener() {
@Override
public void stateChanged(ServerState oldState, ServerState newState) {
if (oldState == ServerState.MIGRATION_REQUIRED && newState == ServerState.RUNNING) {
try {
LocalDevPluginLoader.loadPlugins(bimServer.getPluginManager(), pluginDirectories);
} catch (PluginException e) {
LOGGER.error("", e);
}
}
}
});
} else if (bimServer.getServerInfo().getServerState() == ServerState.RUNNING || bimServer.getServerInfo().getServerState() == ServerState.NOT_SETUP) {
LocalDevPluginLoader.loadPlugins(bimServer.getPluginManager(), pluginDirectories);
try {
AdminInterface adminInterface = bimServer.getServiceFactory().get(new SystemAuthorization(1, TimeUnit.HOURS), AccessMethod.INTERNAL).get(AdminInterface.class);
adminInterface.setup("http://localhost:" + port, name, "My Description", "http://localhost:" + port + "/img/bimserver.png", "Administrator", "admin@bimserver.org", "admin");
SettingsInterface settingsInterface = bimServer.getServiceFactory().get(new SystemAuthorization(1, TimeUnit.HOURS), AccessMethod.INTERNAL).get(SettingsInterface.class);
settingsInterface.setCacheOutputFiles(false);
settingsInterface.setPluginStrictVersionChecking(false);
} catch (Exception e) {
// Ignore
}
bimServer.activateServices();
} else {
LOGGER.error("BIMserver did not startup correctly");
}
} 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);
}
}
Aggregations