org.apache.commons.lang.SerializationUtils Java Examples

The following examples show how to use org.apache.commons.lang.SerializationUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestPaymentGatewayImpl.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Payment reverseAuthorization(final Payment paymentIn, final boolean forceProcessing) {
    final Payment payment = (Payment) SerializationUtils.clone(paymentIn);
    payment.setTransactionOperation(REVERSE_AUTH);
    if (isParameterActivated(REVERSE_AUTH_FAIL) || isParameterActivated(REVERSE_AUTH_FAIL_NO + payment.getPaymentAmount().toPlainString())) {

        payment.setTransactionOperationResultCode("EXTERNAL_ERROR_CODE");
        payment.setTransactionOperationResultMessage("Card rejected exception. Reverse authorize for "  + payment.getPaymentAmount().toPlainString());
        payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_FAILED);
        payment.setPaymentProcessorBatchSettlement(false);

    } else {

        payment.setTransactionReferenceId(UUID.randomUUID().toString());
        payment.setTransactionGatewayLabel(getLabel());
        payment.setTransactionOperationResultCode("REVERSE_AUTH_OK");
        payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_OK);
        payment.setPaymentProcessorBatchSettlement(false);

    }

    return payment;
}
 
Example #2
Source File: AbstractNeuralNetwork.java    From incubator-retired-horn with Apache License 2.0 6 votes vote down vote up
@Override
public void write(DataOutput output) throws IOException {
  // write model type
  WritableUtils.writeString(output, modelType);
  // write learning rate
  output.writeFloat(learningRate);
  // write model path
  if (this.modelPath != null) {
    WritableUtils.writeString(output, modelPath);
  } else {
    WritableUtils.writeString(output, "null");
  }

  // serialize the class
  Class<? extends FloatFeatureTransformer> featureTransformerCls = this.featureTransformer
      .getClass();
  byte[] featureTransformerBytes = SerializationUtils
      .serialize(featureTransformerCls);
  output.writeInt(featureTransformerBytes.length);
  output.write(featureTransformerBytes);
}
 
Example #3
Source File: JdbcAccessorTest.java    From pxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testReadFromQueryWithPartitions() throws Exception {
    String serversDirectory = new File(this.getClass().getClassLoader().getResource("servers").toURI()).getCanonicalPath();
    context.getAdditionalConfigProps().put("pxf.config.server.directory", serversDirectory + File.separator + "test-server");
    context.setDataSource("query:testquery");
    context.addOption("PARTITION_BY", "count:int");
    context.addOption("RANGE", "1:10");
    context.addOption("INTERVAL", "1");
    context.setFragmentMetadata(SerializationUtils.serialize(PartitionType.INT.getFragmentsMetadata("count", "1:10", "1").get(2)));
    ArgumentCaptor<String> queryPassed = ArgumentCaptor.forClass(String.class);
    when(mockStatement.executeQuery(queryPassed.capture())).thenReturn(mockResultSet);

    accessor.initialize(context);
    accessor.openForRead();

    String expected = "SELECT  FROM (SELECT dept.name, count(), max(emp.salary)\n" +
            "FROM dept JOIN emp\n" +
            "ON dept.id = emp.dept_id\n" +
            "GROUP BY dept.name) pxfsubquery WHERE count >= 1 AND count < 2";
    assertEquals(expected, queryPassed.getValue());
}
 
Example #4
Source File: NemoEventDecoderFactory.java    From incubator-nemo with Apache License 2.0 6 votes vote down vote up
@Override
public Object decode() throws IOException {

  final byte isWatermark = (byte) inputStream.read();
  if (isWatermark == -1) {
    // end of the input stream
    throw new EOFException();
  }

  if (isWatermark == 0x00) {
    // this is not a watermark
    return valueDecoder.decode();
  } else if (isWatermark == 0x01) {
    // this is a watermark
    final WatermarkWithIndex watermarkWithIndex =
      (WatermarkWithIndex) SerializationUtils.deserialize(inputStream);
    return watermarkWithIndex;
  } else {
    throw new RuntimeException("Watermark decoding failure: " + isWatermark);
  }
}
 
