コード例 #1
0
 public boolean tooFast(String ip) {
   String[] exclIps = Config.EXCLUDED_IP.split(",");
   for (String exclIp : exclIps) {
     if (ip.equals(exclIp)) return false;
   }
   Long banned = ban.get(ip);
   if (banned != null) {
     if (System.currentTimeMillis() < banned) return true;
     else {
       ban.remove(ip);
       return false;
     }
   }
   Long time = flood.get(ip);
   if (time == null) {
     flood.put(ip, System.currentTimeMillis() + Config.FAST_RECONNECTION_TIME * 1000);
     return false;
   } else {
     if (time > System.currentTimeMillis()) {
       log.info(
           "[AUDIT]FloodProtector:"
               + ip
               + " IP too fast connection attemp. blocked for "
               + Config.WRONG_LOGIN_BAN_TIME
               + " min");
       ban.put(ip, System.currentTimeMillis() + Config.WRONG_LOGIN_BAN_TIME * 60000);
       return true;
     } else return false;
   }
 }
コード例 #2
0
ファイル: Creature.java プロジェクト: soulxj/aion-cn
  /**
   * @param cooldownId
   * @return
   */
  public boolean isSkillDisabled(SkillTemplate template) {

    if (skillCoolDowns == null) return false;

    int cooldownId = template.getCooldownId();
    Long coolDown = skillCoolDowns.get(cooldownId);
    if (coolDown == null) {
      return false;
    }

    if (coolDown < System.currentTimeMillis()) {
      removeSkillCoolDown(cooldownId);
      return false;
    }

    /*
     * Some shared cooldown skills have indipendent and different cooldown they must not be blocked
     */
    if (skillCoolDownsBase != null && skillCoolDownsBase.get(cooldownId) != null) {
      if ((template.getDuration()
              + template.getCooldown() * 100
              + skillCoolDownsBase.get(cooldownId))
          < System.currentTimeMillis()) return false;
    }

    return true;
  }
コード例 #3
0
  @Override
  public void loadCraftCooldowns(final Player player) {
    Connection con = null;
    FastMap<Integer, Long> craftCoolDowns = new FastMap<Integer, Long>();
    try {
      con = DatabaseFactory.getConnection();
      PreparedStatement stmt = con.prepareStatement(SELECT_QUERY);

      stmt.setInt(1, player.getObjectId());
      ResultSet rset = stmt.executeQuery();

      while (rset.next()) {
        int delayId = rset.getInt("delay_id");
        long reuseTime = rset.getLong("reuse_time");
        int delay = (int) ((reuseTime - System.currentTimeMillis()) / 1000);

        if (delay > 0) {
          craftCoolDowns.put(delayId, reuseTime);
        }
      }
      player.getCraftCooldownList().setCraftCoolDowns(craftCoolDowns);
      rset.close();
      stmt.close();
    } catch (SQLException e) {
      log.error("LoadcraftCoolDowns", e);
    } finally {
      DatabaseFactory.close(con);
    }
  }
コード例 #4
0
  /** Find objects that are in visibility range. */
  protected void findVisibleObjects() {
    if (owner == null || !owner.isSpawned()) {
      return;
    }

    MapRegion[] regions = owner.getActiveRegion().getNeighbours();
    for (int i = 0; i < regions.length; i++) {
      MapRegion r = regions[i];
      FastMap<Integer, VisibleObject> objects = r.getObjects();
      for (FastMap.Entry<Integer, VisibleObject> e = objects.head(), mapEnd = objects.tail();
          (e = e.getNext()) != mapEnd; ) {
        VisibleObject newObject = e.getValue();
        if (newObject == owner || newObject == null) {
          continue;
        }

        if (!isAwareOf(newObject)) {
          continue;
        }
        if (knownObjects.containsKey(newObject.getObjectId())) {
          continue;
        }

        if (!checkObjectInRange(newObject)
            && !newObject.getKnownList().checkReversedObjectInRange(owner)) {
          continue;
        }

        /** New object is not known. */
        if (add(newObject)) {
          newObject.getKnownList().add(owner);
        }
      }
    }
  }
