public RoleImpl(final String uuid, final String name) { super(); Misc.checkArgsNotNull(uuid, name); this.uuid = uuid; this.name = name; }
public MultiInstantiationDefinitionImpl(final String variableId, final String className, final Map<String, String> parameters) { Misc.badStateIfNull(className, "Cannot build an multiInstantiatorClass with a null class name"); Misc.badStateIfNull(variableId, "Cannot build an multiInstantiatorClass with a null variable id"); this.variableId = variableId; this.className = className; this.parameters = parameters; }
public BonitaException(String message, Throwable cause) { super(message + " cause:" + Misc.LINE_SEPARATOR + cause.getMessage() + Misc.LINE_SEPARATOR + Misc.getStackTraceFrom(cause)); }
public AttachmentInstanceImpl(final DocumentUUID attachmentUUID, String name, ProcessInstanceUUID processInstanceUUID, String author, Date versionDate) { Misc.checkArgsNotNull(name, processInstanceUUID, author, versionDate); this.attachmentUUID = attachmentUUID; this.name = name; this.processInstanceUUID = processInstanceUUID; this.author = author; this.versionDate = Misc.getTime(versionDate); }
public static byte[] getBusinessArchiveContent(final Map<String, byte[]> resources) throws IOException { Misc.checkArgsNotNull(resources); return Misc.generateJar(resources); }
public static byte[] generateJar(final Class<?>... classes) throws IOException { return Misc.generateJar(Misc.getResources(classes)); }
@Override public void recordInstanceEnded(final ProcessInstanceUUID instanceUUID, final String loggedInUserId) { Misc.checkArgsNotNull(instanceUUID); final InternalProcessInstance instanceRecord = getProcessInstance(instanceUUID); final String message = ExceptionManager.getInstance().getFullMessage("bsi_DJ_1", instanceUUID); Misc.badStateIfNull(instanceRecord, message); instanceRecord.setInstanceState(InstanceState.FINISHED, loggedInUserId); }
Misc.checkArgsNotNull(message, prefix); if (message.length() == 0) { return prefix; Misc.unreachableStatement("Ouch! How can it be that a StringReader throws an IOException?"); } finally { Misc.close(reader);
public MultiInstantiatorDescriptor(int joinNumber, List<Object> variableValues) { Misc.checkArgsNotNull(joinNumber, variableValues); Misc.badStateIfTrue(joinNumber <= 0, "The join number must be greater than 0"); Misc.badStateIfTrue(joinNumber > variableValues.size(), "The join number must be lesser than the number of variable values"); this.joinNumber = joinNumber; this.variableValues = variableValues; }
/** * Equivalent to {@link #getAllContentFrom(InputStream) getAllContentFrom(new * FileInputStream(file))}; * * @param file the file to read * @return the whole content of the file in a single String. * @throws IOException If an I/O exception occured */ public static byte[] getAllContentFrom(final File file) throws IOException { InputStream in = null; try { in = new FileInputStream(file); return Misc.getAllContentFrom(in); } finally { Misc.close(in); } }
@SuppressWarnings("unchecked") public static <T> T get(final Class<T> class1, final String key) { Misc.checkArgsNotNull(class1, key); final Object o = getEnv().get(key); String message = ExceptionManager.getInstance().getFullMessage("bis_ET_1", key); Misc.badStateIfNull(o, message); message = ExceptionManager.getInstance().getFullMessage("bis_ET_2", class1, o.getClass()); Misc.badStateIfFalse(class1.isAssignableFrom(o.getClass()), message); return (T) o; }
public static byte[] getBusinessArchiveContent(final URL xpdlURL, final Class< ? >... classes) throws IOException { Misc.checkArgsNotNull(xpdlURL); return getBusinessArchiveContent(xpdlURL.toString(), Misc.getAllContentFrom(xpdlURL), classes); }
public static byte[] getBusinessArchiveContent(final String xpdlFileName, final byte[] xpdlContent, final Class< ? >... classes) throws IOException { Misc.checkArgsNotNull(xpdlFileName, xpdlContent); Map<String, byte[]> resources = new HashMap<String, byte[]>(); resources.put(xpdlFileName, xpdlContent); if (classes != null && classes.length > 0) { resources.putAll(Misc.getResources(classes)); } return getBusinessArchiveContent(resources); } }
Misc.unreachableStatement(); content = Misc.getAllContentFrom(url); } catch (final IOException e) { throw new InvalidEnvironmentException("An IO error occurs while reading environment from: " + url
/** * This method throw an IllegalStateException if the given parameter is not * null * * @param valueToCheck the value to check * @param msg the message for the thrown exception * * @see IllegalStateException */ public static void badStateIfNotNull(final Object valueToCheck, final String msg) { Misc.badStateIfTrue(valueToCheck != null, msg); }
public static void unreachableStatement() { Misc.unreachableStatement("This statement should never be reached!"); }
@Override public void writeTo(final BusinessArchive t, final Class<?> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream) throws IOException, WebApplicationException { try { entityStream.write(Misc.serialize(t)); } catch (final ClassNotFoundException e) { if (LOG.isLoggable(Level.SEVERE)) { LOG.severe("Error while serializing the object: " + Misc.getStackTraceFrom(e)); } } catch (final IOException e) { if (LOG.isLoggable(Level.SEVERE)) { LOG.severe("Error while serializing the object: " + Misc.getStackTraceFrom(e)); } } }
/** * Return the whole underlying stream content into a single String. * * Warning: the whole content of stream will be kept in memory!! Use with * care! * * @param in the stream to read * @return the whole content of the stream in a single String. * @throws IOException if an I/O exception occured */ public static byte[] getAllContentFrom(final URL url) throws IOException { final InputStream in = url.openStream(); return Misc.getAllContentFrom(in); }
protected TaskInstanceImpl(TaskUUID taskUUID, Date createdDate) { super(taskUUID); NullCheckResult checkResult = Misc.findNull(taskUUID, createdDate); if (checkResult.hasNull()) { List<String> message = Misc.getStringFrom(checkResult, "taskUUID", "createdDate"); throw new IllegalArgumentException("These arguments are null: " + message); } this.createdDate = createdDate; }