Example usage for org.apache.commons.lang SerializationUtils deserialize

List of usage examples for org.apache.commons.lang SerializationUtils deserialize

Introduction

In this page you can find the example usage for org.apache.commons.lang SerializationUtils deserialize.

Prototype

public static Object deserialize(byte[] objectData) 

Source Link

Document

Deserializes a single Object from an array of bytes.

Usage

From source file:mitm.common.sms.hibernate.SMSGatewayDAO.java

/**
 * Converts the entity to an SMS instance.
 *//*from  w  w w.j  a  va  2s. c  o  m*/
public static SMS entityToSMS(SMSGatewayEntity entity) {
    SMS sms = null;

    if (entity != null) {
        Serializable data = null;

        if (entity.getData() != null) {
            data = (Serializable) SerializationUtils.deserialize(entity.getData());
        }

        sms = new SMSImpl(entity.getID(), entity.getPhoneNumber(), entity.getMessage(), data,
                entity.getDateCreated(), entity.getDateLastTry(), entity.getLastError());
    }

    return sms;
}

From source file:edu.illinois.cs.cogcomp.core.utilities.SerializationHelper.java

/**
 * Read a text annotation from a byte array. The byte array must be one that is generated by the
 * {@link #serializeTextAnnotationToBytes(TextAnnotation)} function. Uses Apache's
 * {@link SerializationUtils}.//from w w w .ja v  a 2 s .c o  m
 *
 * @param obj The byte array
 * @return A text annotation
 */
public static TextAnnotation deserializeTextAnnotationFromBytes(byte[] obj) {
    return (TextAnnotation) SerializationUtils.deserialize(obj);
}

From source file:com.doculibre.constellio.wicket.models.ReloadableEntityModel.java

@Override
protected final Object load() {
    ConstellioEntity result;//from w  ww  .j  a v a 2s .c o  m
    if (entityModel != null) {
        entity = (ConstellioEntity) entityModel.getObject();
        entityModel.detach();
        entityModel = null;
    } else if (serializedEntity != null) {
        entity = (ConstellioEntity) SerializationUtils.deserialize(serializedEntity);
        result = entity;
    }
    if (entity != null) {
        result = entity;
    } else {
        EntityManager entityManager = ConstellioPersistenceContext.getCurrentEntityManager();
        BaseCRUDServices<T> crudServices = new BaseCRUDServicesImpl<T>(entityClass, entityManager);
        if (id != null) {
            result = entity = crudServices.get(id);
        } else {
            result = null;
        }
    }
    if (serializedEntity != null) {
        serializedEntity = null;
    }
    return result;
}

From source file:com.autonomy.aci.client.services.impl.AbstractStAXProcessorTest.java

@Test
public void testReadObject() throws NoSuchFieldException, IllegalAccessException {
    AbstractStAXProcessor<?> abstractStAXProcessor = spy(AbstractStAXProcessor.class);

    final Field field = ReflectionTestUtils.getAccessibleField(AbstractStAXProcessor.class, "xmlInputFactory");
    assertThat(field.get(abstractStAXProcessor), is(notNullValue()));

    // Serialise then deserialise the spy and check the XMLInputFactory has been recreated...
    final byte[] serialisedSpy = SerializationUtils.serialize(abstractStAXProcessor);
    abstractStAXProcessor = (AbstractStAXProcessor<?>) SerializationUtils.deserialize(serialisedSpy);
    assertThat(field.get(abstractStAXProcessor), is(notNullValue()));
}

From source file:io.pravega.controller.store.host.ZKHostStore.java

@SuppressWarnings("unchecked")
private Map<Host, Set<Integer>> getCurrentHostMap() {
    try {// ww  w .j a va  2 s.co m
        return (Map<Host, Set<Integer>>) SerializationUtils.deserialize(zkClient.getData().forPath(zkPath));
    } catch (Exception e) {
        throw new HostStoreException("Failed to fetch segment container map from zookeeper", e);
    }
}