コード例 #5
0
  public ModelReader(String modelName) throws GenericEntityException {
    this.modelName = modelName;
    entityResourceHandlers = FastList.newInstance();
    resourceHandlerEntities = FastMap.newInstance();
    entityResourceHandlerMap = FastMap.newInstance();

    EntityModelReaderInfo entityModelReaderInfo =
        EntityConfigUtil.getEntityModelReaderInfo(modelName);

    if (entityModelReaderInfo == null) {
      throw new GenericEntityConfException(
          "Cound not find an entity-model-reader with the name " + modelName);
    }

    // get all of the main resource model stuff, ie specified in the entityengine.xml file
    for (Element resourceElement : entityModelReaderInfo.resourceElements) {
      ResourceHandler handler =
          new MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME, resourceElement);
      entityResourceHandlers.add(handler);
    }

    // get all of the component resource model stuff, ie specified in each ofbiz-component.xml file
    for (ComponentConfig.EntityResourceInfo componentResourceInfo :
        ComponentConfig.getAllEntityResourceInfos("model")) {
      if (modelName.equals(componentResourceInfo.readerName)) {
        entityResourceHandlers.add(componentResourceInfo.createResourceHandler());
      }
    }
  }
コード例 #6
0
  public static List<Map<String, BigDecimal>> getPackageSplit(
      DispatchContext dctx, List<Map<String, Object>> shippableItemInfo, BigDecimal maxWeight) {
    // create the package list w/ the first package
    List<Map<String, BigDecimal>> packages = FastList.newInstance();

    if (UtilValidate.isNotEmpty(shippableItemInfo)) {
      for (Map<String, Object> itemInfo : shippableItemInfo) {
        long pieces = ((Long) itemInfo.get("piecesIncluded")).longValue();
        BigDecimal totalQuantity = (BigDecimal) itemInfo.get("quantity");
        BigDecimal totalWeight = (BigDecimal) itemInfo.get("weight");
        String productId = (String) itemInfo.get("productId");

        // sanity check
        if (pieces < 1) {
          pieces = 1; // can NEVER be less than one
        }
        BigDecimal weight = totalWeight.divide(BigDecimal.valueOf(pieces), generalRounding);
        for (int z = 1; z <= totalQuantity.intValue(); z++) {
          BigDecimal partialQty =
              pieces > 1
                  ? BigDecimal.ONE.divide(BigDecimal.valueOf(pieces), generalRounding)
                  : BigDecimal.ONE;
          for (long x = 0; x < pieces; x++) {
            if (weight.compareTo(maxWeight) >= 0) {
              Map<String, BigDecimal> newPackage = FastMap.newInstance();
              newPackage.put(productId, partialQty);
              packages.add(newPackage);
            } else if (totalWeight.compareTo(BigDecimal.ZERO) > 0) {
              // create the first package
              if (packages.size() == 0) {
                packages.add(FastMap.<String, BigDecimal>newInstance());
              }

              // package loop
              boolean addedToPackage = false;
              for (Map<String, BigDecimal> packageMap : packages) {
                if (!addedToPackage) {
                  BigDecimal packageWeight =
                      calcPackageWeight(dctx, packageMap, shippableItemInfo, weight);
                  if (packageWeight.compareTo(maxWeight) <= 0) {
                    BigDecimal qty = packageMap.get(productId);
                    qty = UtilValidate.isEmpty(qty) ? BigDecimal.ZERO : qty;
                    packageMap.put(productId, qty.add(partialQty));
                    addedToPackage = true;
                  }
                }
              }
              if (!addedToPackage) {
                Map<String, BigDecimal> packageMap = FastMap.newInstance();
                packageMap.put(productId, partialQty);
                packages.add(packageMap);
              }
            }
          }
        }
      }
    }
    return packages;
  }
