List of usage examples for org.apache.commons.lang SerializationUtils deserialize
public static Object deserialize(byte[] objectData)
Deserializes a single Object
from an array of bytes.
From source file:org.eqaula.glue.model.Property.java
public Object getValue() { if (getValueByteArray() == null) { return null; } else {/*w w w.j a v a2 s.c o m*/ return SerializationUtils.deserialize(getValueByteArray()); } }
From source file:org.gatherdata.archiver.dao.vfs.internal.VfsArchiverDao.java
public GatherArchive retrieveEnvelope(URI uid) { GatherArchive foundEnvelope = null;//from www .j a v a2 s . c om try { FileObject envelopeFile = fsManager.resolveFile(fsBase, uid.toASCIIString()); if (envelopeFile.exists()) { foundEnvelope = (GatherArchive) SerializationUtils .deserialize(envelopeFile.getContent().getInputStream()); } } catch (FileSystemException e) { e.printStackTrace(); } return foundEnvelope; }
From source file:org.gatherdata.archiver.dao.vfs.internal.VfsArchiverDao.java
public List<GatherArchive> getAll() { List<GatherArchive> allEnvelopes = new ArrayList<GatherArchive>(); try {//from w w w. ja v a2 s . c o m for (FileObject envelopeFile : fsBase.getChildren()) { allEnvelopes.add( (GatherArchive) SerializationUtils.deserialize(envelopeFile.getContent().getInputStream())); } } catch (FileSystemException e) { e.printStackTrace(); } return allEnvelopes; }
From source file:org.hydracache.client.partition.PartitionAwareClient.java
@Override public synchronized Object get(final String key) throws Exception { Identity identity = nodePartition.get(key); RequestMessage requestMessage = new RequestMessage(); requestMessage.setMethod(GET);/*www . ja v a2 s . com*/ requestMessage.setPath(key); ResponseMessage responseMessage = sendMessage(identity, requestMessage); Object object = null; if (responseMessage != null) { DataMessage dataMessage = protocolDecoder .decode(new DataInputStream(new ByteArrayInputStream(responseMessage.getResponseBody()))); updateVersion(key, dataMessage); object = SerializationUtils.deserialize(dataMessage.getBlob()); } return object; }
From source file:org.jasig.cas.adaptors.ldap.services.DefaultLdapServiceMapper.java
@Override public RegisteredService mapToRegisteredService(final LdapEntry entry) { final LdapAttribute attr = entry.getAttribute(this.serviceIdAttribute); if (attr != null) { final AbstractRegisteredService s = getRegisteredService(attr.getStringValue()); if (s != null) { s.setId(LdapUtils.getLong(entry, this.idAttribute, Long.valueOf(entry.getDn().hashCode()))); s.setServiceId(LdapUtils.getString(entry, this.serviceIdAttribute)); s.setName(LdapUtils.getString(entry, this.serviceNameAttribute)); s.setDescription(LdapUtils.getString(entry, this.serviceDescriptionAttribute)); s.setEnabled(LdapUtils.getBoolean(entry, this.serviceEnabledAttribute)); s.setTheme(LdapUtils.getString(entry, this.serviceThemeAttribute)); s.setEvaluationOrder(LdapUtils.getLong(entry, this.evaluationOrderAttribute).intValue()); s.setUsernameAttribute(LdapUtils.getString(entry, this.usernameAttribute)); s.setAnonymousAccess(LdapUtils.getBoolean(entry, this.serviceAnonymousAccessAttribute)); s.setSsoEnabled(LdapUtils.getBoolean(entry, this.serviceSsoEnabledAttribute)); s.setRequiredHandlers(//from ww w.java 2s.c o m new HashSet<String>(getMultiValuedAttributeValues(entry, this.requiredHandlersAttribute))); final byte[] data = LdapUtils.getBinary(entry, this.attributeReleasePolicyAttribute); if (data != null && data.length > 0) { final AttributeReleasePolicy policy = (AttributeReleasePolicy) SerializationUtils .deserialize(data); s.setAttributeReleasePolicy(policy); } final byte[] proxyData = LdapUtils.getBinary(entry, this.serviceProxyPolicyAttribute); if (proxyData != null && proxyData.length > 0) { final RegisteredServiceProxyPolicy policy = (RegisteredServiceProxyPolicy) SerializationUtils .deserialize(proxyData); s.setProxyPolicy(policy); } } return s; } return null; }
From source file:org.jasypt.properties.EncryptablePropertiesTest.java
public void testEncryptablePropertiesSerialization() throws Exception { final BasicTextEncryptor enc01 = new BasicTextEncryptor(); enc01.setPassword("jasypt"); final String msg01 = "Message one"; final String msgEnc01 = "ENC(eZpONwIfFb5muu5Dc8ABsTPu/0OP95p4)"; final String msg02 = "Message two"; final String msgEnc02 = "ENC(LKyQ65EYz3+ekDPpnLjLGyPK07Gt+UZH)"; final EncryptableProperties prop01 = new EncryptableProperties(enc01); prop01.setProperty("p1", msgEnc01); prop01.setProperty("p2", msgEnc02); Assert.assertEquals(prop01.getProperty("p1"), msg01); Assert.assertEquals(prop01.getProperty("p2"), msg02); final byte[] ser01 = SerializationUtils.serialize(prop01); final EncryptableProperties prop02 = (EncryptableProperties) SerializationUtils.deserialize(ser01); Assert.assertEquals(prop02.getProperty("p1"), msg01); Assert.assertEquals(prop02.getProperty("p2"), msg02); Assert.assertNotSame(prop01, prop02); }
From source file:org.jlibrary.servlet.service.HTTPStreamingServlet.java
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (logger.isDebugEnabled()) { logger.debug("Received a POST request"); }//from w w w . j a va2 s . c om try { InputStream stream = req.getInputStream(); byte[] count = read(stream, 4); int messageNameSize = ByteUtils.byteArrayToInt(count); byte[] messageNameBuffer = read(stream, messageNameSize); String callMethodName = new String(messageNameBuffer); Object returnValue = null; boolean streamOutput = false; boolean streamInput = false; if (callMethodName.equals("stream-input")) { // Streaming request. Re-read call method name streamInput = true; count = read(stream, 4); messageNameSize = ByteUtils.byteArrayToInt(count); messageNameBuffer = read(stream, messageNameSize); callMethodName = new String(messageNameBuffer); } else if (callMethodName.equals("stream-output")) { // Streaming request. Re-read call method name streamOutput = true; count = read(stream, 4); messageNameSize = ByteUtils.byteArrayToInt(count); messageNameBuffer = read(stream, messageNameSize); callMethodName = new String(messageNameBuffer); } if (logger.isDebugEnabled()) { logger.debug("Calling method: " + callMethodName); } // Handle request count = read(stream, 4); int parameters = ByteUtils.byteArrayToInt(count); Object[] params = new Object[parameters]; if (!streamInput && !streamOutput) { params = new Object[parameters]; } else { params = new Object[parameters + 1]; if (streamInput) { params[parameters] = stream; } else if (streamOutput) { params[parameters] = resp.getOutputStream(); } } for (int i = 0; i < parameters; i++) { count = read(stream, 4); int parameterSize = ByteUtils.byteArrayToInt(count); byte[] parameterBuffer = read(stream, parameterSize); params[i] = SerializationUtils.deserialize(parameterBuffer); } try { if (!streamInput && !streamOutput) { returnValue = handleRequest(req, callMethodName, params); } else if (streamInput) { returnValue = handleRequest(req, callMethodName, params, InputStream.class); } else if (streamOutput) { returnValue = handleRequest(req, callMethodName, params, OutputStream.class); } } catch (InvocationTargetException ite) { returnValue = ite.getCause(); if (returnValue == null) { returnValue = ite.getTargetException(); } } catch (Exception e) { returnValue = e; } if (!streamOutput) { handleReturnValue(resp, returnValue); } } catch (IOException e) { logger.error("IOException in doPost", e); } catch (Exception e) { logger.error("Exception in doPost", e); } finally { if (logger.isDebugEnabled()) { logger.debug("POST request handled successfully"); } } }
From source file:org.kiji.mapreduce.input.TestKijiTableMapReduceJobInput.java
@Test public void testConfigure() throws IOException { final Job job = new Job(); // Request the latest 3 versions of column 'info:email': KijiDataRequestBuilder builder = KijiDataRequest.builder(); builder.newColumnsDef().withMaxVersions(3).add("info", "email"); KijiDataRequest dataRequest = builder.build(); // Read from 'here' to 'there': final EntityId startRow = HBaseEntityId.fromHBaseRowKey(Bytes.toBytes("here")); final EntityId limitRow = HBaseEntityId.fromHBaseRowKey(Bytes.toBytes("there")); final KijiRowFilter filter = new StripValueRowFilter(); final KijiTableMapReduceJobInput.RowOptions rowOptions = KijiTableMapReduceJobInput.RowOptions .create(startRow, limitRow, filter); final MapReduceJobInput kijiTableJobInput = new KijiTableMapReduceJobInput(mTable.getURI(), dataRequest, rowOptions);//w ww . j av a2s.co m kijiTableJobInput.configure(job); // Check that the job was configured correctly. final Configuration conf = job.getConfiguration(); assertEquals(mTable.getURI(), KijiURI.newBuilder(conf.get(KijiConfKeys.KIJI_INPUT_TABLE_URI)).build()); final KijiDataRequest decoded = (KijiDataRequest) SerializationUtils .deserialize(Base64.decodeBase64(conf.get(KijiConfKeys.KIJI_INPUT_DATA_REQUEST))); assertEquals(dataRequest, decoded); final String confStartRow = Base64.encodeBase64String(startRow.getHBaseRowKey()); final String confLimitRow = Base64.encodeBase64String(limitRow.getHBaseRowKey()); assertEquals(confStartRow, conf.get(KijiConfKeys.KIJI_START_ROW_KEY)); assertEquals(confLimitRow, conf.get(KijiConfKeys.KIJI_LIMIT_ROW_KEY)); assertEquals(filter.toJson().toString(), conf.get(KijiConfKeys.KIJI_ROW_FILTER)); }
From source file:org.kiji.scoring.batch.impl.ScoreFunctionMapper.java
/** * Extract and deserialize the client data request from the given Configuration. * * @param conf Hadoop Configuration from which to extract the client data request. * @return the client data request serialized in the given Configuration. *//*from w w w . ja v a 2 s. co m*/ private static KijiDataRequest getClientDataRequestFromConf(final Configuration conf) { final String base64DataRequest = conf.get(KijiConfKeys.KIJI_INPUT_DATA_REQUEST); Preconditions.checkNotNull(base64DataRequest, "ClientDataRequest could not be found in configuration."); final byte[] dataRequestBytes = Base64.decodeBase64(Bytes.toBytes(base64DataRequest)); return (KijiDataRequest) SerializationUtils.deserialize(dataRequestBytes); }
From source file:org.lsc.beans.SimpleBean.java
@SuppressWarnings("unchecked") public static SimpleBean from(CompositeData cd) { SimpleBean lb = new SimpleBean(); lb.setMainIdentifier((String) cd.get("mainIdentifier")); for (Entry<String, Set<Object>> entry : ((Map<String, Set<Object>>) SerializationUtils .deserialize((byte[]) cd.get("datasetsBytes"))).entrySet()) { lb.setDataset(entry.getKey(), entry.getValue()); }//from www. j av a 2 s. c o m return lb; }