示例#1
0
  @RequestMapping(value = "/events/{eventName}/pending-payments/bulk-confirmation", method = POST)
  public List<Triple<Boolean, String, String>> bulkConfirmation(
      @PathVariable("eventName") String eventName,
      Principal principal,
      @RequestBody UploadBase64FileModification file)
      throws IOException {

    try (InputStreamReader isr = new InputStreamReader(file.getInputStream());
        CSVReader reader = new CSVReader(isr)) {
      Event event = loadEvent(eventName, principal);
      return reader
          .readAll()
          .stream()
          .map(
              line -> {
                String reservationID = null;
                try {
                  Validate.isTrue(line.length >= 2);
                  reservationID = line[0];
                  ticketReservationManager.validateAndConfirmOfflinePayment(
                      reservationID, event, new BigDecimal(line[1]));
                  return Triple.of(Boolean.TRUE, reservationID, "");
                } catch (Exception e) {
                  return Triple.of(
                      Boolean.FALSE, Optional.ofNullable(reservationID).orElse(""), e.getMessage());
                }
              })
          .collect(Collectors.toList());
    }
  }
示例#2
0
 public void setAnimation(
     Triple<Integer, Integer, Float> animData, Table<Integer, Optional<Node<?>>, Key> keyData) {
   ImmutableTable.Builder<Integer, Node<?>, Key> builder = ImmutableTable.builder();
   for (Table.Cell<Integer, Optional<Node<?>>, Key> key : keyData.cellSet()) {
     builder.put(key.getRowKey(), key.getColumnKey().or(this), key.getValue());
   }
   setAnimation(
       new Animation(
           animData.getLeft(), animData.getMiddle(), animData.getRight(), builder.build()));
 }
示例#3
0
  public static <T extends IEntity> Specification<T> resolveConstraint(
      final Triple<String, ClientOperation, String> constraint, final Class<T> clazz) {
    final String constraintName = constraint.getLeft();
    final boolean negated = isConstraintNegated(constraint);

    if (constraintName.equals(QueryConstants.NAME)) {
      return QuerySpecificationSec.getByNameSpecification(
          clazz, constraint.getMiddle(), constraint.getRight(), negated);
    }
    if (constraintName.equals(QueryConstants.ID)) {
      return QuerySpecificationSec.getByIdSpecification(
          clazz, Long.parseLong(constraint.getRight()), negated);
    }
    return null;
  }
