public Serializable getValue() throws IOException, ClassNotFoundException { if (value == null) { return null; } return Misc.deserialize(value); }
public Serializable getValue() throws IOException, ClassNotFoundException { if (value == null) { return null; } return Misc.deserialize(value); }
@SuppressWarnings("unchecked") public Command<T> getCommand() throws IOException, ClassNotFoundException{ return (Command<T>) Misc.deserialize(this.serializedCommand); }
@SuppressWarnings("unchecked") public Command<T> getCommand() throws IOException, ClassNotFoundException{ return (Command<T>) Misc.deserialize(this.serializedCommand); }
public Serializable getObject() throws IOException, ClassNotFoundException{ return Misc.deserialize(value); }
public Serializable getObject() throws IOException, ClassNotFoundException{ return Misc.deserialize(value); }
public Set<?> getSet(){ Set<?> ret = null; try { ret = (Set<?>) Misc.deserialize(this.value); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } return ret; }
public Set<?> getSet(){ Set<?> ret = null; try { ret = (Set<?>) Misc.deserialize(this.value); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } return ret; }
/** * @param decodeAndGather * @param contextProperties * @return * @throws ClassNotFoundException * @throws IOException */ public static Object deserialize(final byte[] buf, final Properties contextProperties) throws IOException, ClassNotFoundException { final Object res = deserialize(buf); if (res == null) { return null; } else if (res instanceof String && contextProperties != null) { return ProcessBuilder.resolveWithContext((String) res, contextProperties); } else if (res.getClass().isArray() && contextProperties != null) { final Object[] array = (Object[]) res; for (int i = 0; i < array.length; i++) { if (array[i] instanceof String) { array[i] = ProcessBuilder.resolveWithContext((String) array[i], contextProperties); } } return array; } else { return res; } }
@Override public BusinessArchive readFrom(final Class<BusinessArchive> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, final MultivaluedMap<String, String> httpHeaders, final InputStream entityStream) throws IOException, WebApplicationException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); Serializable serializable = null; try { readFromInputStream(entityStream, out); serializable = Misc.deserialize(out.toByteArray()); } catch (final ClassNotFoundException e) { if (LOG.isLoggable(Level.SEVERE)) { LOG.severe("Error while reading the InputStream: " + Misc.getStackTraceFrom(e)); } } catch (final IOException e) { if (LOG.isLoggable(Level.SEVERE)) { LOG.severe("Error while reading the InputStream: " + Misc.getStackTraceFrom(e)); } } finally { out.close(); } BusinessArchive businessArchive = null; if (serializable instanceof BusinessArchive) { businessArchive = (BusinessArchive) serializable; } return businessArchive; }
@Override @SuppressWarnings("unchecked") public T execute(final Environment environment) throws Exception { try { final ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Executing a command in remote mode. Looking for Class: " + this.className + ". Current ClassLoader: " + currentClassLoader); } Class.forName(this.className, true, currentClassLoader); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Executing a command in remote mode. Class: " + this.className + " found."); } final Command<T> command = (Command<T>) Misc.deserialize(this.serializedCommand); // execute command if (LOG.isLoggable(Level.FINE)) { LOG.fine("Executing a command in remote mode. Executing deserialized command: " + command); } return command.execute(environment); } catch (final ClassNotFoundException e) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Executing a command in remote mode. Class: " + this.className + " not found."); } final String message = ExceptionManager.getInstance().getFullMessage("baa_SC_1", this.className); throw new BonitaRuntimeException(message, e); } }
@SuppressWarnings("unchecked") private <T> T getData(final Class<T> clazz, final File file) { try { final byte[] value = Misc.getAllContentFrom(file); return (T) Misc.deserialize(value); } catch (final IOException e) { throw new BonitaRuntimeException(e); } catch (final ClassNotFoundException e) { throw new BonitaRuntimeException(e); } }
private void parseMultipleActivitiesInstantiator(final Element activityElement, final ProcessBuilder processBuilder, final Properties contextProperties) { final Element instantiatorElement = XmlUtil.element(activityElement, XmlDef.MULTIPLE_ACT_INSTANTIATOR); if (instantiatorElement != null && XmlUtil.element(instantiatorElement) != null) { final String instantiatorClassName = getChildTextContent(instantiatorElement, XmlDef.CLASSNAME); processBuilder.addMultipleActivitiesInstantiator(instantiatorClassName); final Element instantiatorParametersElement = XmlUtil.element(instantiatorElement, XmlDef.PARAMETERS); if (instantiatorParametersElement != null) { final List<Element> instantiatorParametersElements = XmlUtil.elements(instantiatorParametersElement, XmlDef.PARAMETER); if (instantiatorParametersElements != null) { for (final Element instantiatorParameterElement : instantiatorParametersElements) { try { final String key = instantiatorParameterElement.getAttribute(XmlDef.NAME); processBuilder.addInputParameter(key, (Object[]) Misc.deserialize( Misc.base64DecodeAndGather(instantiatorParameterElement.getTextContent()), contextProperties)); } catch (final Exception e) { throw new BonitaRuntimeException("Error while deserializing", e); } } } } } }
private void parseMultipleActivitiesInstantiator(final Element activityElement, final ProcessBuilder processBuilder, final Properties contextProperties) { final Element instantiatorElement = XmlUtil.element(activityElement, XmlDef.MULTIPLE_ACT_INSTANTIATOR); if (instantiatorElement != null && XmlUtil.element(instantiatorElement) != null) { final String instantiatorClassName = getChildTextContent(instantiatorElement, XmlDef.CLASSNAME); processBuilder.addMultipleActivitiesInstantiator(instantiatorClassName); final Element instantiatorParametersElement = XmlUtil.element(instantiatorElement, XmlDef.PARAMETERS); if (instantiatorParametersElement != null) { final List<Element> instantiatorParametersElements = XmlUtil.elements(instantiatorParametersElement, XmlDef.PARAMETER); if (instantiatorParametersElements != null) { for (final Element instantiatorParameterElement : instantiatorParametersElements) { try { final String key = instantiatorParameterElement.getAttribute(XmlDef.NAME); processBuilder.addInputParameter(key, (Object[]) Misc.deserialize( Misc.base64DecodeAndGather(instantiatorParameterElement.getTextContent()), contextProperties)); } catch (final Exception e) { throw new BonitaRuntimeException("Error while deserializing", e); } } } } } }
private void parseMultipleActivitiesJoinChecker(final Element activityElement, final ProcessBuilder processBuilder, final Properties contextProperties) { final Element joinCheckerElement = XmlUtil.element(activityElement, XmlDef.MULTIPLE_ACT_JOINCHECKER); if (joinCheckerElement != null && XmlUtil.element(joinCheckerElement) != null) { final String joinCheckerClassName = getChildTextContent(joinCheckerElement, XmlDef.CLASSNAME); processBuilder.addMultipleActivitiesJoinChecker(joinCheckerClassName); final Element joinCheckerParametersElement = XmlUtil.element(joinCheckerElement, XmlDef.PARAMETERS); if (joinCheckerParametersElement != null) { final List<Element> joinCheckerParametersElements = XmlUtil.elements(joinCheckerParametersElement, XmlDef.PARAMETER); if (joinCheckerParametersElements != null) { for (final Element joinCheckerParameterElement : joinCheckerParametersElements) { try { final String key = joinCheckerParameterElement.getAttribute(XmlDef.NAME); processBuilder.addInputParameter(key, (Object[]) Misc.deserialize( Misc.base64DecodeAndGather(joinCheckerParameterElement.getTextContent()), contextProperties)); } catch (final Exception e) { throw new BonitaRuntimeException("Error while deserializing", e); } } } } } }
private void parseMultipleActivitiesJoinChecker(final Element activityElement, final ProcessBuilder processBuilder, final Properties contextProperties) { final Element joinCheckerElement = XmlUtil.element(activityElement, XmlDef.MULTIPLE_ACT_JOINCHECKER); if (joinCheckerElement != null && XmlUtil.element(joinCheckerElement) != null) { final String joinCheckerClassName = getChildTextContent(joinCheckerElement, XmlDef.CLASSNAME); processBuilder.addMultipleActivitiesJoinChecker(joinCheckerClassName); final Element joinCheckerParametersElement = XmlUtil.element(joinCheckerElement, XmlDef.PARAMETERS); if (joinCheckerParametersElement != null) { final List<Element> joinCheckerParametersElements = XmlUtil.elements(joinCheckerParametersElement, XmlDef.PARAMETER); if (joinCheckerParametersElements != null) { for (final Element joinCheckerParameterElement : joinCheckerParametersElements) { try { final String key = joinCheckerParameterElement.getAttribute(XmlDef.NAME); processBuilder.addInputParameter(key, (Object[]) Misc.deserialize( Misc.base64DecodeAndGather(joinCheckerParameterElement.getTextContent()), contextProperties)); } catch (final Exception e) { throw new BonitaRuntimeException("Error while deserializing", e); } } } } } }
private void parseFilter(final Element activityElement, final ProcessBuilder processBuilder, final Properties contextProperties) { final Element filterElement = XmlUtil.element(activityElement, XmlDef.FILTER); if (filterElement != null && XmlUtil.elements(filterElement) != null && !XmlUtil.elements(filterElement).isEmpty()) { final String filterClassName = getChildTextContent(filterElement, XmlDef.CLASSNAME); final String filterDescription = getChildTextContent(filterElement, XmlDef.DESCRIPTION); processBuilder.addFilter(filterClassName); processBuilder.addDescription(filterDescription); final Element filterParametersElement = XmlUtil.element(filterElement, XmlDef.PARAMETERS); final List<Element> filterParameterElements = XmlUtil.elements(filterParametersElement, XmlDef.PARAMETER); if (filterParameterElements != null) { for (final Element filterParameterElement : filterParameterElements) { try { processBuilder.addInputParameter(filterParameterElement.getAttribute(XmlDef.NAME), (Object[]) Misc .deserialize(Misc.base64DecodeAndGather(filterParameterElement.getTextContent()), contextProperties)); } catch (final Exception e) { throw new BonitaRuntimeException("Error while deserializing", e); } } } } }
private void parseFilter(final Element activityElement, final ProcessBuilder processBuilder, final Properties contextProperties) { final Element filterElement = XmlUtil.element(activityElement, XmlDef.FILTER); if (filterElement != null && XmlUtil.elements(filterElement) != null && !XmlUtil.elements(filterElement).isEmpty()) { final String filterClassName = getChildTextContent(filterElement, XmlDef.CLASSNAME); final String filterDescription = getChildTextContent(filterElement, XmlDef.DESCRIPTION); processBuilder.addFilter(filterClassName); processBuilder.addDescription(filterDescription); final Element filterParametersElement = XmlUtil.element(filterElement, XmlDef.PARAMETERS); final List<Element> filterParameterElements = XmlUtil.elements(filterParametersElement, XmlDef.PARAMETER); if (filterParameterElements != null) { for (final Element filterParameterElement : filterParameterElements) { try { processBuilder.addInputParameter(filterParameterElement.getAttribute(XmlDef.NAME), (Object[]) Misc .deserialize(Misc.base64DecodeAndGather(filterParameterElement.getTextContent()), contextProperties)); } catch (final Exception e) { throw new BonitaRuntimeException("Error while deserializing", e); } } } } }
private void parseMultiInstantiation(final Element activityElement, final ProcessBuilder processBuilder, final Properties contextProperties) { final Element multiInstantiationElement = XmlUtil.element(activityElement, XmlDef.MULTI_INSTANTIATION); if (multiInstantiationElement != null && XmlUtil.elements(multiInstantiationElement) != null && !XmlUtil.elements(multiInstantiationElement).isEmpty()) { final String multiInstantiationClassName = getChildTextContent(multiInstantiationElement, XmlDef.CLASSNAME); final String multiInstantiationVariableName = getChildTextContent(multiInstantiationElement, XmlDef.VARIABLE_NAME); processBuilder.addMultiInstanciation(multiInstantiationVariableName, multiInstantiationClassName); final Element multiInstantiationParametersElement = XmlUtil.element(multiInstantiationElement, XmlDef.PARAMETERS); final List<Element> multiInstantiationParameterElements = XmlUtil.elements(multiInstantiationParametersElement, XmlDef.PARAMETER); if (multiInstantiationParameterElements != null) { for (final Element multiInstantiationParameterElement : multiInstantiationParameterElements) { try { processBuilder .addInputParameter(multiInstantiationParameterElement.getAttribute(XmlDef.NAME), (Object[]) Misc .deserialize(Misc.base64DecodeAndGather(multiInstantiationParameterElement.getTextContent()), contextProperties)); } catch (final Exception e) { throw new BonitaRuntimeException("Error while deserializing", e); } } } } }
private void parseMultiInstantiation(final Element activityElement, final ProcessBuilder processBuilder, final Properties contextProperties) { final Element multiInstantiationElement = XmlUtil.element(activityElement, XmlDef.MULTI_INSTANTIATION); if (multiInstantiationElement != null && XmlUtil.elements(multiInstantiationElement) != null && !XmlUtil.elements(multiInstantiationElement).isEmpty()) { final String multiInstantiationClassName = getChildTextContent(multiInstantiationElement, XmlDef.CLASSNAME); final String multiInstantiationVariableName = getChildTextContent(multiInstantiationElement, XmlDef.VARIABLE_NAME); processBuilder.addMultiInstanciation(multiInstantiationVariableName, multiInstantiationClassName); final Element multiInstantiationParametersElement = XmlUtil.element(multiInstantiationElement, XmlDef.PARAMETERS); final List<Element> multiInstantiationParameterElements = XmlUtil.elements(multiInstantiationParametersElement, XmlDef.PARAMETER); if (multiInstantiationParameterElements != null) { for (final Element multiInstantiationParameterElement : multiInstantiationParameterElements) { try { processBuilder .addInputParameter(multiInstantiationParameterElement.getAttribute(XmlDef.NAME), (Object[]) Misc .deserialize(Misc.base64DecodeAndGather(multiInstantiationParameterElement.getTextContent()), contextProperties)); } catch (final Exception e) { throw new BonitaRuntimeException("Error while deserializing", e); } } } } }