コード例 #1
0
ファイル: PagerUI.java プロジェクト: SiteView/ECC8.13
  public static Map<String, Object> pagerSettingInfo(DispatchContext ctx, Map<?, ?> context) {
    String id = (String) context.get("id");
    Map<String, Object> map = new HashMap<String, Object>();
    if (id == null || "".equalsIgnoreCase(id)) {
      map.put("_id", "");
      map.put("_name", "");
      map.put("_disabled", "no");
      map.put("_pagerSpeed", "");
      map.put("_pagerAlphaPhone", "");
      map.put("_pagerAlphaPIN", "");
      map.put("_pagerDirectPhone", "");
      map.put("_pagerOptionPhone", "");
      map.put("_pagerCustom", "");
      map.put("_pagerOption", "");
      map.put("_pagerType", "custom");
      Map retMap = ServiceUtil.returnSuccess();
      retMap.put("result", map);
      return retMap;
    } else {
      try {
        Map map1 =
            (Map<String, Object>)
                (ctx.getDispatcher().runSync("pagerSettingInfoValue", UtilMisc.toMap("id", id)))
                    .get("result");

        Map retMap = ServiceUtil.returnSuccess();
        retMap.put("result", map1);
        return retMap;
      } catch (GenericServiceException e) {
        return ServiceUtil.returnFailure(e.getMessage());
      }
    }
  }
コード例 #2
0
ファイル: CommonServices.java プロジェクト: zzj1213/BIGITWEB
  public static Map<String, Object> ping(DispatchContext dctx, Map<String, ?> context) {
    Delegator delegator = dctx.getDelegator();
    String message = (String) context.get("message");
    Locale locale = (Locale) context.get("locale");
    if (message == null) {
      message = "PONG";
    }

    long count = -1;
    try {
      count = delegator.findCountByCondition("SequenceValueItem", null, null, null);
    } catch (GenericEntityException e) {
      Debug.logError(e.getMessage(), module);
      return ServiceUtil.returnError(
          UtilProperties.getMessage(resource, "CommonPingDatasourceCannotConnect", locale));
    }

    if (count > 0) {
      Map<String, Object> result = ServiceUtil.returnSuccess();
      result.put("message", message);
      return result;
    } else {
      return ServiceUtil.returnError(
          UtilProperties.getMessage(resource, "CommonPingDatasourceInvalidCount", locale));
    }
  }
コード例 #3
0
ファイル: CommonServices.java プロジェクト: zzj1213/BIGITWEB
  public static Map<String, Object> streamTest(DispatchContext dctx, Map<String, ?> context) {
    InputStream in = (InputStream) context.get("inputStream");
    OutputStream out = (OutputStream) context.get("outputStream");

    BufferedReader reader = new BufferedReader(new InputStreamReader(in));
    Writer writer = new OutputStreamWriter(out);
    String line;

    try {
      while ((line = reader.readLine()) != null) {
        Debug.log("Read line: " + line, module);
        writer.write(line);
      }
    } catch (IOException e) {
      Debug.logError(e, module);
      return ServiceUtil.returnError(e.getMessage());
    } finally {
      try {
        writer.close();
      } catch (Exception e) {
        Debug.logError(e, module);
      }
    }

    Map<String, Object> result = ServiceUtil.returnSuccess();
    result.put("contentType", "text/plain");
    return result;
  }