Example #5
Source File: JdbcAccessorTest.java    From pxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testReadFromQueryWithWhereWithPartitions() throws Exception {
    String serversDirectory = new File(this.getClass().getClassLoader().getResource("servers").toURI()).getCanonicalPath();
    context.getAdditionalConfigProps().put("pxf.config.server.directory", serversDirectory + File.separator + "test-server");
    context.setDataSource("query:testquerywithwhere");
    context.addOption("PARTITION_BY", "count:int");
    context.addOption("RANGE", "1:10");
    context.addOption("INTERVAL", "1");
    context.setFragmentMetadata(SerializationUtils.serialize(PartitionType.INT.getFragmentsMetadata("count", "1:10", "1").get(2)));
    ArgumentCaptor<String> queryPassed = ArgumentCaptor.forClass(String.class);
    when(mockStatement.executeQuery(queryPassed.capture())).thenReturn(mockResultSet);

    accessor.initialize(context);
    accessor.openForRead();

    String expected = "SELECT  FROM (SELECT dept.name, count(), max(emp.salary)\n" +
            "FROM dept JOIN emp\n" +
            "ON dept.id = emp.dept_id\n" +
            "WHERE dept.id < 10\n" +
            "GROUP BY dept.name) pxfsubquery WHERE count >= 1 AND count < 2";
    assertEquals(expected, queryPassed.getValue());
}
 
Example #6
Source File: AuthorizeNetAimPaymentGatewayImpl.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
@Override
public Payment capture(final Payment paymentIn, final boolean forceProcessing) {
    final Payment payment = (Payment) SerializationUtils.clone(paymentIn);
    payment.setTransactionOperation(CAPTURE);


    final net.authorize.Merchant merchant = createMerchant();
    final net.authorize.aim.Transaction transaction = merchant.createAIMTransaction(
            net.authorize.TransactionType.PRIOR_AUTH_CAPTURE,
            payment.getPaymentAmount()
    );
    transaction.setTransactionId(payment.getTransactionReferenceId()); // prev auth


    return runTransaction(merchant, transaction, payment);

}
 
Example #7
Source File: ParamSupply.java    From onedev with MIT License 6 votes vote down vote up
@SuppressWarnings("unchecked")
public static Class<? extends Serializable> defineBeanClass(Collection<ParamSpec> paramSpecs) {
	byte[] bytes = SerializationUtils.serialize((Serializable) paramSpecs);
	String className = PARAM_BEAN_PREFIX + "_" + Hex.encodeHexString(bytes);
	
	List<ParamSpec> paramSpecsCopy = new ArrayList<>(paramSpecs);
	for (int i=0; i<paramSpecsCopy.size(); i++) {
		ParamSpec paramSpec = paramSpecsCopy.get(i);
		if (paramSpec instanceof SecretParam) {
			ParamSpec paramSpecClone = (ParamSpec) SerializationUtils.clone(paramSpec);
			String description = paramSpecClone.getDescription();
			if (description == null)
				description = "";
			description += String.format("<div style='margin-top: 12px;'><b>Note:</b> Secret less than %d characters "
					+ "will not be masked in build log</div>", SecretInput.MASK.length());
			paramSpecClone.setDescription(description);
			paramSpecsCopy.set(i, paramSpecClone);
		}
	}
	return (Class<? extends Serializable>) ParamSpec.defineClass(className, "Build Parameters", paramSpecsCopy);
}
 
Example #8
Source File: ParamSupply.java    From onedev with MIT License 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Nullable
public static Class<? extends Serializable> loadBeanClass(String className) {
	if (className.startsWith(PARAM_BEAN_PREFIX)) {
		byte[] bytes;
		try {
			bytes = Hex.decodeHex(className.substring(PARAM_BEAN_PREFIX.length()+1).toCharArray());
		} catch (DecoderException e) {
			throw new RuntimeException(e);
		}
		List<ParamSpec> paramSpecs = (List<ParamSpec>) SerializationUtils.deserialize(bytes);
		return defineBeanClass(paramSpecs);
	} else {
		return null;
	}
}
 