From source file:com.janrain.backplane2.server.dao.redis.RedisBusDAO.java

@Override
public BusConfig2 get(String id) throws BackplaneServerException {
    byte[] bytes = Redis.getInstance().get(getKey(id));
    if (bytes != null) {
        return (BusConfig2) SerializationUtils.deserialize(bytes);
    } else {//from ww  w.jav  a  2s .  c om
        return null;
    }
}

From source file:mitm.application.djigzo.james.EncryptedContainerTest.java

@SuppressWarnings("unchecked")
@Test//  w  ww .j  a v  a  2 s . com
public void testSerialize() throws Exception {
    EncryptedContainer<String> container = new EncryptedContainer<String>();

    container.set("123");

    byte[] serialized = SerializationUtils.serialize(container);

    container = (EncryptedContainer<String>) SerializationUtils.deserialize(serialized);

    assertEquals("123", container.get());
}

From source file:br.com.ufjf.labredes.rest.EleitorResource.java

@POST
@Path("/votar/{voto}")
public String votar(@PathParam("voto") String vote) {
    byte[] voto_decoded = Base64.getDecoder().decode(vote);
    SealedObject aux = (SealedObject) SerializationUtils.deserialize(voto_decoded);
    Voto voto = null;/* w w w. ja  va 2  s .com*/
    voto = (Voto) rsa.decrypt(aux, client_aes);

    Response ans = new Response();

    if (voto != null) {
        eleitorService.votar(voto.getCpf(), voto.getNumero());
        ans.Ok("Voto computado");
        //3.1 Responde
        byte[] data = SerializationUtils.serialize(rsa.encrypt(ans, client_aes));
        String retorno = Base64.getEncoder().encodeToString(data);
        return retorno;
    } else {
        ans.Error("Erro ao decriptar chave");
        //3.1 Responde
        byte[] data = SerializationUtils.serialize(rsa.encrypt(ans, client_aes));
        String retorno = Base64.getEncoder().encodeToString(data);
        return retorno;
    }
}

From source file:fr.inria.oak.paxquery.pact.io.XmlOutputFormat.java

@Override
public void configure(Configuration parameters) {
    super.configure(parameters);

    // read your own parameters
    String recordsSignatureEncoded = parameters.getString(PACTOperatorsConfiguration.NRSMD1_BINARY.toString(),
            null);/*  w  w  w  .  ja v  a2 s .c om*/
    byte[] recordsSignatureBytes = DatatypeConverter.parseBase64Binary(recordsSignatureEncoded);
    final NestedMetadata signature = (NestedMetadata) SerializationUtils.deserialize(recordsSignatureBytes);
    this.signature = signature;

    String applyConstructEncoded = parameters
            .getString(PACTOperatorsConfiguration.APPLY_CONSTRUCT_BINARY.toString(), null);
    byte[] applyConstructBytes = DatatypeConverter.parseBase64Binary(applyConstructEncoded);
    final ApplyConstruct apply = (ApplyConstruct) SerializationUtils.deserialize(applyConstructBytes);
    this.apply = apply;
}

From source file:com.janrain.backplane2.server.dao.redis.RedisBackplaneMessageDAO.java

@Override
public BackplaneMessage getLatestMessage() throws BackplaneServerException {
    Jedis jedis = null;//from  ww w  .  j  a v  a2 s  . co  m
    try {
        jedis = Redis.getInstance().getReadJedis();

        Set<byte[]> bytesList = jedis.zrange(V2_MESSAGES.getBytes(), -1, -1);
        if (!bytesList.isEmpty()) {
            String args[] = new String(bytesList.iterator().next()).split(" ");
            byte[] bytes = jedis.get(getKey(args[2]));
            if (bytes != null) {
                return (BackplaneMessage) SerializationUtils.deserialize(bytes);
            }
        }
        return null;
    } finally {
        Redis.getInstance().releaseToPool(jedis);
    }
}