コード例 #7
0
 public void delVisualObject(VisibleObject object, boolean isOutOfRange) {
   if (visualObjects.remove(object.getObjectId()) != null) {
     if (visualPlayers != null) {
       visualPlayers.remove(object.getObjectId());
     }
     owner.getController().notSee(object, isOutOfRange);
   }
 }
コード例 #8
0
  public Map<K, V> getAll(Collection<K> keys) {
    FastMap<K, V> m = new FastMap<K, V>();
    for (K key : keys) {
      m.put(key, get(key));
    }

    return m;
  }
コード例 #9
0
ファイル: ArmorSetsTable.java プロジェクト: rean1m5/lucera2
  private void loadData(String SQL) {
    Connection con = null;
    try {
      con = L2DatabaseFactory.getInstance().getConnection(con);
      // L2EMU_EDIT
      PreparedStatement statement = con.prepareStatement(SQL);
      // L2EMU_EDIT
      ResultSet rset = statement.executeQuery();

      while (rset.next()) {
        int chest = rset.getInt("chest");
        int legs = rset.getInt("legs");
        int head = rset.getInt("head");
        int gloves = rset.getInt("gloves");
        int feet = rset.getInt("feet");
        int skill_id = rset.getInt("skill_id");
        int skill_lvl = rset.getInt("skill_lvl");

        // L2EMU_ADD
        int skillset_id = rset.getInt("skillset_id");
        // L2EMU_ADD

        int shield = rset.getInt("shield");
        int shield_skill_id = rset.getInt("shield_skill_id");
        int enchant6skill = rset.getInt("enchant6skill");

        // L2EMU_EDIT
        _armorSets.put(
            chest,
            new L2ArmorSet(
                chest,
                legs,
                head,
                gloves,
                feet,
                skill_id,
                skill_lvl,
                skillset_id,
                shield,
                shield_skill_id,
                enchant6skill));
        // L2EMU_EDIT
      }

      _log.info("ArmorSetsTable: Loaded " + _armorSets.size() + " armor sets.");

      rset.close();
      statement.close();
    } catch (Exception e) {
      _log.warn("Error while loading armor sets " + e.getMessage());
    } finally {
      try {
        if (con != null) con.close();
      } catch (Exception e) {
      }
    }
  }
コード例 #10
0
 /**
  * Delete VisibleObject from this KnownList.
  *
  * @param object
  */
 private void del(VisibleObject object, boolean isOutOfRange) {
   /** object was known. */
   if (knownObjects.remove(object.getObjectId()) != null) {
     if (knownPlayers != null) {
       knownPlayers.remove(object.getObjectId());
     }
     delVisualObject(object, isOutOfRange);
   }
 }
コード例 #11
0
ファイル: ThreadLocal.java プロジェクト: KosBeg/jwebsocket
 public Object get() {
   FastMap localMap = getLocalMap();
   Object value = localMap.get(this);
   if ((value == null) && !(localMap.containsKey(this))) {
     value = initialValue();
     localMap.put(this, value);
   }
   return value;
 }
コード例 #12
0
ファイル: StringLongMap.java プロジェクト: SergeyLee/jss7
 @Override
 public void updateData(String name) {
   synchronized (this) {
     LongValue val = data.get(name);
     if (val == null) {
       val = new LongValue();
       data.put(name, val);
     }
     val.updateValue();
   }
 }
コード例 #13
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();
  }
コード例 #14
0
ファイル: ThreadLocal.java プロジェクト: KosBeg/jwebsocket
 private FastMap newLocalMap() {
   // First, do some cleanup (remove dead threads).
   for (FastMap.Entry e = THREAD_TO_LOCAL_MAP.head(), end = THREAD_TO_LOCAL_MAP.tail();
       (e = (FastMap.Entry) e.getNext()) != end; ) {
     Thread thread = (Thread) e.getKey();
     if (!thread.isAlive()) {
       THREAD_TO_LOCAL_MAP.remove(thread);
     }
   }
   FastMap localMap = new FastMap();
   THREAD_TO_LOCAL_MAP.put(Thread.currentThread(), localMap);
   return localMap;
 }