Example #9
Source File: JedisCacheDriver.java    From rebuild with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void putx(String key, V value, int seconds) {
	Jedis jedis = null;
	try {
		jedis = jedisPool.getResource();

		byte[] bkey = key.getBytes();
		if (seconds > 0) {
   			jedis.setex(bkey, seconds, SerializationUtils.serialize(value));
           } else {
   			jedis.set(bkey, SerializationUtils.serialize(value));
           }
	} finally {
		IOUtils.closeQuietly(jedis);
	}
}
 
Example #10
Source File: AuthorizeNetAimPaymentGatewayImpl.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Payment authorizeCapture(final Payment paymentIn, final boolean forceProcessing) {
    final Payment payment = (Payment) SerializationUtils.clone(paymentIn);
    payment.setTransactionOperation(AUTH_CAPTURE);


    final net.authorize.Merchant merchant = createMerchant();
    final net.authorize.aim.Transaction transaction = merchant.createAIMTransaction(
            net.authorize.TransactionType.AUTH_CAPTURE,
            payment.getPaymentAmount()
    );
    transaction.setCustomer(createAnetCustomer(payment));
    transaction.setOrder(createAnetOrder(payment));
    transaction.setCreditCard(createAnetCreditCard(payment));
    transaction.setShippingAddress(createShippingAddress(payment));


    return runTransaction(merchant, transaction, payment);

}
 
Example #11
Source File: AuthorizeNetAimPaymentGatewayImpl.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Payment voidCapture(final Payment paymentIn, final boolean forceProcessing) {
    final Payment payment = (Payment) SerializationUtils.clone(paymentIn);
    payment.setTransactionOperation(VOID_CAPTURE);


    final net.authorize.Merchant merchant = createMerchant();
    final net.authorize.aim.Transaction transaction = merchant.createAIMTransaction(
            net.authorize.TransactionType.VOID,
            payment.getPaymentAmount()
    );
    transaction.setTransactionId(payment.getTransactionReferenceId()); // prev auth


    return runTransaction(merchant, transaction, payment);

}
 
Example #12
Source File: GroupResultDiskBuffer.java    From dble with GNU General Public License v2.0 6 votes vote down vote up
@Override
public RowDataPacket nextRow() {
    RowDataPacket rp = super.nextRow();
    if (rp == null)
        return null;
    else {
        DGRowPacket newRow = new DGRowPacket(orgFieldCount, sumSize);
        for (int index = 0; index < sumSize; index++) {
            byte[] b = rp.getValue(index);
            if (b != null) {
                Object obj = SerializationUtils.deserialize(b);
                newRow.setSumTran(index, obj, b.length);
            }
        }
        for (int index = sumSize; index < this.fieldCount; index++) {
            newRow.add(rp.getValue(index));
        }
        return newRow;
    }
}
 
Example #13
Source File: TestPaymentGatewayImpl.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Payment refund(final Payment paymentIn, final boolean forceProcessing) {
    final Payment payment = (Payment) SerializationUtils.clone(paymentIn);
    payment.setTransactionOperation(REFUND);
    if (isParameterActivated(REFUND_FAIL) || isParameterActivated(REFUND_FAIL_NO + payment.getPaymentAmount().toPlainString())) {
        payment.setTransactionOperationResultCode("EXTERNAL_ERROR_CODE");
        payment.setTransactionOperationResultMessage("Card rejected exception. Refund for " + payment.getPaymentAmount().toPlainString());
        payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_FAILED);
        payment.setPaymentProcessorBatchSettlement(false);
    } else {
        payment.setTransactionReferenceId(UUID.randomUUID().toString());
        payment.setTransactionGatewayLabel(getLabel());
        payment.setTransactionOperationResultCode("OK");
        payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_OK);
        payment.setPaymentProcessorBatchSettlement(false);
    }
    return payment;
}
 
