Beispiel #1
0
  /**
   * get a IQuotaSingleInstance list and an string with the instance and return all quotas about
   * belong to this instance.
   *
   * @return
   */
  private List<IQuotaSingleInstance> findQuotasByInstance(
      List<IQuotaSingleInstance> aQuotas, String aInstance) {

    List<IQuotaSingleInstance> lQResult = new FastList<IQuotaSingleInstance>();

    if (aQuotas.size() > 0) {
      IQuotaSingleInstance lQtmp = null;
      for (Iterator<IQuotaSingleInstance> it = aQuotas.iterator(); it.hasNext(); ) {
        IQuotaSingleInstance lQuotaSingle = it.next();
        QuotaChildSI lChild;
        lChild = lQuotaSingle.getChildQuota(aInstance);
        if (null != lChild) {
          if (lQuotaSingle.getInstanceType().equals("Group")) {

            lQtmp =
                QuotaHelper.factorySingleInstance(
                    lChild.getValue(),
                    lChild.getInstance(),
                    lChild.getUuid(),
                    lQuotaSingle.getNamespace(),
                    lQuotaSingle.getQuotaType(),
                    lQuotaSingle.getQuotaIdentifier(),
                    lChild.getInstanceType(),
                    lQuotaSingle.getActions());
          }

          if (lQuotaSingle.getInstanceType().equals("User")) {

            lQtmp =
                QuotaHelper.factorySingleInstance(
                    lQuotaSingle.getvalue(),
                    lChild.getInstance(),
                    lChild.getUuid(),
                    lQuotaSingle.getNamespace(),
                    lQuotaSingle.getQuotaType(),
                    lQuotaSingle.getQuotaIdentifier(),
                    lChild.getInstanceType(),
                    lQuotaSingle.getActions());
          }

          if (lQtmp != null) {
            lQResult.add(lQtmp);
          }
        }
      }
    }
    return lQResult;
  }
Beispiel #2
0
  /**
   * @param aUuid
   * @param aInstance
   * @return
   */
  @Override
  public IQuotaSingleInstance getQuota(String aUuid, String aInstance) {

    IQuotaSingleInstance lQuotaInstance =
        (IQuotaSingleInstance) mQuotaStorage.getQuotaByUuid(aUuid);

    if (lQuotaInstance.getInstance().equals(aInstance)) {
      return lQuotaInstance;
    } else {

      QuotaChildSI lQuotaChild = lQuotaInstance.getChildQuota(aInstance);
      if (null != lQuotaChild) {

        IQuotaSingleInstance lSingle =
            new QuotaBaseInstance(
                lQuotaChild.getValue(),
                aInstance,
                aUuid,
                lQuotaInstance.getNamespace(),
                lQuotaInstance.getQuotaType(),
                lQuotaInstance.getQuotaIdentifier(),
                lQuotaChild.getInstanceType(),
                lQuotaInstance.getActions());

        return lSingle;
      }
    }
    return null;
  }
Beispiel #3
0
  /**
   * get a IQuotaSingleInstance list and an string with the instanceType and return the
   * IQuotaSingleInstance.
   *
   * @return
   */
  private IQuotaSingleInstance findQuotaByInstance(
      List<IQuotaSingleInstance> aQuotas, String aInstance, String aActions) {

    IQuotaSingleInstance lQResult = null;

    for (Iterator<IQuotaSingleInstance> it = aQuotas.iterator(); it.hasNext(); ) {
      IQuotaSingleInstance lQuotaSingle = it.next();
      QuotaChildSI lChild;
      lChild = lQuotaSingle.getChildQuota(aInstance);
      if (null != lChild) {
        if (!lQuotaSingle.getActions().equals(aActions)) {
          continue;
        }
        if (lQuotaSingle.getInstanceType().equals("Group")) {

          lQResult =
              QuotaHelper.factorySingleInstance(
                  lChild.getValue(),
                  lChild.getInstance(),
                  lChild.getUuid(),
                  lQuotaSingle.getNamespace(),
                  lQuotaSingle.getQuotaType(),
                  lQuotaSingle.getQuotaIdentifier(),
                  lChild.getInstanceType(),
                  lQuotaSingle.getActions());
        }

        if (lQuotaSingle.getInstanceType().equals("User")) {

          lQResult =
              QuotaHelper.factorySingleInstance(
                  lQuotaSingle.getvalue(),
                  lChild.getInstance(),
                  lChild.getUuid(),
                  lQuotaSingle.getNamespace(),
                  lQuotaSingle.getQuotaType(),
                  lQuotaSingle.getQuotaIdentifier(),
                  lChild.getInstanceType(),
                  lQuotaSingle.getActions());
        }

        return lQResult;
      }
    }
    return null;
  }