コード例 #15
0
 /** Clear known list. Used when object is despawned. */
 public void clear() {
   for (VisibleObject object : knownObjects.values()) {
     object.getKnownList().del(owner, false);
   }
   knownObjects.clear();
   if (knownPlayers != null) {
     knownPlayers.clear();
   }
   visualObjects.clear();
   if (visualPlayers != null) {
     visualPlayers.clear();
   }
 }
コード例 #16
0
 public void doOnAllObjects(Visitor<VisibleObject> visitor) {
   try {
     for (FastMap.Entry<Integer, VisibleObject> e = knownObjects.head(),
             mapEnd = knownObjects.tail();
         (e = e.getNext()) != mapEnd; ) {
       VisibleObject newObject = e.getValue();
       if (newObject != null) {
         visitor.visit(newObject);
       }
     }
   } catch (Exception ex) {
     // log.error("Exception when running visitor on all objects" + ex);
   }
 }
コード例 #17
0
ファイル: PaymentWorker.java プロジェクト: zzj1213/BIGITWEB
  public static List<Map<String, GenericValue>> getPartyPaymentMethodValueMaps(
      Delegator delegator, String partyId, Boolean showOld) {
    List<Map<String, GenericValue>> paymentMethodValueMaps = FastList.newInstance();
    try {
      List<GenericValue> paymentMethods =
          delegator.findByAnd("PaymentMethod", UtilMisc.toMap("partyId", partyId));

      if (!showOld) paymentMethods = EntityUtil.filterByDate(paymentMethods, true);

      for (GenericValue paymentMethod : paymentMethods) {
        Map<String, GenericValue> valueMap = FastMap.newInstance();

        paymentMethodValueMaps.add(valueMap);
        valueMap.put("paymentMethod", paymentMethod);
        if ("CREDIT_CARD".equals(paymentMethod.getString("paymentMethodTypeId"))) {
          GenericValue creditCard = paymentMethod.getRelatedOne("CreditCard");
          if (creditCard != null) valueMap.put("creditCard", creditCard);
        } else if ("GIFT_CARD".equals(paymentMethod.getString("paymentMethodTypeId"))) {
          GenericValue giftCard = paymentMethod.getRelatedOne("GiftCard");
          if (giftCard != null) valueMap.put("giftCard", giftCard);
        } else if ("EFT_ACCOUNT".equals(paymentMethod.getString("paymentMethodTypeId"))) {
          GenericValue eftAccount = paymentMethod.getRelatedOne("EftAccount");
          if (eftAccount != null) valueMap.put("eftAccount", eftAccount);
        }
      }
    } catch (GenericEntityException e) {
      Debug.logWarning(e, module);
    }
    return paymentMethodValueMaps;
  }
コード例 #18
0
ファイル: Fort.java プロジェクト: rean1m5/lucera2
 /** Load All Functions */
 private void loadFunctions() {
   Connection con = null;
   try {
     PreparedStatement statement;
     ResultSet rs;
     con = L2DatabaseFactory.getInstance().getConnection(con);
     statement = con.prepareStatement("SELECT * FROM fort_functions WHERE fortId = ?");
     statement.setInt(1, getFortId());
     rs = statement.executeQuery();
     while (rs.next()) {
       _function.put(
           rs.getInt("type"),
           new FortFunction(
               rs.getInt("type"),
               rs.getInt("lvl"),
               rs.getInt("lease"),
               0,
               rs.getLong("rate"),
               rs.getLong("endTime"),
               true));
     }
     statement.close();
   } catch (Exception e) {
     _log.fatal("Exception: Fort.loadFunctions(): " + e.getMessage(), e);
   } finally {
     try {
       con.close();
     } catch (Exception e) {
     }
   }
 }
