コード例 #1
0
 private CharacteristicDto restoreCharacteristic(
     DebtCharacteristic targetCharacteristic,
     @Nullable Integer parentId,
     List<CharacteristicDto> sourceCharacteristics,
     Date updateDate,
     DbSession session) {
   CharacteristicDto sourceCharacteristic =
       characteristicByKey(targetCharacteristic.key(), sourceCharacteristics, false);
   if (sourceCharacteristic == null) {
     CharacteristicDto newCharacteristic =
         toDto(targetCharacteristic, parentId).setCreatedAt(updateDate);
     dbClient.debtCharacteristicDao().insert(newCharacteristic, session);
     return newCharacteristic;
   } else {
     // Update only if modifications
     if (ObjectUtils.notEqual(sourceCharacteristic.getName(), targetCharacteristic.name())
         || ObjectUtils.notEqual(sourceCharacteristic.getOrder(), targetCharacteristic.order())
         || ObjectUtils.notEqual(sourceCharacteristic.getParentId(), parentId)) {
       sourceCharacteristic.setName(targetCharacteristic.name());
       sourceCharacteristic.setOrder(targetCharacteristic.order());
       sourceCharacteristic.setParentId(parentId);
       sourceCharacteristic.setUpdatedAt(updateDate);
       dbClient.debtCharacteristicDao().update(sourceCharacteristic, session);
     }
     return sourceCharacteristic;
   }
 }
コード例 #2
0
 /**
  * Checks for an existing route that matches the {@link er.rest.routes.ERXRoute.Method} and {@link
  * er.rest.routes.ERXRoute#routePattern()} of <code>route</code> and yet has a different
  * controller or action mapping.
  *
  * @param route
  */
 protected void verifyRoute(ERXRoute route) {
   ERXRoute duplicateRoute =
       routeForMethodAndPattern(route.method(), route.routePattern().pattern());
   if (duplicateRoute != null) {
     boolean isDifferentController =
         ObjectUtils.notEqual(duplicateRoute.controller(), route.controller());
     boolean isDifferentAction = ObjectUtils.notEqual(duplicateRoute.action(), route.action());
     if (isDifferentController || isDifferentAction) {
       // We have a problem whereby two routes with same url pattern and http method map to
       // different direct actions
       StringBuilder message = new StringBuilder();
       message.append("The route <");
       message.append(route);
       message.append("> conflicts with existing route <");
       message.append(duplicateRoute);
       message.append(">.");
       if (isDifferentController) {
         message.append(" The controller class <");
         message.append(route.controller());
         message.append("> is different to <");
         message.append(duplicateRoute.controller());
         message.append(">.");
       }
       if (isDifferentAction) {
         message.append(" The action <");
         message.append(route.action());
         message.append("> is different to <");
         message.append(duplicateRoute.action());
         message.append(">.");
       }
       throw new IllegalStateException(message.toString());
     }
   }
 }
コード例 #3
0
  @Override
  protected String doFilter(String input, Map<String, Object> metaData) {
    String destination = (String) metaData.get("destination");
    String callId = (String) metaData.get("callId");
    LOGGER.info("sending message with callId {} to destination {}", callId, destination);
    sendMessage(destination, input);

    if (ObjectUtils.notEqual(metaData.get("answer"), true)) {
      LOGGER.debug("no answer expected, just returning null");
      return null;
    }
    LOGGER.info("waiting {}ms for response on call with id {}", timeout, callId);
    JmsTemplate createJMSTemplate = createJMSTemplate(destination);
    createJMSTemplate.setReceiveTimeout(timeout);
    Object receiveAndConvert = createJMSTemplate.receiveAndConvert(callId);
    if (receiveAndConvert == null) {
      throw new RuntimeException("JMS Receive Timeout reached");
    }
    LOGGER.info("response for call with id {} received", callId);
    return (String) receiveAndConvert;
  }