コード例 #4
0
ファイル: PayPalServices.java プロジェクト: yan96in/GreenTea
  public static Map<String, Object> doAuthorization(
      DispatchContext dctx, Map<String, Object> context) {
    Delegator delegator = dctx.getDelegator();
    String orderId = (String) context.get("orderId");
    BigDecimal processAmount = (BigDecimal) context.get("processAmount");
    GenericValue payPalPaymentMethod = (GenericValue) context.get("payPalPaymentMethod");
    OrderReadHelper orh = new OrderReadHelper(delegator, orderId);
    GenericValue payPalConfig =
        getPaymentMethodGatewayPayPal(dctx, context, PaymentGatewayServices.AUTH_SERVICE_TYPE);
    Locale locale = (Locale) context.get("locale");

    NVPEncoder encoder = new NVPEncoder();
    encoder.add("METHOD", "DoAuthorization");
    encoder.add("TRANSACTIONID", payPalPaymentMethod.getString("transactionId"));
    encoder.add("AMT", processAmount.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
    encoder.add("TRANSACTIONENTITY", "Order");
    String currency = (String) context.get("currency");
    if (currency == null) {
      currency = orh.getCurrency();
    }
    encoder.add("CURRENCYCODE", currency);

    NVPDecoder decoder = null;
    try {
      decoder = sendNVPRequest(payPalConfig, encoder);
    } catch (PayPalException e) {
      Debug.logError(e, module);
      return ServiceUtil.returnError(e.getMessage());
    }

    if (decoder == null) {
      return ServiceUtil.returnError(
          UtilProperties.getMessage(resource, "AccountingPayPalUnknownError", locale));
    }

    Map<String, Object> result = ServiceUtil.returnSuccess();
    Map<String, String> errors = getErrorMessageMap(decoder);
    if (UtilValidate.isNotEmpty(errors)) {
      result.put("authResult", false);
      result.put("authRefNum", "N/A");
      result.put("processAmount", BigDecimal.ZERO);
      if (errors.size() == 1) {
        Map.Entry<String, String> error = errors.entrySet().iterator().next();
        result.put("authCode", error.getKey());
        result.put("authMessage", error.getValue());
      } else {
        result.put(
            "authMessage",
            "Multiple errors occurred, please refer to the gateway response messages");
        result.put("internalRespMsgs", errors);
      }
    } else {
      result.put("authResult", true);
      result.put("processAmount", new BigDecimal(decoder.get("AMT")));
      result.put("authRefNum", decoder.get("TRANSACTIONID"));
    }
    // TODO: Look into possible PAYMENTSTATUS and PENDINGREASON return codes, it is unclear what
    // should be checked for this type of transaction
    return result;
  }
コード例 #5
0
ファイル: CommonServices.java プロジェクト: zzj1213/BIGITWEB
  public static Map<String, Object> makeALotOfVisits(DispatchContext dctx, Map<String, ?> context) {
    Delegator delegator = dctx.getDelegator();
    int count = ((Integer) context.get("count")).intValue();

    for (int i = 0; i < count; i++) {
      GenericValue v = delegator.makeValue("Visit");
      String seqId = delegator.getNextSeqId("Visit");

      v.set("visitId", seqId);
      v.set("userCreated", "N");
      v.set("sessionId", "NA-" + seqId);
      v.set("serverIpAddress", "127.0.0.1");
      v.set("serverHostName", "localhost");
      v.set("webappName", "webtools");
      v.set("initialLocale", "en_US");
      v.set("initialRequest", "http://localhost:8080/webtools/control/main");
      v.set("initialReferrer", "http://localhost:8080/webtools/control/main");
      v.set(
          "initialUserAgent",
          "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/124 (KHTML, like Gecko) Safari/125.1");
      v.set("clientIpAddress", "127.0.0.1");
      v.set("clientHostName", "localhost");
      v.set("fromDate", UtilDateTime.nowTimestamp());

      try {
        delegator.create(v);
      } catch (GenericEntityException e) {
        Debug.logError(e, module);
      }
    }

    return ServiceUtil.returnSuccess();
  }
コード例 #6
0
ファイル: CommonServices.java プロジェクト: zzj1213/BIGITWEB
  /** Cause a Referential Integrity Error */
  public static Map<String, Object> entityFailTest(DispatchContext dctx, Map<String, ?> context) {
    Delegator delegator = dctx.getDelegator();
    Locale locale = (Locale) context.get("locale");

    // attempt to create a DataSource entity w/ an invalid dataSourceTypeId
    GenericValue newEntity = delegator.makeValue("DataSource");
    newEntity.set("dataSourceId", "ENTITY_FAIL_TEST");
    newEntity.set("dataSourceTypeId", "ENTITY_FAIL_TEST");
    newEntity.set("description", "Entity Fail Test - Delete me if I am here");
    try {
      delegator.create(newEntity);
    } catch (GenericEntityException e) {
      Debug.logError(e, module);
      return ServiceUtil.returnError(
          UtilProperties.getMessage(resource, "CommonEntityTestFailure", locale));
    }

    /*
    try {
        newEntity.remove();
    } catch (GenericEntityException e) {
        Debug.logError(e, module);
    }
    */

    return ServiceUtil.returnSuccess();
  }
コード例 #7
0
ファイル: ScheduleUI.java プロジェクト: SiteView/ECC8.13
 public static Map<String, Object> saveAbsoluteSchedule(DispatchContext ctx, Map<?, ?> context) {
   try {
     String name = (String) context.get("name");
     String scheduleAt0 = (String) context.get("scheduleAt0");
     String scheduleAt1 = (String) context.get("scheduleAt1");
     String scheduleAt2 = (String) context.get("scheduleAt2");
     String scheduleAt3 = (String) context.get("scheduleAt3");
     String scheduleAt4 = (String) context.get("scheduleAt4");
     String scheduleAt5 = (String) context.get("scheduleAt5");
     String scheduleAt6 = (String) context.get("scheduleAt6");
     String timeV =
         " _name="
             + name
             + " _schedule="
             + "*"
             + scheduleAt0
             + ","
             + scheduleAt1
             + ","
             + scheduleAt2
             + ","
             + scheduleAt3
             + ","
             + scheduleAt4
             + ","
             + scheduleAt5
             + ","
             + scheduleAt6;
     ctx.getDispatcher().runSync("saveAbsoluteScheduleV", UtilMisc.toMap("value", timeV));
   } catch (Exception e) {
     return ServiceUtil.returnFailure(e.getMessage());
   }
   return ServiceUtil.returnSuccess();
 }
コード例 #8
0
ファイル: PagerUI.java プロジェクト: SiteView/ECC8.13
  public static Map<String, Object> getPagerPrefefencesList(
      DispatchContext ctx, Map<?, ?> context) {
    try {
      Map<String, Object> map2 = ServiceUtil.returnSuccess();
      List<Map<Object, Object>> list = new ArrayList<Map<Object, Object>>();
      Map<String, Object> retDataMap =
          (Map<String, Object>)
              (ctx.getDispatcher()
                      .runSync("getConfigByName", UtilMisc.toMap("attrName", "_additionalPager")))
                  .get("result");
      if (retDataMap == null || retDataMap.size() == 0 || retDataMap.isEmpty()) {
        Map<Object, Object> map1 = new HashMap<Object, Object>();
        map1.put("_id", "no");
        map1.put("_name", "");
        map1.put("_pagerType", "no additional pager settings");
        map1.put("_pagerAlphaPhone", "");
        map1.put("_disabled", "");
        map1.put("_pagerAlphaPIN", "");

        list.add(map1);
        map2.put("result", list);
      } else {
        map2.put(
            "result",
            (ctx.getDispatcher().runSync("getPagerPrefefencesListValue", new HashMap()))
                .get("result"));
      }
      return map2;
    } catch (Exception e) {
      return ServiceUtil.returnFailure(e.getMessage());
    }
  }
コード例 #9
0
  /**
   * Copies a user preference group. Call with fromUserLoginId, userPrefGroupTypeId and optional
   * userPrefLoginId. If userPrefLoginId isn't specified, then the currently logged-in user's
   * userLoginId will be used.
   *
   * @param ctx The DispatchContext that this service is operating in.
   * @param context Map containing the input arguments.
   * @return Map with the result of the service, the output parameters.
   */
  public static Map<String, Object> copyUserPreferenceGroup(
      DispatchContext ctx, Map<String, ?> context) {
    Delegator delegator = ctx.getDelegator();
    Locale locale = (Locale) context.get("locale");

    String userLoginId = PreferenceWorker.getUserLoginId(context, false);
    String fromUserLoginId = (String) context.get("fromUserLoginId");
    String userPrefGroupTypeId = (String) context.get("userPrefGroupTypeId");
    if (UtilValidate.isEmpty(userLoginId)
        || UtilValidate.isEmpty(userPrefGroupTypeId)
        || UtilValidate.isEmpty(fromUserLoginId)) {
      return ServiceUtil.returnError(
          UtilProperties.getMessage(resource, "copyPreference.invalidArgument", locale));
    }

    try {
      Map<String, String> fieldMap =
          UtilMisc.toMap(
              "userLoginId", fromUserLoginId, "userPrefGroupTypeId", userPrefGroupTypeId);
      List<GenericValue> resultList = delegator.findByAnd("UserPreference", fieldMap);
      if (resultList != null) {
        for (GenericValue preference : resultList) {
          preference.set("userLoginId", userLoginId);
        }
        delegator.storeAll(resultList);
      }
    } catch (GenericEntityException e) {
      Debug.logWarning(e.getMessage(), module);
      return ServiceUtil.returnError(
          UtilProperties.getMessage(
              resource, "copyPreference.writeFailure", new Object[] {e.getMessage()}, locale));
    }

    return ServiceUtil.returnSuccess();
  }
コード例 #10
0
ファイル: PagerOperate.java プロジェクト: SiteView/ECC8.13
 public static Map<?, ?> delPagerseting(DispatchContext ctx, Map<?, ?> context) {
   try {
     delPagerseting(context);
     return ServiceUtil.returnSuccess();
   } catch (Exception e) {
     return ServiceUtil.returnFailure(e.getMessage());
   }
 }
コード例 #11
0
  public static Map<String, Object> updateContact(
      DispatchContext dctx, Map<String, Object> context) {
    Delegator delegator = dctx.getDelegator();
    LocalDispatcher dispatcher = dctx.getDispatcher();
    Security security = dctx.getSecurity();
    GenericValue userLogin = (GenericValue) context.get("userLogin");
    Locale locale = UtilCommon.getLocale(context);

    String contactPartyId = (String) context.get("partyId");

    // make sure userLogin has CRMSFA_CONTACT_UPDATE permission for this contact
    if (!CrmsfaSecurity.hasPartyRelationSecurity(
        security, "CRMSFA_CONTACT", "_UPDATE", userLogin, contactPartyId)) {
      return UtilMessage.createAndLogServiceError("CrmErrorPermissionDenied", locale, MODULE);
    }
    try {
      // update the Party and Person
      Map<String, Object> input =
          UtilMisc.<String, Object>toMap(
              "partyId",
              contactPartyId,
              "firstName",
              context.get("firstName"),
              "lastName",
              context.get("lastName"));
      input.put("firstNameLocal", context.get("firstNameLocal"));
      input.put("lastNameLocal", context.get("lastNameLocal"));
      input.put("personalTitle", context.get("personalTitle"));
      input.put("preferredCurrencyUomId", context.get("preferredCurrencyUomId"));
      input.put("description", context.get("description"));
      input.put("birthDate", context.get("birthDate"));
      input.put("userLogin", userLogin);
      Map<String, Object> serviceResults = dispatcher.runSync("updatePerson", input);
      if (ServiceUtil.isError(serviceResults)) {
        return UtilMessage.createAndLogServiceError(
            serviceResults, "CrmErrorUpdateContactFail", locale, MODULE);
      }

      // update PartySupplementalData
      GenericValue partyData =
          delegator.findByPrimaryKey(
              "PartySupplementalData", UtilMisc.toMap("partyId", contactPartyId));
      if (partyData == null) {
        // create a new one
        partyData =
            delegator.makeValue("PartySupplementalData", UtilMisc.toMap("partyId", contactPartyId));
        partyData.create();
      }
      partyData.setNonPKFields(context);
      partyData.store();

    } catch (GenericServiceException e) {
      return UtilMessage.createAndLogServiceError(e, "CrmErrorUpdateContactFail", locale, MODULE);
    } catch (GenericEntityException e) {
      return UtilMessage.createAndLogServiceError(e, "CrmErrorUpdateContactFail", locale, MODULE);
    }
    return ServiceUtil.returnSuccess();
  }
コード例 #12
0
ファイル: PagerOperate.java プロジェクト: SiteView/ECC8.13
 public static Map<?, ?> sendTest(DispatchContext ctx, Map<?, ?> context) {
   try {
     sendTest(context);
     return ServiceUtil.returnSuccess();
   } catch (Exception e) {
     Map map = ServiceUtil.returnFailure(e.getMessage());
     return map;
   }
 }
コード例 #13
0
ファイル: ScheduleUI.java プロジェクト: SiteView/ECC8.13
 public static Map<String, Object> delSchedule(DispatchContext ctx, Map<?, ?> context) {
   try {
     String id = (String) context.get("id");
     ctx.getDispatcher().runSync("delScheduleV", UtilMisc.toMap("id", id));
     return ServiceUtil.returnSuccess();
   } catch (Exception e) {
     return ServiceUtil.returnFailure(e.getMessage());
   }
 }
コード例 #14
0
ファイル: PagerOperate.java プロジェクト: SiteView/ECC8.13
  public static Map<String, Object> updatePagersetting(DispatchContext ctx, Map<?, ?> context) {
    try {

      updatePagersetting(context);
      return ServiceUtil.returnSuccess();
    } catch (Exception e) {
      return ServiceUtil.returnFailure(e.getMessage());
    }
  }
コード例 #15
0
ファイル: PagerOperate.java プロジェクト: SiteView/ECC8.13
 public static Map<String, Object> pagerSettingInfo(DispatchContext ctx, Map<?, ?> context) {
   try {
     Map<String, Object> retresult = ServiceUtil.returnSuccess();
     retresult.put("result", pagerSettingInfo(context));
     return retresult;
   } catch (Exception e1) {
     return ServiceUtil.returnError(e1.getMessage());
   }
 }
コード例 #16
0
ファイル: PagerOperate.java プロジェクト: SiteView/ECC8.13
 public static Map<?, ?> savePagerChange(DispatchContext ctx, Map<?, ?> context) {
   try {
     savePagerChange(context);
     Map<String, Object> retmap = ServiceUtil.returnSuccess();
     return retmap;
   } catch (Exception ex) {
     return ServiceUtil.returnError(ex.getMessage());
   }
 }
コード例 #17
0
  public static Map<String, Object> assignContactToAccount(
      DispatchContext dctx, Map<String, Object> context) {
    Delegator delegator = dctx.getDelegator();
    LocalDispatcher dispatcher = dctx.getDispatcher();
    Security security = dctx.getSecurity();
    GenericValue userLogin = (GenericValue) context.get("userLogin");
    Locale locale = UtilCommon.getLocale(context);

    String contactPartyId = (String) context.get("contactPartyId");
    String accountPartyId = (String) context.get("accountPartyId");

    try {
      // check if this contact is already a contact of this account
      EntityCondition searchConditions =
          EntityCondition.makeCondition(
              EntityOperator.AND,
              EntityCondition.makeCondition("partyIdFrom", EntityOperator.EQUALS, contactPartyId),
              EntityCondition.makeCondition("partyIdTo", EntityOperator.EQUALS, accountPartyId),
              EntityCondition.makeCondition("roleTypeIdFrom", EntityOperator.EQUALS, "CONTACT"),
              EntityCondition.makeCondition("roleTypeIdTo", EntityOperator.EQUALS, "ACCOUNT"),
              EntityCondition.makeCondition(
                  "partyRelationshipTypeId", EntityOperator.EQUALS, "CONTACT_REL_INV"),
              EntityUtil.getFilterByDateExpr());
      List<GenericValue> existingRelationships =
          delegator.findByCondition("PartyRelationship", searchConditions, null, null);
      if (existingRelationships.size() > 0) {
        return UtilMessage.createAndLogServiceError(
            "CrmErrorContactAlreadyAssociatedToAccount", locale, MODULE);
      }

      // check if userLogin has CRMSFA_ACCOUNT_UPDATE permission for this account
      if (!CrmsfaSecurity.hasPartyRelationSecurity(
          security, "CRMSFA_ACCOUNT", "_UPDATE", userLogin, accountPartyId)) {
        return UtilMessage.createAndLogServiceError("CrmErrorPermissionDenied", locale, MODULE);
      }
      // create the party relationship between the Contact and the Account
      PartyHelper.createNewPartyToRelationship(
          accountPartyId,
          contactPartyId,
          "CONTACT",
          "CONTACT_REL_INV",
          null,
          UtilMisc.toList("ACCOUNT"),
          false,
          userLogin,
          delegator,
          dispatcher);

    } catch (GenericServiceException e) {
      return UtilMessage.createAndLogServiceError(
          e, "CrmErrorAssignContactToAccountFail", locale, MODULE);
    } catch (GenericEntityException e) {
      return UtilMessage.createAndLogServiceError(
          e, "CrmErrorAssignContactToAccountFail", locale, MODULE);
    }
    return ServiceUtil.returnSuccess();
  }
コード例 #18
0
  /**
   * Authorizes and captures an EFT transaction. If the authorization or capture fails due to
   * problems with the transaction, this service will result in a failure.
   *
   * <p>If this service results in an error, it means that the service is not propery configured and
   * will not work until the issues are resolved.
   */
  public static Map authorizeAndCaptureEft(DispatchContext dctx, Map context) {
    Delegator delegator = dctx.getDelegator();
    String resource = getResource(context);
    Double amount = (Double) context.get("processAmount");
    GenericValue eftAccount = (GenericValue) context.get("eftAccount");
    String currencyUomId = (String) context.get("currency");

    try {
      Map request = buildRequestHeader(resource);
      request.putAll(buildRequest(eftAccount, amount, currencyUomId, "AUTH_CAPTURE"));
      request.putAll(buildCustomerRequest(delegator, context));
      request.putAll(buildOrderRequest(context));

      AuthorizeResponse response = processRequest(request, resource);

      // process the response
      Map results = ServiceUtil.returnSuccess();
      if (response == null) {
        results.put("authResult", Boolean.FALSE);
        results.put("authRefNum", AuthorizeResponse.ERROR);
        results.put("processAmount", new Double(0.0));
      } else if (AuthorizeResponse.APPROVED.equals(response.getResponseCode())) {
        results.put("authResult", Boolean.TRUE);
        results.put("authFlag", response.getReasonCode());
        results.put("authMessage", response.getReasonText());
        results.put("authCode", response.getResponseField(AuthorizeResponse.AUTHORIZATION_CODE));
        results.put("authRefNum", response.getResponseField(AuthorizeResponse.TRANSACTION_ID));
        results.put(
            "processAmount", new Double(response.getResponseField(AuthorizeResponse.AMOUNT)));
      } else {
        results.put("authResult", Boolean.FALSE);
        results.put("authFlag", response.getReasonCode());
        results.put("authMessage", response.getReasonText());
        results.put("authCode", response.getResponseField(AuthorizeResponse.AUTHORIZATION_CODE));
        results.put("authRefNum", AuthorizeResponse.ERROR);
        results.put("processAmount", new Double(0.0));
      }

      if (isTestMode(resource)) {
        Debug.logInfo("eCheck.NET AUTH_CAPTURE results: " + results, module);
      }
      return results;
    } catch (GenericEntityException e) {
      String message =
          "Entity engine error when attempting to authorize and capture EFT via eCheck.net: "
              + e.getMessage();
      Debug.logError(e, message, module);
      return ServiceUtil.returnError(message);
    } catch (GenericServiceException e) {
      String message =
          "Service error when attempting to authorize and capture EFT via eCheck.net.  This is a configuration problem that must be fixed before this service can work properly: "
              + e.getMessage();
      Debug.logError(e, message, module);
      return ServiceUtil.returnError(message);
    }
  }
コード例 #19
0
ファイル: PayPalServices.java プロジェクト: yan96in/GreenTea
  public static Map<String, Object> doCapture(DispatchContext dctx, Map<String, Object> context) {
    GenericValue paymentPref = (GenericValue) context.get("orderPaymentPreference");
    BigDecimal captureAmount = (BigDecimal) context.get("captureAmount");
    GenericValue payPalConfig =
        getPaymentMethodGatewayPayPal(dctx, context, PaymentGatewayServices.AUTH_SERVICE_TYPE);
    GenericValue authTrans = (GenericValue) context.get("authTrans");
    Locale locale = (Locale) context.get("locale");
    if (authTrans == null) {
      authTrans = PaymentGatewayServices.getAuthTransaction(paymentPref);
    }

    NVPEncoder encoder = new NVPEncoder();
    encoder.add("METHOD", "DoCapture");
    encoder.add("AUTHORIZATIONID", authTrans.getString("referenceNum"));
    encoder.add("AMT", captureAmount.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
    encoder.add("CURRENCYCODE", authTrans.getString("currencyUomId"));
    encoder.add("COMPLETETYPE", "NotComplete");

    NVPDecoder decoder = null;
    try {
      decoder = sendNVPRequest(payPalConfig, encoder);
    } catch (PayPalException e) {
      Debug.logError(e, module);
      return ServiceUtil.returnError(e.getMessage());
    }

    if (decoder == null) {
      return ServiceUtil.returnError(
          UtilProperties.getMessage(resource, "AccountingPayPalUnknownError", locale));
    }

    Map<String, Object> result = ServiceUtil.returnSuccess();
    Map<String, String> errors = getErrorMessageMap(decoder);
    if (UtilValidate.isNotEmpty(errors)) {
      result.put("captureResult", false);
      result.put("captureRefNum", "N/A");
      result.put("captureAmount", BigDecimal.ZERO);
      if (errors.size() == 1) {
        Map.Entry<String, String> error = errors.entrySet().iterator().next();
        result.put("captureCode", error.getKey());
        result.put("captureMessage", error.getValue());
      } else {
        result.put(
            "captureMessage",
            "Multiple errors occurred, please refer to the gateway response messages");
        result.put("internalRespMsgs", errors);
      }
    } else {
      result.put("captureResult", true);
      result.put("captureAmount", new BigDecimal(decoder.get("AMT")));
      result.put("captureRefNum", decoder.get("TRANSACTIONID"));
    }
    // TODO: Look into possible PAYMENTSTATUS and PENDINGREASON return codes, it is unclear what
    // should be checked for this type of transaction
    return result;
  }
コード例 #20
0
ファイル: PagerOperate.java プロジェクト: SiteView/ECC8.13
 public static Map<String, Object> getPagerPrefefencesList(
     DispatchContext ctx, Map<?, ?> context) {
   try {
     Map<String, Object> map2 = ServiceUtil.returnSuccess();
     map2.put("result", getPagerPrefefencesList());
     return map2;
   } catch (Exception e) {
     return ServiceUtil.returnFailure(e.getMessage());
   }
 }
コード例 #21
0
ファイル: PayPalServices.java プロジェクト: yan96in/GreenTea
  public static Map<String, Object> doRefund(DispatchContext dctx, Map<String, Object> context) {
    Locale locale = (Locale) context.get("locale");
    GenericValue payPalConfig = getPaymentMethodGatewayPayPal(dctx, context, null);
    if (payPalConfig == null) {
      return ServiceUtil.returnError(
          UtilProperties.getMessage(
              resource, "AccountingPayPalPaymentGatewayConfigCannotFind", locale));
    }
    GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
    GenericValue captureTrans =
        PaymentGatewayServices.getCaptureTransaction(orderPaymentPreference);
    BigDecimal refundAmount = (BigDecimal) context.get("refundAmount");
    NVPEncoder encoder = new NVPEncoder();
    encoder.add("METHOD", "RefundTransaction");
    encoder.add("TRANSACTIONID", captureTrans.getString("referenceNum"));
    encoder.add("REFUNDTYPE", "Partial");
    encoder.add("CURRENCYCODE", captureTrans.getString("currencyUomId"));
    encoder.add("AMT", refundAmount.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
    encoder.add("NOTE", "Order #" + orderPaymentPreference.getString("orderId"));
    NVPDecoder decoder = null;
    try {
      decoder = sendNVPRequest(payPalConfig, encoder);
    } catch (PayPalException e) {
      Debug.logError(e, module);
      return ServiceUtil.returnError(e.getMessage());
    }

    if (decoder == null) {
      return ServiceUtil.returnError(
          UtilProperties.getMessage(resource, "AccountingPayPalUnknownError", locale));
    }

    Map<String, Object> result = ServiceUtil.returnSuccess();
    Map<String, String> errors = getErrorMessageMap(decoder);
    if (UtilValidate.isNotEmpty(errors)) {
      result.put("refundResult", false);
      result.put("refundRefNum", captureTrans.getString("referenceNum"));
      result.put("refundAmount", BigDecimal.ZERO);
      if (errors.size() == 1) {
        Map.Entry<String, String> error = errors.entrySet().iterator().next();
        result.put("refundCode", error.getKey());
        result.put("refundMessage", error.getValue());
      } else {
        result.put(
            "refundMessage",
            "Multiple errors occurred, please refer to the gateway response messages");
        result.put("internalRespMsgs", errors);
      }
    } else {
      result.put("refundResult", true);
      result.put("refundAmount", new BigDecimal(decoder.get("GROSSREFUNDAMT")));
      result.put("refundRefNum", decoder.get("REFUNDTRANSACTIONID"));
    }
    return result;
  }
コード例 #22
0
 public static Map<String, Object> deleteCmsCatalog(
     DispatchContext dctx, Map<String, ? extends Object> context) throws GenericEntityException {
   Delegator delegator = dctx.getDelegator();
   String catalogId = (String) context.get("catalogId");
   GenericValue gv =
       delegator.findByPrimaryKey("CmsCatalog", UtilMisc.toMap("catalogId", catalogId));
   if (UtilValidate.isNotEmpty(gv)) {
     gv.remove();
   }
   return ServiceUtil.returnSuccess();
 }
コード例 #23
0
ファイル: PagerOperate.java プロジェクト: SiteView/ECC8.13
  public static Map<String, Object> getPagerDefaultPrefefences(
      DispatchContext ctx, Map<?, ?> context) {

    try {
      Map<String, Object> retresult = ServiceUtil.returnSuccess();
      retresult.put("result", getPagerDefaultPrefefences());
      return retresult;
    } catch (Exception ex) {
      return ServiceUtil.returnError(ex.getMessage());
    }
  }
コード例 #24
0
 public static Map<String, Object> createCmsCatalog(
     DispatchContext dctx, Map<String, ? extends Object> context) throws GenericEntityException {
   Map result = ServiceUtil.returnSuccess();
   Delegator delegator = dctx.getDelegator();
   String catalogId = delegator.getNextSeqId("CmsCatalog");
   GenericValue gv = delegator.makeValue("CmsCatalog", UtilMisc.toMap("catalogId", catalogId));
   gv.setNonPKFields(context);
   gv.create();
   result.put("catalogId", catalogId);
   return result;
 }
コード例 #25
0
ファイル: CommonServices.java プロジェクト: zzj1213/BIGITWEB
 public static Map<String, Object> testCommitListener(
     DispatchContext dctx, Map<String, ?> context) {
   ServiceXaWrapper xar = new ServiceXaWrapper(dctx);
   xar.setCommitService("testScv", context);
   try {
     xar.enlist();
   } catch (XAException e) {
     Debug.logError(e, module);
   }
   return ServiceUtil.returnSuccess();
 }
コード例 #26
0
  public static Map<String, Object> deactivateContact(
      DispatchContext dctx, Map<String, Object> context) {
    Delegator delegator = dctx.getDelegator();
    LocalDispatcher dispatcher = dctx.getDispatcher();
    Security security = dctx.getSecurity();
    GenericValue userLogin = (GenericValue) context.get("userLogin");
    Locale locale = UtilCommon.getLocale(context);

    // what contact we're expiring
    String contactPartyId = (String) context.get("partyId");

    // check that userLogin has CRMSFA_CONTACT_DEACTIVATE permission for this contact
    if (!CrmsfaSecurity.hasPartyRelationSecurity(
        security, "CRMSFA_CONTACT", "_DEACTIVATE", userLogin, contactPartyId)) {
      return UtilMessage.createAndLogServiceError("CrmErrorPermissionDenied", locale, MODULE);
    }

    // when to expire the contact
    Timestamp expireDate = (Timestamp) context.get("expireDate");
    if (expireDate == null) {
      expireDate = UtilDateTime.nowTimestamp();
    }

    // in order to deactivate a contact, we expire all party relationships on the expire date
    try {
      List<GenericValue> partyRelationships =
          delegator.findByAnd(
              "PartyRelationship",
              UtilMisc.toMap("partyIdFrom", contactPartyId, "roleTypeIdFrom", "CONTACT"));
      PartyHelper.expirePartyRelationships(partyRelationships, expireDate, dispatcher, userLogin);
    } catch (GenericEntityException e) {
      return UtilMessage.createAndLogServiceError(
          e, "CrmErrorDeactivateContactFail", locale, MODULE);
    } catch (GenericServiceException e) {
      return UtilMessage.createAndLogServiceError(
          e, "CrmErrorDeactivateContactFail", locale, MODULE);
    }

    // set the party statusId to PARTY_DISABLED and register the PartyDeactivation
    try {
      GenericValue contactParty =
          delegator.findByPrimaryKey("Party", UtilMisc.toMap("partyId", contactPartyId));
      contactParty.put("statusId", "PARTY_DISABLED");
      contactParty.store();

      delegator.create(
          "PartyDeactivation",
          UtilMisc.toMap("partyId", contactPartyId, "deactivationTimestamp", expireDate));
    } catch (GenericEntityException e) {
      return UtilMessage.createAndLogServiceError(
          e, "CrmErrorDeactivateAccountFail", locale, MODULE);
    }
    return ServiceUtil.returnSuccess();
  }
コード例 #27
0
 /**
  * Returns a complete category trail - can be used for exporting proper category trees. This is
  * mostly useful when used in combination with bread-crumbs, for building a faceted index tree, or
  * to export a category tree for migration to another system. Will create the tree from root point
  * to categoryId.
  *
  * <p>This method is not meant to be run on every request. Its best use is to generate the trail
  * every so often and store somewhere (a lucene/solr tree, entities, cache or so).
  *
  * @param productCategoryId id of category the trail should be generated for
  * @returns List organized trail from root point to categoryId.
  */
 public static Map getCategoryTrail(DispatchContext dctx, Map context) {
   String productCategoryId = (String) context.get("productCategoryId");
   Map<String, Object> results = ServiceUtil.returnSuccess();
   GenericDelegator delegator = (GenericDelegator) dctx.getDelegator();
   List<String> trailElements = FastList.newInstance();
   trailElements.add(productCategoryId);
   String parentProductCategoryId = productCategoryId;
   while (UtilValidate.isNotEmpty(parentProductCategoryId)) {
     // find product category rollup
     try {
       List<EntityCondition> rolllupConds = FastList.newInstance();
       rolllupConds.add(
           EntityCondition.makeCondition("productCategoryId", parentProductCategoryId));
       rolllupConds.add(EntityUtil.getFilterByDateExpr());
       List<GenericValue> productCategoryRollups =
           delegator.findList(
               "ProductCategoryRollup",
               EntityCondition.makeCondition(rolllupConds),
               null,
               UtilMisc.toList("sequenceNum"),
               null,
               true);
       if (UtilValidate.isNotEmpty(productCategoryRollups)) {
         // add only categories that belong to the top category to trail
         for (GenericValue productCategoryRollup : productCategoryRollups) {
           String trailCategoryId = productCategoryRollup.getString("parentProductCategoryId");
           parentProductCategoryId = trailCategoryId;
           if (trailElements.contains(trailCategoryId)) {
             break;
           } else {
             trailElements.add(trailCategoryId);
           }
         }
       } else {
         parentProductCategoryId = null;
       }
     } catch (GenericEntityException e) {
       Map<String, String> messageMap =
           UtilMisc.toMap("errMessage", ". Cannot generate trail from product category. ");
       String errMsg =
           UtilProperties.getMessage(
               "CommonUiLabels",
               "CommonDatabaseProblem",
               messageMap,
               (Locale) context.get("locale"));
       Debug.logError(e, errMsg, module);
       return ServiceUtil.returnError(errMsg);
     }
   }
   Collections.reverse(trailElements);
   results.put("trail", trailElements);
   return results;
 }
コード例 #28
0
ファイル: ScheduleUI.java プロジェクト: SiteView/ECC8.13
  public static Map<String, Object> getScheduleSettingsList(
      DispatchContext ctx, Map<?, ?> context) {
    try {
      List list = (List) ctx.getDispatcher().runSync("getScheduleList", new HashMap()).get("value");
      Map retMap = ServiceUtil.returnSuccess();

      retMap.put("result", list);
      return retMap;
    } catch (Exception e) {
      return ServiceUtil.returnFailure(e.getMessage());
    }
  }
コード例 #29
0
ファイル: PayPalServices.java プロジェクト: yan96in/GreenTea
  public static Map<String, Object> doVoid(DispatchContext dctx, Map<String, Object> context) {
    GenericValue payPalConfig = getPaymentMethodGatewayPayPal(dctx, context, null);
    Locale locale = (Locale) context.get("locale");
    if (payPalConfig == null) {
      return ServiceUtil.returnError(
          UtilProperties.getMessage(
              resource, "AccountingPayPalPaymentGatewayConfigCannotFind", locale));
    }
    GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
    GenericValue authTrans = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
    NVPEncoder encoder = new NVPEncoder();
    encoder.add("METHOD", "DoVoid");
    encoder.add("AUTHORIZATIONID", authTrans.getString("referenceNum"));
    NVPDecoder decoder = null;
    try {
      decoder = sendNVPRequest(payPalConfig, encoder);
    } catch (PayPalException e) {
      Debug.logError(e, module);
      return ServiceUtil.returnError(e.getMessage());
    }

    if (decoder == null) {
      return ServiceUtil.returnError(
          UtilProperties.getMessage(resource, "AccountingPayPalUnknownError", locale));
    }

    Map<String, Object> result = ServiceUtil.returnSuccess();
    Map<String, String> errors = getErrorMessageMap(decoder);
    if (UtilValidate.isNotEmpty(errors)) {
      result.put("releaseResult", false);
      result.put("releaseRefNum", authTrans.getString("referenceNum"));
      result.put("releaseAmount", BigDecimal.ZERO);
      if (errors.size() == 1) {
        Map.Entry<String, String> error = errors.entrySet().iterator().next();
        result.put("releaseCode", error.getKey());
        result.put("releaseMessage", error.getValue());
      } else {
        result.put(
            "releaseMessage",
            "Multiple errors occurred, please refer to the gateway response messages");
        result.put("internalRespMsgs", errors);
      }
    } else {
      result.put("releaseResult", true);
      // PayPal voids the entire order amount minus any captures, that's a little difficult to
      // figure out here
      // so until further testing proves we should do otherwise I'm just going to return requested
      // void amount
      result.put("releaseAmount", context.get("releaseAmount"));
      result.put("releaseRefNum", decoder.get("AUTHORIZATIONID"));
    }
    return result;
  }
コード例 #30
0
ファイル: CommonServices.java プロジェクト: zzj1213/BIGITWEB
  public static Map<String, Object> uploadTest(DispatchContext dctx, Map<String, ?> context) {
    LocalDispatcher dispatcher = dctx.getDispatcher();
    GenericValue userLogin = (GenericValue) context.get("userLogin");

    byte[] array = (byte[]) context.get("uploadFile");
    String fileName = (String) context.get("_uploadFile_fileName");
    String contentType = (String) context.get("_uploadFile_contentType");

    Map<String, Object> createCtx = FastMap.newInstance();
    createCtx.put("binData", array);
    createCtx.put("dataResourceTypeId", "OFBIZ_FILE");
    createCtx.put("dataResourceName", fileName);
    createCtx.put("dataCategoryId", "PERSONAL");
    createCtx.put("statusId", "CTNT_PUBLISHED");
    createCtx.put("mimeTypeId", contentType);
    createCtx.put("userLogin", userLogin);

    Map<String, Object> createResp = null;
    try {
      createResp = dispatcher.runSync("createFile", createCtx);
    } catch (GenericServiceException e) {
      Debug.logError(e, module);
      return ServiceUtil.returnError(e.getMessage());
    }
    if (ServiceUtil.isError(createResp)) {
      return ServiceUtil.returnError(ServiceUtil.getErrorMessage(createResp));
    }

    GenericValue dataResource = (GenericValue) createResp.get("dataResource");
    if (dataResource != null) {
      Map<String, Object> contentCtx = FastMap.newInstance();
      contentCtx.put("dataResourceId", dataResource.getString("dataResourceId"));
      contentCtx.put("localeString", ((Locale) context.get("locale")).toString());
      contentCtx.put("contentTypeId", "DOCUMENT");
      contentCtx.put("mimeTypeId", contentType);
      contentCtx.put("contentName", fileName);
      contentCtx.put("statusId", "CTNT_PUBLISHED");
      contentCtx.put("userLogin", userLogin);

      Map<String, Object> contentResp = null;
      try {
        contentResp = dispatcher.runSync("createContent", contentCtx);
      } catch (GenericServiceException e) {
        Debug.logError(e, module);
        return ServiceUtil.returnError(e.getMessage());
      }
      if (ServiceUtil.isError(contentResp)) {
        return ServiceUtil.returnError(ServiceUtil.getErrorMessage(contentResp));
      }
    }

    return ServiceUtil.returnSuccess();
  }