コード例 #19
0
    public boolean isAuthorized(XmlRpcRequest xmlRpcReq) throws XmlRpcException {
      XmlRpcHttpRequestConfig config = (XmlRpcHttpRequestConfig) xmlRpcReq.getConfig();

      ModelService model;
      try {
        model = dispatcher.getDispatchContext().getModelService(xmlRpcReq.getMethodName());
      } catch (GenericServiceException e) {
        throw new XmlRpcException(e.getMessage(), e);
      }

      if (model != null && model.auth) {
        String username = config.getBasicUserName();
        String password = config.getBasicPassword();

        // check the account
        Map<String, Object> context = FastMap.newInstance();
        context.put("login.username", username);
        context.put("login.password", password);

        Map<String, Object> resp;
        try {
          resp = dispatcher.runSync("userLogin", context);
        } catch (GenericServiceException e) {
          throw new XmlRpcException(e.getMessage(), e);
        }

        if (ServiceUtil.isError(resp)) {
          return false;
        }
      }

      return true;
    }
コード例 #20
0
ファイル: SagePayUtil.java プロジェクト: yuri0x7c1/opentaps-1
  public static Map<String, Object> buildCardAuthorisationPaymentResponse(
      Boolean authResult,
      String authCode,
      String authFlag,
      BigDecimal processAmount,
      String authRefNum,
      String authAltRefNum,
      String authMessage) {

    Map<String, Object> result = FastMap.newInstance();
    if (authResult != null) {
      result.put("authResult", authResult);
    }
    if (authCode != null) {
      result.put("authCode", authCode);
    }
    if (authFlag != null) {
      result.put("authFlag", authFlag);
    }
    if (processAmount != null) {
      result.put("processAmount", processAmount);
    }
    if (authRefNum != null) {
      result.put("authRefNum", authRefNum);
    }
    if (authAltRefNum != null) {
      result.put("authAltRefNum", authAltRefNum);
    }
    if (authMessage != null) {
      result.put("authMessage", authMessage);
    }
    return result;
  }
コード例 #21
0
ファイル: SagePayUtil.java プロジェクト: yuri0x7c1/opentaps-1
  public static Map<String, Object> buildCardCapturePaymentResponse(
      Boolean captureResult,
      String captureCode,
      String captureFlag,
      BigDecimal captureAmount,
      String captureRefNum,
      String captureAltRefNum,
      String captureMessage) {

    Map<String, Object> result = FastMap.newInstance();
    if (captureResult != null) {
      result.put("captureResult", captureResult);
    }
    if (captureCode != null) {
      result.put("captureCode", captureCode);
    }
    if (captureFlag != null) {
      result.put("captureFlag", captureFlag);
    }
    if (captureAmount != null) {
      result.put("captureAmount", captureAmount);
    }
    if (captureRefNum != null) {
      result.put("captureRefNum", captureRefNum);
    }
    if (captureAltRefNum != null) {
      result.put("captureAltRefNum", captureAltRefNum);
    }
    if (captureMessage != null) {
      result.put("captureMessage", captureMessage);
    }
    return result;
  }
コード例 #22
0
 public void doOnAllPlayers(Visitor<Player> visitor) {
   if (knownPlayers == null) {
     return;
   }
   try {
     for (FastMap.Entry<Integer, Player> e = knownPlayers.head(), mapEnd = knownPlayers.tail();
         (e = e.getNext()) != mapEnd; ) {
       Player player = e.getValue();
       if (player != null) {
         visitor.visit(player);
       }
     }
   } catch (Exception ex) {
     // log.error("Exception when running visitor on all players" + ex);
   }
 }
