private Bindings getBindings(Execution execution, JCRSessionWrapper session)
      throws RepositoryException {
    EnvironmentImpl environment = EnvironmentImpl.getCurrent();
    final Map<String, Object> vars = ((ExecutionImpl) execution).getVariables();
    Locale locale = (Locale) vars.get("locale");
    final Bindings bindings = new MyBindings(environment);
    ResourceBundle resourceBundle =
        JahiaResourceBundle.lookupBundle(
            "org.jahia.services.workflow."
                + ((ExecutionImpl) execution).getProcessDefinition().getKey(),
            locale);
    bindings.put("bundle", resourceBundle);
    JahiaUser jahiaUser =
        ServicesRegistry.getInstance()
            .getJahiaUserManagerService()
            .lookupUserByKey((String) vars.get("user"));
    bindings.put("user", jahiaUser);
    bindings.put("date", new DateTool());
    bindings.put("submissionDate", Calendar.getInstance());
    bindings.put("locale", locale);
    bindings.put("workspace", vars.get("workspace"));

    List<JCRNodeWrapper> nodes = new LinkedList<JCRNodeWrapper>();
    @SuppressWarnings("unchecked")
    List<String> stringList = (List<String>) vars.get("nodeIds");
    for (String s : stringList) {
      JCRNodeWrapper nodeByUUID = session.getNodeByUUID(s);
      if (!nodeByUUID.isNodeType("jnt:translation")) {
        nodes.add(nodeByUUID);
      }
    }
    bindings.put("nodes", nodes);
    return bindings;
  }
Example #2
0
  public boolean isOlder(Date receivedDate, Date lastReceivedDate) {

    // now we check to see if the timestamp of this message is newer than that of
    // the last received date, so we are getting new google voice messages only
    Calendar newMsgReceivedDate = Calendar.getInstance(TimeZone.getDefault());
    Calendar oldReceivedDate = Calendar.getInstance(TimeZone.getDefault());
    newMsgReceivedDate.setTime(receivedDate);
    oldReceivedDate.setTime(lastReceivedDate);
    if (log.isDebugEnabled())
      log.debug(
          String.format(
              "Calendar Message age check.  Sent date %s %s, received date %s %s",
              newMsgReceivedDate.getTime().getTime(),
              newMsgReceivedDate.getTime(),
              oldReceivedDate.getTime().getTime(),
              oldReceivedDate.getTime()));

    if (newMsgReceivedDate.getTime().compareTo(oldReceivedDate.getTime()) <= 0) return true;

    if (log.isDebugEnabled())
      log.debug(
          String.format(
              "Calendar explicit equal check:  Seconds %s %s \n, minutes %s %s \n, hours %s %s",
              newMsgReceivedDate.get(Calendar.SECOND),
              oldReceivedDate.get(Calendar.SECOND),
              newMsgReceivedDate.get(Calendar.MINUTE),
              oldReceivedDate.get(Calendar.MINUTE),
              newMsgReceivedDate.get(Calendar.HOUR),
              oldReceivedDate.get(Calendar.HOUR)));

    // need to an explicit check if two dates are equal
    return newMsgReceivedDate.get(Calendar.SECOND) == oldReceivedDate.get(Calendar.SECOND)
        && newMsgReceivedDate.get(Calendar.MINUTE) == oldReceivedDate.get(Calendar.MINUTE)
        && newMsgReceivedDate.get(Calendar.HOUR) == oldReceivedDate.get(Calendar.HOUR)
        && newMsgReceivedDate.get(Calendar.DAY_OF_YEAR) == oldReceivedDate.get(Calendar.DAY_OF_YEAR)
        && newMsgReceivedDate.get(Calendar.YEAR) == oldReceivedDate.get(Calendar.YEAR);
  }