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:com.ephesoft.dcma.batch.dao.impl.BatchInstanceWorkflowDetailDaoImpl.java

@Override
public WorkflowDetailContainer getWorkflowContainer(final String batchInstanceIdentifier) {
    final String localFolderLocation = batchSchemaService.getLocalFolderLocation();
    String pathToPropertiesFolder = getPathToPropertiesFile(localFolderLocation);
    String workflowSerializedFileSuffix = EphesoftStringUtil.concatenate(ICommonConstants.UNDERSCORE,
            BatchConstants.WORKFLOWS_CONSTANT, FileType.SER.getExtensionWithDot());
    String serializedFilePath = EphesoftStringUtil.concatenate(pathToPropertiesFolder, File.separator,
            batchInstanceIdentifier, workflowSerializedFileSuffix);
    File batchInstanceSerializedFile = new File(serializedFilePath);
    WorkflowDetailContainer workflowContainer = null;
    boolean workflowContainerExist = isBatchSerializedfileExisting(batchInstanceIdentifier,
            workflowSerializedFileSuffix, serializedFilePath, batchInstanceSerializedFile);
    if (workflowContainerExist) {
        FileInputStream fileInputStream = null;
        try {/*  ww  w  . j a va2  s.com*/
            fileInputStream = new FileInputStream(batchInstanceSerializedFile);
            BufferedInputStream bufferedInputstream = new BufferedInputStream(fileInputStream);
            workflowContainer = (WorkflowDetailContainer) SerializationUtils.deserialize(bufferedInputstream);
        } catch (Exception exception) {
            LOGGER.error(exception, "Error during de-serializing the workflow properties for Batch instance: ",
                    batchInstanceIdentifier);
        } finally {
            try {
                if (null != fileInputStream) {
                    fileInputStream.close();
                }
            } catch (IOException ioException) {
                LOGGER.error(ioException, "Problem closing stream for workflows file :",
                        batchInstanceSerializedFile.getName());
            }
        }
    }
    return workflowContainer;
}

From source file:mitm.common.security.keystore.hibernate.SerializableKeyEntry.java

/**
 * Deserialize the serialized SerializableKeyEntry object.
 * //from   w ww  . j  a v  a  2 s . co m
 * @param serialized the serialized SerializableKeyEntry
 * @return a deserialized object
 * @throws UnrecoverableKeyException
 */
public static SerializableKeyEntry deserialize(byte[] serialized) throws UnrecoverableKeyException {
    Object o = SerializationUtils.deserialize(serialized);

    if (!(o instanceof SerializableKeyEntry)) {
        throw new UnrecoverableKeyException("The serialized is not the correct type.");
    }

    return (SerializableKeyEntry) o;
}

From source file:mitm.common.dlp.impl.PolicyViolationImplTest.java

@Test
public void testSerializeNulls() {
    PolicyViolation violation = new PolicyViolationImpl(null, null, null, null);

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

    assertEquals(SERIALIZED_NULLS, MiscStringUtils.toAsciiString((Base64.encodeBase64(serialized))));

    violation = (PolicyViolation) SerializationUtils.deserialize(serialized);
}

From source file:hws.util.ZkDataMonitor.java

public <T> T read(String path) throws KeeperException, InterruptedException {
    Stat stat = new Stat();
    byte[] data = this.zk.getData(path, false, stat);
    return (T) SerializationUtils.deserialize(data);
}

From source file:mitm.common.dlp.impl.PolicyViolationImplTest.java

@Test
public void testDeserializeNulls() {
    PolicyViolation violation = (PolicyViolation) SerializationUtils
            .deserialize(Base64.decodeBase64(MiscStringUtils.toAsciiBytes(SERIALIZED_NULLS)));

    assertNull(violation.getPolicy());//from   w w  w  .  ja  v a  2s  .  c om
    assertNull(violation.getRule());
    assertNull(violation.getMatch());
    assertNull(violation.getPriority());
}

From source file:io.pravega.controller.store.stream.InMemoryStream.java

private void handleStreamMetadataExists(final long timestamp, CompletableFuture<CreateStreamResponse> result,
        final long time, final StreamConfiguration config, Data<Integer> currentState) {
    if (currentState != null) {
        State stateVal = (State) SerializationUtils.deserialize(currentState.getData());
        if (stateVal.equals(State.UNKNOWN) || stateVal.equals(State.CREATING)) {
            CreateStreamResponse.CreateStatus status;
            status = (time == timestamp) ? CreateStreamResponse.CreateStatus.NEW
                    : CreateStreamResponse.CreateStatus.EXISTS_CREATING;
            result.complete(new CreateStreamResponse(status, config, time));
        } else {// w w w .  ja  v  a2s.  co m
            result.complete(
                    new CreateStreamResponse(CreateStreamResponse.CreateStatus.EXISTS_ACTIVE, config, time));
        }
    } else {
        CreateStreamResponse.CreateStatus status = (time == timestamp) ? CreateStreamResponse.CreateStatus.NEW
                : CreateStreamResponse.CreateStatus.EXISTS_CREATING;

        result.complete(new CreateStreamResponse(status, config, time));
    }
}

From source file:mitm.application.djigzo.james.mock.MockMail.java

@Override
public Serializable getAttribute(String name) {
    byte[] serialized = attributes.get(name);

    Serializable value = null;/*w w w  . j  a v a 2 s  .co  m*/

    if (serialized != null) {
        value = (Serializable) SerializationUtils.deserialize(serialized);
    }

    return value;
}

From source file:mitm.common.mail.MailAddressTest.java

@Test
public void testSerialize() throws Exception {
    MailAddress address = new MailAddress("test@example.com");

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

    MailAddress copy = (MailAddress) SerializationUtils.deserialize(serialized);

    assertEquals(address, copy);/*from www.  j  a  va  2 s  . com*/
}

From source file:com.impetus.ankush.common.domain.Service.java

@Transient
public HashMap<String, Object> getData() {
    if (getDataBytes() == null) {
        return null;
    }// w w  w .j  a  v a  2 s.  co  m
    return (HashMap<String, Object>) SerializationUtils.deserialize(getDataBytes());
}

From source file:io.pravega.common.cluster.zkImpl.ClusterZKImpl.java

/**
 * Get the current cluster members.// w w w  . ja va 2s  .  com
 *
 * @return List of cluster members.
 */
@Override
@Synchronized
public Set<Host> getClusterMembers() {
    if (!cache.isPresent()) {
        initializeCache();
    }
    List<ChildData> data = cache.get().getCurrentData();
    return data.stream().map(d -> (Host) SerializationUtils.deserialize(d.getData()))
            .collect(Collectors.toSet());
}