コード例 #23
0
ファイル: SagePayUtil.java プロジェクト: yuri0x7c1/opentaps-1
  public static Map<String, Object> buildCardRefundPaymentResponse(
      Boolean refundResult,
      String refundCode,
      BigDecimal refundAmount,
      String refundRefNum,
      String refundAltRefNum,
      String refundMessage) {

    Map<String, Object> result = FastMap.newInstance();
    if (refundResult != null) {
      result.put("refundResult", refundResult);
    }
    if (refundCode != null) {
      result.put("refundCode", refundCode);
    }
    if (refundAmount != null) {
      result.put("refundAmount", refundAmount);
    }
    if (refundRefNum != null) {
      result.put("refundRefNum", refundRefNum);
    }
    if (refundAltRefNum != null) {
      result.put("refundAltRefNum", refundAltRefNum);
    }
    if (refundMessage != null) {
      result.put("refundMessage", refundMessage);
    }
    return result;
  }
コード例 #24
0
ファイル: UtilCache.java プロジェクト: CrasOu/haze
 private Map<String, Object> createLineInfo(int keyNum, K key, V value) {
   Map<String, Object> lineInfo = FastMap.newInstance();
   lineInfo.put("elementKey", key);
   lineInfo.put("lineSize", findSizeInBytes(value));
   lineInfo.put("keyNum", keyNum);
   return lineInfo;
 }
コード例 #25
0
ファイル: ArmorSetsTable.java プロジェクト: rean1m5/lucera2
 private void loadData() {
   _armorSets.clear();
   loadData(
       "SELECT chest, legs, head, gloves, feet, skill_id, skill_lvl, skillset_id, shield, shield_skill_id, enchant6skill, mw_chest, mw_legs, mw_head, mw_gloves, mw_feet, mw_shield FROM armorsets");
   loadData(
       "SELECT chest, legs, head, gloves, feet, skill_id, skill_lvl, skillset_id, shield, shield_skill_id, enchant6skill, chest, legs, head, gloves, feet, shield FROM custom_armorsets");
 }
コード例 #26
0
ファイル: PartyWorker.java プロジェクト: rbingfeng/GreenTea
  public static Map<String, GenericValue> getPartyOtherValues(
      ServletRequest request,
      String partyId,
      String partyAttr,
      String personAttr,
      String partyGroupAttr) {
    Delegator delegator = (Delegator) request.getAttribute("delegator");
    Map<String, GenericValue> result = FastMap.newInstance();
    try {
      GenericValue party = delegator.findByPrimaryKey("Party", UtilMisc.toMap("partyId", partyId));

      if (party != null) result.put(partyAttr, party);
    } catch (GenericEntityException e) {
      Debug.logWarning(e, "Problems getting Party entity", module);
    }

    try {
      GenericValue person =
          delegator.findByPrimaryKey("Person", UtilMisc.toMap("partyId", partyId));

      if (person != null) result.put(personAttr, person);
    } catch (GenericEntityException e) {
      Debug.logWarning(e, "Problems getting Person entity", module);
    }

    try {
      GenericValue partyGroup =
          delegator.findByPrimaryKey("PartyGroup", UtilMisc.toMap("partyId", partyId));

      if (partyGroup != null) result.put(partyGroupAttr, partyGroup);
    } catch (GenericEntityException e) {
      Debug.logWarning(e, "Problems getting PartyGroup entity", module);
    }
    return result;
  }