Example #14
Source File: TestPaymentGatewayImpl.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Payment voidCapture(final Payment paymentIn, final boolean forceProcessing) {
    final Payment payment = (Payment) SerializationUtils.clone(paymentIn);
    payment.setTransactionOperation(VOID_CAPTURE);
    if (isParameterActivated(VOID_CAPTURE_FAIL) || isParameterActivated(VOID_CAPTURE_FAIL_NO + payment.getPaymentAmount().toPlainString())) {
        payment.setTransactionOperationResultCode("EXTERNAL_ERROR_CODE");
        payment.setTransactionOperationResultMessage("Card rejected exception. Void Capture for " + payment.getPaymentAmount().toPlainString());
        payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_FAILED);
        payment.setPaymentProcessorBatchSettlement(false);
    } else {
        payment.setTransactionReferenceId(UUID.randomUUID().toString());
        payment.setTransactionGatewayLabel(getLabel());
        payment.setTransactionOperationResultCode("OK");
        payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_OK);
        payment.setPaymentProcessorBatchSettlement(false);
    }
    return payment;
}
 
Example #15
Source File: MemcachedClientTest.java    From ob1k with Apache License 2.0 6 votes vote down vote up
@Test(expected = ExecutionException.class)
public void testMultiget_TranscoderExecption() throws ExecutionException, InterruptedException, TimeoutException {
  final Transcoder<Serializable> transcoder = new Transcoder<Serializable>() {
    @Override
    public Serializable decode(final byte[] b) {
      throw new SerializationException("QQQQQ YYYYY");
    }

    @Override
    public byte[] encode(final Serializable t) {
      return SerializationUtils.serialize(t);
    }
  };

  final MemcachedClient<Object, Serializable> client = createClient(transcoder);

  client.setAsync("meh", "its here").get();
  client.getBulkAsync(Lists.newArrayList("meh", "bah")).get(1, TimeUnit.MINUTES);
}
 
Example #16
Source File: PayPalButtonPaymentGatewayImpl.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Payment capture(final Payment paymentIn, final boolean forceProcessing) {
    final Payment payment = (Payment) SerializationUtils.clone(paymentIn);
    payment.setTransactionOperation(CAPTURE);
    payment.setTransactionReferenceId(UUID.randomUUID().toString());
    payment.setTransactionAuthorizationCode(UUID.randomUUID().toString());
    payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_MANUAL_PROCESSING_REQUIRED);
    payment.setPaymentProcessorBatchSettlement(false);
    return payment;
}
 
Example #17
Source File: AuthorizeNetSimPaymentGatewayImpl.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Payment authorize(final Payment paymentIn, final boolean forceProcessing) {
    final Payment payment = (Payment) SerializationUtils.clone(paymentIn);
    payment.setTransactionOperation(AUTH);
    payment.setTransactionReferenceId(UUID.randomUUID().toString());
    payment.setTransactionAuthorizationCode(UUID.randomUUID().toString());
    payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_MANUAL_PROCESSING_REQUIRED);
    payment.setPaymentProcessorBatchSettlement(false);
    return payment;
}
 
Example #18
Source File: NodeMonitoring.java    From ankush with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Gets the technology data.
 * 
 * @return the technologyData
 */
@Transient
public Map<String, TechnologyData> getTechnologyData() {
	if (getTechnologyDataBytes() == null) {
		return null;
	}
	return (Map<String, TechnologyData>) SerializationUtils
			.deserialize(getTechnologyDataBytes());
}
 
Example #19
Source File: PostFinancePaymentGatewayImpl.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Payment refund(final Payment paymentIn, final boolean forceProcessing) {
    final Payment payment = (Payment) SerializationUtils.clone(paymentIn);
    payment.setTransactionOperation(REFUND);
    payment.setTransactionReferenceId(UUID.randomUUID().toString());
    payment.setTransactionAuthorizationCode(UUID.randomUUID().toString());
    payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_MANUAL_PROCESSING_REQUIRED);
    payment.setPaymentProcessorBatchSettlement(false);
    return payment;
}
 