示例#4
0
 private Triple<Integer, Integer, Float> anim() throws IOException {
   chunk("ANIM");
   int flags = buf.getInt();
   int frames = buf.getInt();
   float fps = buf.getFloat();
   dump("ANIM(" + flags + ", " + frames + ", " + fps + ")");
   popLimit();
   return Triple.of(flags, frames, fps);
 }
 /**
  * Returns a memoized (caching) version of this {@link ObjBiByteToCharFunction}. Whenever it is
  * called, the mapping between the input parameters and the return value is preserved in a cache,
  * making subsequent calls returning the memoized value instead of computing the return value
  * again.
  *
  * <p>Unless the function and therefore the used cache will be garbage-collected, it will keep all
  * memoized values forever.
  *
  * @return A memoized (caching) version of this {@code ObjBiByteToCharFunction}.
  * @implSpec This implementation does not allow the input parameters or return value to be {@code
  *     null} for the resulting memoized function, as the cache used internally does not permit
  *     {@code null} keys or values.
  * @implNote The returned memoized function can be safely used concurrently from multiple threads
  *     which makes it thread-safe.
  */
 @Nonnull
 default ObjBiByteToCharFunction<T> memoized() {
   if (isMemoized()) {
     return this;
   } else {
     final Map<Triple<T, Byte, Byte>, Character> cache = new ConcurrentHashMap<>();
     final Object lock = new Object();
     return (ObjBiByteToCharFunction<T> & Memoized)
         (t, value1, value2) -> {
           final char returnValue;
           synchronized (lock) {
             returnValue =
                 cache.computeIfAbsent(
                     Triple.of(t, value1, value2),
                     key -> applyAsChar(key.getLeft(), key.getMiddle(), key.getRight()));
           }
           return returnValue;
         };
   }
 }
 /**
  * Returns a memoized (caching) version of this {@link ThrowableObjBiBooleanToByteFunction}.
  * Whenever it is called, the mapping between the input parameters and the return value is
  * preserved in a cache, making subsequent calls returning the memoized value instead of computing
  * the return value again.
  *
  * <p>Unless the function and therefore the used cache will be garbage-collected, it will keep all
  * memoized values forever.
  *
  * @return A memoized (caching) version of this {@code ThrowableObjBiBooleanToByteFunction}.
  * @implSpec This implementation does not allow the input parameters or return value to be {@code
  *     null} for the resulting memoized function, as the cache used internally does not permit
  *     {@code null} keys or values.
  * @implNote The returned memoized function can be safely used concurrently from multiple threads
  *     which makes it thread-safe.
  */
 @Nonnull
 default ThrowableObjBiBooleanToByteFunction<T, X> memoized() {
   if (isMemoized()) {
     return this;
   } else {
     final Map<Triple<T, Boolean, Boolean>, Byte> cache = new ConcurrentHashMap<>();
     final Object lock = new Object();
     return (ThrowableObjBiBooleanToByteFunction<T, X> & Memoized)
         (t, value1, value2) -> {
           final byte returnValue;
           synchronized (lock) {
             returnValue =
                 cache.computeIfAbsent(
                     Triple.of(t, value1, value2),
                     ThrowableFunction.of(
                         key ->
                             applyAsByteThrows(key.getLeft(), key.getMiddle(), key.getRight())));
           }
           return returnValue;
         };
   }
 }
 /**
  * Returns a memoized (caching) version of this {@link ThrowableTriByteToFloatFunction}. Whenever
  * it is called, the mapping between the input parameters and the return value is preserved in a
  * cache, making subsequent calls returning the memoized value instead of computing the return
  * value again.
  *
  * <p>Unless the function and therefore the used cache will be garbage-collected, it will keep all
  * memoized values forever.
  *
  * @return A memoized (caching) version of this {@code ThrowableTriByteToFloatFunction}.
  * @implSpec This implementation does not allow the input parameters or return value to be {@code
  *     null} for the resulting memoized function, as the cache used internally does not permit
  *     {@code null} keys or values.
  * @implNote The returned memoized function can be safely used concurrently from multiple threads
  *     which makes it thread-safe.
  */
 @Nonnull
 default ThrowableTriByteToFloatFunction<X> memoized() {
   if (isMemoized()) {
     return this;
   } else {
     final Map<Triple<Byte, Byte, Byte>, Float> cache = new ConcurrentHashMap<>();
     final Object lock = new Object();
     return (ThrowableTriByteToFloatFunction<X> & Memoized)
         (value1, value2, value3) -> {
           final float returnValue;
           synchronized (lock) {
             returnValue =
                 cache.computeIfAbsent(
                     Triple.of(value1, value2, value3),
                     ThrowableFunction.of(
                         key ->
                             applyAsFloatThrows(key.getLeft(), key.getMiddle(), key.getRight())));
           }
           return returnValue;
         };
   }
 }
示例#8
0
  @Override
  public ListenableFuture<Triple<byte[], byte[], String>> encryptAsync(
      final byte[] plaintext,
      final byte[] iv,
      final byte[] authenticationData,
      final String algorithm)
      throws NoSuchAlgorithmException {

    if (plaintext == null) {
      throw new IllegalArgumentException("plaintext");
    }

    // Interpret the requested algorithm
    String algorithmName =
        (Strings.isNullOrWhiteSpace(algorithm) ? getDefaultEncryptionAlgorithm() : algorithm);
    Algorithm baseAlgorithm = AlgorithmResolver.Default.get(algorithmName);

    if (baseAlgorithm == null || !(baseAlgorithm instanceof AsymmetricEncryptionAlgorithm)) {
      throw new NoSuchAlgorithmException(algorithmName);
    }

    AsymmetricEncryptionAlgorithm algo = (AsymmetricEncryptionAlgorithm) baseAlgorithm;

    ICryptoTransform transform;
    ListenableFuture<Triple<byte[], byte[], String>> result;

    try {
      transform = algo.CreateEncryptor(_keyPair, _provider);
      result =
          Futures.immediateFuture(
              Triple.of(transform.doFinal(plaintext), (byte[]) null, algorithmName));
    } catch (Exception e) {
      result = Futures.immediateFailedFuture(e);
    }

    return result;
  }
示例#9
0
 static boolean isConstraintNegated(final Triple<String, ClientOperation, String> constraint) {
   return constraint.getMiddle().isNegated();
 }