コード例 #27
0
  public void renderContentEnd(
      Appendable writer, Map<String, Object> context, ModelScreenWidget.Content content)
      throws IOException {
    String expandedContentId = content.getContentId(context);
    String editMode = "Edit";
    String editRequest = content.getEditRequest(context);
    String enableEditName = content.getEnableEditName(context);
    String enableEditValue = (String) context.get(enableEditName);
    String urlString = "";
    if (editRequest != null && editRequest.toUpperCase().indexOf("IMAGE") > 0) {
      editMode += " Image";
    }

    if (UtilValidate.isNotEmpty(editRequest) && "true".equals(enableEditValue)) {
      HttpServletResponse response = (HttpServletResponse) context.get("response");
      HttpServletRequest request = (HttpServletRequest) context.get("request");
      if (request != null && response != null) {
        if (editRequest.indexOf("?") < 0) editRequest += "?";
        else editRequest += "&amp;";
        editRequest += "contentId=" + expandedContentId;
        ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
        RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
        urlString = rh.makeLink(request, response, editRequest, false, false, false);
      }

      Map<String, Object> parameters = FastMap.newInstance();
      parameters.put("urlString", urlString);
      parameters.put("editMode", editMode);
      parameters.put("editContainerStyle", content.getEditContainerStyle(context));
      parameters.put("editRequest", editRequest);
      parameters.put("enableEditValue", enableEditValue);
      executeMacro(writer, "renderContentEnd", parameters);
    }
  }
コード例 #28
0
 private int calculateSize() {
   int size = 0;
   for (Map.Entry<Integer, Long> entry : cooldowns.entrySet()) {
     size += DataManager.SKILL_DATA.getSkillsForCooldownId(entry.getKey()).size();
   }
   return size;
 }
コード例 #29
0
  public String invoke(
      Event event, RequestMap requestMap, HttpServletRequest request, HttpServletResponse response)
      throws EventHandlerException {
    try {
      Map<String, Object> groovyContext = FastMap.newInstance();
      groovyContext.put("request", request);
      groovyContext.put("response", response);
      HttpSession session = request.getSession();
      groovyContext.put("session", session);

      groovyContext.put("dispatcher", request.getAttribute("dispatcher"));
      groovyContext.put("delegator", request.getAttribute("delegator"));
      groovyContext.put("security", request.getAttribute("security"));
      groovyContext.put("locale", UtilHttp.getLocale(request));
      groovyContext.put("timeZone", UtilHttp.getTimeZone(request));
      groovyContext.put("userLogin", session.getAttribute("userLogin"));
      groovyContext.put(
          "parameters",
          UtilHttp.getCombinedMap(
              request,
              UtilMisc.toSet(
                  "delegator", "dispatcher", "security", "locale", "timeZone", "userLogin")));

      Object result = GroovyUtil.runScriptAtLocation(event.path + event.invoke, groovyContext);
      // check the result
      if (result != null && !(result instanceof String)) {
        throw new EventHandlerException(
            "Event did not return a String result, it returned a " + result.getClass().getName());
      }
      return (String) result;
    } catch (Exception e) {
      throw new EventHandlerException("Groovy Event Error", e);
    }
  }
コード例 #30
0
  /** Creates request fields for a customer, such as email and postal addresses. */
  private static Map buildCustomerRequest(Delegator delegator, Map context)
      throws GenericEntityException {
    Map request = FastMap.newInstance();
    GenericValue customer = (GenericValue) context.get("billToParty");
    GenericValue address = (GenericValue) context.get("billingAddress");
    GenericValue email = (GenericValue) context.get("billToEmail");

    if (customer != null && "Person".equals(customer.getEntityName())) {
      request.put("x_first_name", customer.get("firstName"));
      request.put("x_last_name", customer.get("lastName"));
    }
    if (customer != null && "PartyGroup".equals(customer.getEntityName())) {
      request.put("x_company", customer.get("groupName"));
    }
    if (address != null) {
      request.put("x_address", address.get("address1"));
      request.put("x_city", address.get("city"));
      request.put("x_zip", address.get("postalCode"));
      GenericValue country = address.getRelatedOneCache("CountryGeo");
      if (country != null) {
        request.put("x_country", country.get("geoCode"));
        if ("USA".equals(country.get("geoId"))) {
          request.put("x_state", address.get("stateProvinceGeoId"));
        }
      }
    }
    if (email != null && UtilValidate.isNotEmpty(email.getString("infoString"))) {
      request.put("x_email", email.get("infoString"));
    }

    return request;
  }