Example #20
Source File: EnumTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testSerialization() {
    int hashCode = ColorEnum.RED.hashCode();
    assertSame(ColorEnum.RED, SerializationUtils.clone(ColorEnum.RED));
    assertEquals(hashCode, SerializationUtils.clone(ColorEnum.RED).hashCode());
    assertSame(ColorEnum.GREEN, SerializationUtils.clone(ColorEnum.GREEN));
    assertSame(ColorEnum.BLUE, SerializationUtils.clone(ColorEnum.BLUE));
}
 
Example #21
Source File: PainterCanvasControl.java    From whiteboard with Apache License 2.0 5 votes vote down vote up
/** 
 * @return void
 * @description:  ��ÿһ��·�����ó�ʼֵ
 * @date 2015-3-16 ����10:11:57    
 * @author: yems 
 */
private void setPathValue() {
	mCurrentPath = new SerializablePath();
	mCurrentPath.setOPType("send");
	mCurrentPath.setScreenHeight(Commons.CURRENT_SCREEN_HEIGHT);
	mCurrentPath.setScreenWidth(Commons.CURRENT_SCREEN_WIDTH);
	mCurrentPath.setMyUUID(Commons.myUUID);
	mCurrentPath
			.setSerializablePaint((SerializablePaint) SerializationUtils
					.clone(mPaint));

	Utils.pickUndoCaches();
}
 
Example #22
Source File: PostFinancePaymentGatewayImpl.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Payment reverseAuthorization(final Payment paymentIn, final boolean forceProcessing) {
    final Payment payment = (Payment) SerializationUtils.clone(paymentIn);
    payment.setTransactionOperation(REVERSE_AUTH);
    payment.setTransactionReferenceId(UUID.randomUUID().toString());
    payment.setTransactionAuthorizationCode(UUID.randomUUID().toString());
    payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_MANUAL_PROCESSING_REQUIRED);
    payment.setPaymentProcessorBatchSettlement(false);
    return payment;
}
 
Example #23
Source File: PostFinancePaymentGatewayImpl.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Payment capture(final Payment paymentIn, final boolean forceProcessing) {
    final Payment payment = (Payment) SerializationUtils.clone(paymentIn);
    payment.setTransactionOperation(CAPTURE);
    payment.setTransactionReferenceId(UUID.randomUUID().toString());
    payment.setTransactionAuthorizationCode(UUID.randomUUID().toString());
    payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_MANUAL_PROCESSING_REQUIRED);
    payment.setPaymentProcessorBatchSettlement(false);
    return payment;
}
 
Example #24
Source File: LiqPayPaymentGatewayImpl.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * <p/>
 * Shipment not included. Will be added at capture operation.
 */
@Override
public Payment authorize(final Payment paymentIn, final boolean forceProcessing) {
    final Payment payment = (Payment) SerializationUtils.clone(paymentIn);
    payment.setTransactionOperation(AUTH);
    payment.setTransactionReferenceId(UUID.randomUUID().toString());
    payment.setTransactionAuthorizationCode(UUID.randomUUID().toString());
    payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_MANUAL_PROCESSING_REQUIRED);
    payment.setPaymentProcessorBatchSettlement(false);
    return payment;
}
 
Example #25
Source File: OWLGraphWrapperExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * gets the OBO-style ID of the specified object. e.g., "GO:0008150"
 * SerializationUtils.clone is used to avoid memory leaks.
 * 
 * @param iriId
 * @return OBO-style identifier, using obo2owl mappings or the literals extracted from oboInowl#id.
 */
