protected byte[] createTestPageContent(final String pageName, final String displayName, final String description) throws Exception { try { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ZipOutputStream zos = new ZipOutputStream(baos); zos.putNextEntry(new ZipEntry("Index.groovy")); zos.write("return \"\";".getBytes()); zos.putNextEntry(new ZipEntry("page.properties")); zos.write(("name=" + pageName + "\n" + "displayName=" + displayName + "\n" + "description=" + description + "\n").getBytes()); zos.closeEntry(); return baos.toByteArray(); } catch (final IOException e) { throw new BonitaException(e); } }
public static void clearRepo(final CommandAPI commandAPI) { final Map<String, Serializable> parameters = new HashMap<>(1); parameters.put("clear", true); try { commandAPI.execute(WAIT_SERVER_COMMAND, parameters); } catch (final BonitaException e) { // ok LOGGER.debug("error undeploying command (maybe already undeployed?) " + e.getMessage()); } }
@Override public String getMessage() { final StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(getUserNameMessage()); appendContextMessage(stringBuilder); stringBuilder.append(super.getMessage()); return stringBuilder.toString(); }
@Test public void newBonitaExceptionWithNullCauseShouldNotThrowNPE() { new BonitaException("any message", null); }
protected <T> T getAPI(final Class<T> apiClass) { ensureSessionExists(); try { final ClientInterceptor clientInterceptor = new ClientInterceptor(apiClass.getName(), getServerAPI(), session); @SuppressWarnings("unchecked") final T api = (T) Proxy.newProxyInstance(APIAccessor.class.getClassLoader(), new Class[] { apiClass }, clientInterceptor); return api; } catch (ServerAPIException | UnknownAPITypeException e) { throw new IllegalStateException(e.getMessage(), e); } }
@Override public String getMessage() { final StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(getUserNameMessage()); appendContextMessage(stringBuilder); stringBuilder.append(super.getMessage()); return stringBuilder.toString(); }
throw new BonitaException("Problem while searching for users involved in process instance through their manager", e);
protected <T> T getAPI(final Class<T> apiClass) { ensureSessionExists(); try { final ClientInterceptor clientInterceptor = new ClientInterceptor(apiClass.getName(), getServerAPI(), session); @SuppressWarnings("unchecked") final T api = (T) Proxy.newProxyInstance(APIAccessor.class.getClassLoader(), new Class[] { apiClass }, clientInterceptor); return api; } catch (ServerAPIException | UnknownAPITypeException e) { throw new IllegalStateException(e.getMessage(), e); } }
throw new BonitaException("Problem while searching for users involved in process instance through their manager", e);
public static void undeployCommand(final APISession apiSession) throws BonitaException { final CommandAPI commandAPI = TenantAPIAccessor.getCommandAPI(apiSession); try { commandAPI.unregister(WAIT_SERVER_COMMAND); commandAPI.unregister(ADD_HANDLER_COMMAND); LOGGER.debug("commands undeployed"); } catch (final BonitaException e) { // ok LOGGER.debug("error undeploying command (maybe already undeployed?) " + e.getMessage()); } }
/** * This methods serves the purpose to remove confusion between getAPI() when a session is mandatory, and this one, where no session is needed to access the * API class. * * @param apiClass the API to retrieve * @param <T> The type of the API, extending {@link org.bonitasoft.engine.api.LoginAPI} * @return the retrieved API * @throws IllegalStateException if the API cannot be retrieved. */ protected <T extends LoginAPI> T getLoginAPI(Class<T> apiClass) { try { final ClientInterceptor interceptor = new ClientInterceptor(apiClass.getName(), getServerAPI()); @SuppressWarnings("unchecked") final T api = (T) Proxy.newProxyInstance(APIAccessor.class.getClassLoader(), new Class[] { apiClass }, interceptor); return api; } catch (ServerAPIException | UnknownAPITypeException e) { throw new IllegalStateException(e.getMessage(), e); } }
/** * This methods serves the purpose to remove confusion between getAPI() when a session is mandatory, and this one, where no session is needed to access the * API class. * * @param apiClass the API to retrieve * @param <T> The type of the API, extending {@link org.bonitasoft.engine.api.LoginAPI} * @return the retrieved API * @throws IllegalStateException if the API cannot be retrieved. */ protected <T extends LoginAPI> T getLoginAPI(Class<T> apiClass) { try { final ClientInterceptor interceptor = new ClientInterceptor(apiClass.getName(), getServerAPI()); @SuppressWarnings("unchecked") final T api = (T) Proxy.newProxyInstance(APIAccessor.class.getClassLoader(), new Class[] { apiClass }, interceptor); return api; } catch (ServerAPIException | UnknownAPITypeException e) { throw new IllegalStateException(e.getMessage(), e); } }