public String getIdentifier(IRI iriId) {
	if (iriId.toString().startsWith(Obo2OWLConstants.DEFAULT_IRI_PREFIX))
		return (String) SerializationUtils.clone(Owl2Obo.getIdentifier(iriId));

	final OWLAnnotationProperty oboIdInOwl = getDataFactory().getOWLAnnotationProperty(Obo2Owl.trTagToIRI(OboFormatTag.TAG_ID.getTag()));
	for (OWLOntology o : getAllOntologies()) {
		Collection<OWLAnnotation> oas = EntitySearcher.getAnnotations(iriId, o);
		if (oas == null) continue;

		for (OWLAnnotation oa: oas) {
			// We specifically look for the annotation property, oboInOwl:id; ignore others.
			if (oa.getProperty().equals(oboIdInOwl) != true)
				continue;

			// We then get the object value of this property, which is supposed to be a literal.
			OWLAnnotationValue objValue = oa.getValue();
			if (objValue.isLiteral() != true) {
				LOG.warn("Odd. " + objValue + " of oboInOwl#id for "+ iriId + ", is supposed to be an literal, but it is not.");
				continue;
			}

			Optional<OWLLiteral> literalOpt = objValue.asLiteral();
			if (literalOpt.isPresent() != true) {
				LOG.warn("Odd. " + objValue + " of oboInOwl#id for "+ iriId + ", does not exist.");
				continue;
			}

			OWLLiteral literal = literalOpt.get();
			return (String) SerializationUtils.clone(literal.getLiteral());
		}
	}

	// In the case where the input class does not have oboInOwl#id, we return its original URL.
	LOG.warn("Unable to retrieve the value of oboInOwl#id as the identifier for " + iriId + "; we will use an original iri as the identifier.");
	return (String) SerializationUtils.clone(iriId.toString());
}
 
Example #26
Source File: Cluster.java    From ankush with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Transient
public ClusterConfig getClusterConfig() {
	if (getConfBytes() == null) {
		return null;
	}
	return (ClusterConfig) SerializationUtils.deserialize(getConfBytes());
}
 
Example #27
Source File: PayPalExpressCheckoutPaymentGatewayImpl.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Payment reverseAuthorization(final Payment paymentIn, final boolean forceProcessing) {
    final Payment payment = (Payment) SerializationUtils.clone(paymentIn);
    payment.setTransactionOperation(REVERSE_AUTH);
    payment.setTransactionReferenceId(UUID.randomUUID().toString());
    payment.setTransactionAuthorizationCode(UUID.randomUUID().toString());
    payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_MANUAL_PROCESSING_REQUIRED);
    payment.setPaymentProcessorBatchSettlement(false);
    return payment;
}
 
Example #28
Source File: NodeMonitoring.java    From ankush with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Method to sset graph view data.
 * 
 * @return
 */
@Transient
public HashMap getGraphViewData() {
	// if graphViewData is not null.
	if (this.graphView != null) {
		try {
			return (HashMap) SerializationUtils.deserialize(this
					.getGraphView());
		} catch (Exception e) {
			return new HashMap();
		}
	}
	return new HashMap();
}
 
Example #29
Source File: Operation.java    From ankush with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Gets the cluster conf.
 * 
 * @return the cluster conf
 */
@Transient
public HashMap<String, Object> getData() {
	if (getDataBytes() == null) {
		return null;
	}
	return (HashMap<String, Object>) SerializationUtils
			.deserialize(getDataBytes());
}
 
Example #30
Source File: HashFunctionsTest.java    From metron with Apache License 2.0 5 votes vote down vote up
@Test
public void nonStringValueThatIsSerializableHashesSuccessfully() throws Exception {
  final String algorithm = "'md5'";
  final String valueToHash = "'My value to hash'";
  final Serializable input = (Serializable) Collections.singletonList(valueToHash);

  final MessageDigest expected = MessageDigest.getInstance(algorithm.replace("'", ""));
  expected.update(SerializationUtils.serialize(input));

  final Map<String, Object> variables = new HashMap<>();
  variables.put("toHash", input);

  assertEquals(expectedHexString(expected), run("HASH(toHash, " + algorithm + ")", variables));
}