Beispiel #1
0
 @RequestMapping(value = "/levelsByForm", produces = MediaType.APPLICATION_JSON_VALUE)
 @ResponseBody
 public List<SignatureLevel> getAllowedLevelsByForm(
     @RequestParam("form") SignatureForm signatureForm, @RequestParam("isSign") Boolean isSign) {
   List<SignatureLevel> levels = new ArrayList<SignatureLevel>();
   if (signatureForm != null) {
     switch (signatureForm) {
       case CAdES:
         if (BooleanUtils.isTrue(isSign)) {
           levels.add(SignatureLevel.CAdES_BASELINE_B);
         }
         levels.add(SignatureLevel.CAdES_BASELINE_T);
         levels.add(SignatureLevel.CAdES_BASELINE_LT);
         levels.add(SignatureLevel.CAdES_BASELINE_LTA);
         break;
       case PAdES:
         if (BooleanUtils.isTrue(isSign)) {
           levels.add(SignatureLevel.PAdES_BASELINE_B);
         }
         levels.add(SignatureLevel.PAdES_BASELINE_T);
         levels.add(SignatureLevel.PAdES_BASELINE_LT);
         levels.add(SignatureLevel.PAdES_BASELINE_LTA);
         break;
       case XAdES:
         if (BooleanUtils.isTrue(isSign)) {
           levels.add(SignatureLevel.XAdES_BASELINE_B);
         }
         levels.add(SignatureLevel.XAdES_BASELINE_T);
         levels.add(SignatureLevel.XAdES_BASELINE_LT);
         levels.add(SignatureLevel.XAdES_BASELINE_LTA);
         break;
       case ASiC_S:
         if (BooleanUtils.isTrue(isSign)) {
           levels.add(SignatureLevel.ASiC_S_BASELINE_B);
         }
         levels.add(SignatureLevel.ASiC_S_BASELINE_T);
         levels.add(SignatureLevel.ASiC_S_BASELINE_LT);
         levels.add(SignatureLevel.ASiC_S_BASELINE_LTA);
         break;
       case ASiC_E:
         if (BooleanUtils.isTrue(isSign)) {
           levels.add(SignatureLevel.ASiC_E_BASELINE_B);
         }
         levels.add(SignatureLevel.ASiC_E_BASELINE_T);
         levels.add(SignatureLevel.ASiC_E_BASELINE_LT);
         levels.add(SignatureLevel.ASiC_E_BASELINE_LTA);
         break;
       default:
         break;
     }
   }
   return levels;
 }
Beispiel #2
0
 @CheckForNull
 private static Double getDoubleValue(MeasureDto measure, Metric metric) {
   Double value = measure.getValue();
   if (BooleanUtils.isTrue(metric.isOptimizedBestValue()) && value == null) {
     value = metric.getBestValue();
   }
   return value;
 }
 public NiftyInstanceResponse(NiftyInstance niftyInstance) {
   this.instanceType = niftyInstance.getInstanceType();
   this.status = niftyInstance.getStatus();
   this.dnsName = niftyInstance.getDnsName();
   this.privateDnsName = niftyInstance.getPrivateDnsName();
   this.ipAddress = niftyInstance.getIpAddress();
   this.privateIpAddress = niftyInstance.getPrivateIpAddress();
   this.initialized = BooleanUtils.isTrue(niftyInstance.getInitialized());
 }
 public static void fromFudgeMsg(
     FudgeDeserializer deserializer, FudgeMsg msg, EquitySecurity object) {
   FinancialSecurityFudgeBuilder.fromFudgeMsg(deserializer, msg, object);
   object.setShortName(msg.getString(SHORT_NAME_FIELD_NAME));
   object.setExchange(msg.getString(EXCHANGE_FIELD_NAME));
   object.setExchangeCode(msg.getString(EXCHANGE_CODE_FIELD_NAME));
   object.setCompanyName(msg.getString(COMPANY_NAME_FIELD_NAME));
   object.setCurrency(msg.getValue(Currency.class, CURRENCY_FIELD_NAME));
   object.setGicsCode(msg.getValue(GICSCode.class, GICS_CODE_FIELD_NAME));
   object.setPreferred(BooleanUtils.isTrue(msg.getBoolean(PREFERRED_FIELD_NAME)));
 }
 public Boolean isOverriden() {
   Boolean result = false;
   TypeJavaSymbol enclosingClass = enclosingClass();
   for (JavaType.ClassJavaType superType : enclosingClass.superTypes()) {
     Boolean overrideFromType = overridesFromSymbol(superType);
     if (overrideFromType == null) {
       result = null;
     } else if (BooleanUtils.isTrue(overrideFromType)) {
       return true;
     }
   }
   return result;
 }
 @PUT
 @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
 @Produces(MediaType.APPLICATION_JSON)
 public Response putJSON(@FormParam("name") String name, @FormParam("hidden") Boolean isHidden) {
   PortfolioDocument doc = data().getPortfolio();
   if (doc.isLatest() == false) {
     return Response.status(Status.FORBIDDEN).entity(getHTML()).build();
   }
   name = StringUtils.trimToNull(name);
   DocumentVisibility visibility =
       BooleanUtils.isTrue(isHidden) ? DocumentVisibility.HIDDEN : DocumentVisibility.VISIBLE;
   updatePortfolio(name, visibility, doc);
   return Response.ok().build();
 }
  /**
   * Méthode en charge de construire la liste des items pour un thème du modèle. Il s'agit de
   * construire un item par catégorie et par thème/catégorie.
   *
   * @param grille La grille.
   * @param theme Le thème.
   * @return La liste des items correspondants aux catégories.
   */
  private Collection<Item> buildItems(final Grille grille, final Theme theme) {
    final SortedSet<Item> items = new TreeSet<Item>(new ItemComparator());

    // Gestion des thèmes qui sont aussi des catégories
    if (BooleanUtils.isTrue(theme.isCategorie())) {
      items.add(this.buildItem(grille, theme, null));
    }

    // gestion des catégories.
    for (final Categorie categorie : theme.getCategories()) {
      items.add(this.buildItem(grille, theme, categorie));
    }
    return items;
  }
  @Override
  public void writeAttribute(String localName, String value) throws XMLStreamException {
    try {

      if (!objectQueue.isEmpty()) {
        if (StringUtils.equals(CmsConstants.EXPORT_AS_AN_ARRAY_INSTRUCTION, localName)) {
          objectQueue.peek().exportAsAnArray = BooleanUtils.isTrue(BooleanUtils.toBoolean(value));
        } else {
          objectQueue.peek().addAttribute(localName, value);
        }
      }

    } catch (Exception e) {
      throw new XMLStreamException(e);
    }
  }
  /**
   * @param volumeId
   * @return
   */
  @RequestMapping(method = RequestMethod.GET)
  public ModelAndView setupForm(
      @ModelAttribute("command") ShowExplorerVolumeCommand command, BindingResult result) {
    Map<String, Object> model = new HashMap<String, Object>(0);

    VolumeExplorer volumeExplorer =
        new VolumeExplorer(command.getSummaryId(), command.getVolNum(), command.getVolLetExt());
    volumeExplorer.setImage(new Image());
    volumeExplorer.getImage().setImageProgTypeNum(command.getImageProgTypeNum());
    volumeExplorer
        .getImage()
        .setMissedNumbering(StringUtils.nullTrim(command.getMissedNumbering()));
    volumeExplorer
        .getImage()
        .setImageRectoVerso(
            Image.ImageRectoVerso.convertFromString(
                StringUtils.nullTrim(command.getImageRectoVerso())));
    volumeExplorer.getImage().setImageOrder(command.getImageOrder());
    volumeExplorer.getImage().setImageType(command.getImageType());
    volumeExplorer.getImage().setInsertNum(StringUtils.nullTrim(command.getInsertNum()));
    volumeExplorer
        .getImage()
        .setInsertLet(
            StringUtils.isNullableString(command.getInsertNum()) ? null : command.getInsertLet());
    volumeExplorer.setTotal(command.getTotal());
    volumeExplorer.setTotalRubricario(command.getTotalRubricario());
    volumeExplorer.setTotalCarta(command.getTotalCarta());
    volumeExplorer.setTotalAppendix(command.getTotalAppendix());
    volumeExplorer.setTotalOther(command.getTotalOther());
    volumeExplorer.setTotalGuardia(command.getTotalGuardia());

    try {
      volumeExplorer = getVolBaseService().getVolumeExplorer(volumeExplorer);
      model.put("volumeExplorer", volumeExplorer);

      Boolean hasInserts =
          getVolBaseService().hasInserts(command.getVolNum(), command.getVolLetExt());
      model.put("hasInsert", hasInserts);
    } catch (ApplicationThrowable ath) {
    }

    if (BooleanUtils.isTrue(command.getModalWindow())) {
      return new ModelAndView("volbase/ShowExplorerVolumeModalWindow", model);
    } else {
      return new ModelAndView("volbase/ShowExplorerVolume", model);
    }
  }
Beispiel #10
0
 @Nullable
 private Boolean overridesFromSymbol(JavaType.ClassJavaType classType) {
   Boolean result = false;
   if (classType.isTagged(JavaType.UNKNOWN)) {
     return null;
   }
   List<JavaSymbol> symbols = classType.getSymbol().members().lookup(name);
   for (JavaSymbol overrideSymbol : symbols) {
     if (overrideSymbol.isKind(JavaSymbol.MTH)
         && canOverride((MethodJavaSymbol) overrideSymbol)) {
       Boolean isOverriding = isOverriding((MethodJavaSymbol) overrideSymbol, classType);
       if (isOverriding == null) {
         result = null;
       } else if (BooleanUtils.isTrue(isOverriding)) {
         return true;
       }
     }
   }
   return result;
 }
  // -------------------------------------------------------------------------
  @PUT
  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  @Produces(MediaType.TEXT_HTML)
  public Response putHTML(@FormParam("name") String name, @FormParam("hidden") Boolean isHidden) {
    PortfolioDocument doc = data().getPortfolio();
    if (doc.isLatest() == false) {
      return Response.status(Status.FORBIDDEN).entity(getHTML()).build();
    }

    name = StringUtils.trimToNull(name);
    DocumentVisibility visibility =
        BooleanUtils.isTrue(isHidden) ? DocumentVisibility.HIDDEN : DocumentVisibility.VISIBLE;
    if (name == null) {
      FlexiBean out = createRootData();
      out.put("err_nameMissing", true);
      String html = getFreemarker().build("portfolios/portfolio-update.ftl", out);
      return Response.ok(html).build();
    }
    URI uri = updatePortfolio(name, visibility, doc);
    return Response.seeOther(uri).build();
  }
  /**
   * Updates the default/template rule options with those in the defaults element
   *
   * @param defaultsElement the ruleDefaults element
   * @param updatedRuleTemplate the Rule Template being updated
   * @return whether this is a delegation rule template
   */
  protected boolean updateRuleDefaults(Element defaultsElement, RuleTemplateBo updatedRuleTemplate)
      throws XmlException {
    // NOTE: implementation detail: in contrast with the other options, the delegate template, and
    // the rule attributes,
    // we unconditionally blow away the default rule and re-create it (we don't update the existing
    // one, if there is one)
    if (updatedRuleTemplate.getId() != null) {
      RuleBaseValues ruleDefaults =
          KEWServiceLocator.getRuleService()
              .findDefaultRuleByRuleTemplateId(updatedRuleTemplate.getId());
      if (ruleDefaults != null) {
        List ruleDelegationDefaults =
            KEWServiceLocator.getRuleDelegationService().findByDelegateRuleId(ruleDefaults.getId());
        // delete the rule
        KEWServiceLocator.getRuleService().delete(ruleDefaults.getId());
        // delete the associated rule delegation defaults
        for (Iterator iterator = ruleDelegationDefaults.iterator(); iterator.hasNext(); ) {
          RuleDelegationBo ruleDelegation = (RuleDelegationBo) iterator.next();
          KEWServiceLocator.getRuleDelegationService().delete(ruleDelegation.getRuleDelegationId());
        }
      }
    }

    boolean isDelegation = false;

    if (defaultsElement != null) {
      String delegationTypeCode =
          defaultsElement.getChildText(DELEGATION_TYPE, RULE_TEMPLATE_NAMESPACE);
      DelegationType delegationType = null;
      isDelegation = !org.apache.commons.lang.StringUtils.isEmpty(delegationTypeCode);

      String description = defaultsElement.getChildText(DESCRIPTION, RULE_TEMPLATE_NAMESPACE);

      // would normally be validated via schema but might not be present if invoking RuleXmlParser
      // directly
      if (description == null) {
        throw new XmlException("Description must be specified in rule defaults");
      }

      String fromDate = defaultsElement.getChildText(FROM_DATE, RULE_TEMPLATE_NAMESPACE);
      String toDate = defaultsElement.getChildText(TO_DATE, RULE_TEMPLATE_NAMESPACE);
      // toBooleanObject ensures that if the value is null (not set) that the Boolean object will
      // likewise be null (will not default to a value)
      Boolean forceAction =
          BooleanUtils.toBooleanObject(
              defaultsElement.getChildText(FORCE_ACTION, RULE_TEMPLATE_NAMESPACE));
      Boolean active =
          BooleanUtils.toBooleanObject(
              defaultsElement.getChildText(ACTIVE, RULE_TEMPLATE_NAMESPACE));

      if (isDelegation) {
        delegationType = DelegationType.parseCode(delegationTypeCode);
        if (delegationType == null) {
          throw new XmlException(
              "Invalid delegation type '"
                  + delegationType
                  + "'."
                  + "  Expected one of: "
                  + DelegationType.PRIMARY.getCode()
                  + ","
                  + DelegationType.SECONDARY.getCode());
        }
      }

      // create our "default rule" which encapsulates the defaults for the rule
      RuleBaseValues ruleDefaults = new RuleBaseValues();

      // set simple values
      ruleDefaults.setRuleTemplate(updatedRuleTemplate);
      ruleDefaults.setRuleTemplateId(updatedRuleTemplate.getId());
      ruleDefaults.setDocTypeName(DUMMY_DOCUMENT_TYPE);
      ruleDefaults.setTemplateRuleInd(Boolean.TRUE);
      ruleDefaults.setCurrentInd(Boolean.TRUE);
      ruleDefaults.setVersionNbr(new Integer(0));
      ruleDefaults.setDescription(description);

      // these are non-nullable fields, so default them if they were not set in the defaults section
      ruleDefaults.setForceAction(Boolean.valueOf(BooleanUtils.isTrue(forceAction)));
      ruleDefaults.setActive(Boolean.valueOf(BooleanUtils.isTrue(active)));

      if (ruleDefaults.getActivationDate() == null) {
        ruleDefaults.setActivationDate(new Timestamp(System.currentTimeMillis()));
      }

      ruleDefaults.setFromDateValue(formatDate("fromDate", fromDate));
      ruleDefaults.setToDateValue(formatDate("toDate", toDate));

      // ok, if this is a "Delegate Template", then we need to set this other RuleDelegation object
      // which contains
      // some delegation-related info
      RuleDelegationBo ruleDelegationDefaults = null;
      if (isDelegation) {
        ruleDelegationDefaults = new RuleDelegationBo();
        ruleDelegationDefaults.setDelegationRule(ruleDefaults);
        ruleDelegationDefaults.setDelegationType(delegationType);
        ruleDelegationDefaults.setResponsibilityId(KewApiConstants.ADHOC_REQUEST_RESPONSIBILITY_ID);
      }

      // explicitly save the new rule delegation defaults and default rule
      KEWServiceLocator.getRuleTemplateService()
          .saveRuleDefaults(ruleDelegationDefaults, ruleDefaults);
    } else {
      // do nothing, rule defaults will be deleted if ruleDefaults element is omitted
    }

    return isDelegation;
  }
  /** {@inheritDoc} */
  @Override
  public Long createFarm(Long userNo, String farmName, String comment) {
    // 引数チェック
    if (userNo == null) {
      throw new AutoApplicationException("ECOMMON-000003", "userNo");
    }
    if (farmName == null || farmName.length() == 0) {
      throw new AutoApplicationException("ECOMMON-000003", "farmName");
    }

    // 形式チェック
    if (!Pattern.matches("^[0-9a-z]|[0-9a-z][0-9a-z-]*[0-9a-z]$", farmName)) {
      throw new AutoApplicationException("ECOMMON-000012", "farmName");
    }

    // TODO: 長さチェック

    // ファーム名の一意チェック
    Farm checkFarm = farmDao.readByFarmName(farmName);
    if (checkFarm != null) {
      // 同名のファームが存在する場合
      throw new AutoApplicationException("ESERVICE-000201", farmName);
    }

    // ファームのドメイン名
    // TODO: 設定値の取得方法をうまくする
    String domainName = farmName + "." + Config.getProperty("dns.domain");

    // ファームの作成
    Farm farm = new Farm();
    farm.setFarmName(farmName);
    farm.setUserNo(userNo);
    farm.setComment(comment);
    farm.setDomainName(domainName);
    farm.setScheduled(false);
    farm.setComponentProcessing(false);
    farmDao.create(farm);

    // ファームごとのホストグループ作成
    Boolean useZabbix = BooleanUtils.toBooleanObject(Config.getProperty("zabbix.useZabbix"));
    if (BooleanUtils.isTrue(useZabbix)) {
      zabbixHostProcess.createFarmHostgroup(farm.getFarmNo());
    }

    // VMware関連情報の作成
    List<Platform> platforms = platformDao.readAll();
    for (Platform platform : platforms) {
      if ("vmware".equals(platform.getPlatformType()) == false) {
        continue;
      }

      if (vmwareKeyPairDao.countByUserNoAndPlatformNo(userNo, platform.getPlatformNo()) > 0) {
        // 空いているVLANを取得
        VmwareNetwork publicNetwork = null;
        VmwareNetwork privateNetwork = null;
        List<VmwareNetwork> vmwareNetworks =
            vmwareNetworkDao.readByPlatformNo(platform.getPlatformNo());
        for (VmwareNetwork vmwareNetwork : vmwareNetworks) {
          if (vmwareNetwork.getFarmNo() != null) {
            continue;
          }
          if (BooleanUtils.isTrue(vmwareNetwork.getPublicNetwork())) {
            if (publicNetwork == null) {
              publicNetwork = vmwareNetwork;
            }
          } else {
            if (privateNetwork == null) {
              privateNetwork = vmwareNetwork;
            }
          }
        }

        // VLANを割り当て
        if (publicNetwork != null) {
          publicNetwork.setFarmNo(farm.getFarmNo());
          vmwareNetworkDao.update(publicNetwork);
        }
        if (privateNetwork != null) {
          privateNetwork.setFarmNo(farm.getFarmNo());
          vmwareNetworkDao.update(privateNetwork);
        }
      }
    }

    // イベントログ出力
    eventLogger.log(
        EventLogLevel.INFO,
        farm.getFarmNo(),
        farmName,
        null,
        null,
        null,
        null,
        "FarmCreate",
        null,
        null,
        null);

    return farm.getFarmNo();
  }
  private <F extends FocusType> void processFocusFocus(
      LensContext<F> context,
      String activityDescription,
      XMLGregorianCalendar now,
      Task task,
      OperationResult result)
      throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException,
          PolicyViolationException, ObjectAlreadyExistsException, CommunicationException,
          ConfigurationException, SecurityViolationException {

    LensFocusContext<F> focusContext = context.getFocusContext();
    ObjectTemplateType objectTemplate = context.getFocusTemplate();

    boolean resetOnRename = true; // This is fixed now. TODO: make it configurable
    int maxIterations = 0;
    IterationSpecificationType iterationSpecificationType = null;
    if (objectTemplate != null) {
      iterationSpecificationType = objectTemplate.getIteration();
      maxIterations = LensUtil.determineMaxIterations(iterationSpecificationType);
    }
    int iteration = focusContext.getIteration();
    String iterationToken = focusContext.getIterationToken();
    boolean wasResetIterationCounter = false;

    PrismObject<F> focusCurrent = focusContext.getObjectCurrent();
    if (focusCurrent != null && iterationToken == null) {
      Integer focusIteration = focusCurrent.asObjectable().getIteration();
      if (focusIteration != null) {
        iteration = focusIteration;
      }
      iterationToken = focusCurrent.asObjectable().getIterationToken();
    }

    while (true) {

      ObjectTypeTemplateType objectPolicyConfigurationType =
          focusContext.getObjectPolicyConfigurationType();
      if (objectPolicyConfigurationType != null
          && BooleanUtils.isTrue(objectPolicyConfigurationType.isOidNameBoundMode())) {
        // Generate the name now - unless it is already present
        PrismObject<F> focusNew = focusContext.getObjectNew();
        if (focusNew != null) {
          PolyStringType focusNewName = focusNew.asObjectable().getName();
          if (focusNewName == null) {
            String newName = focusNew.getOid();
            if (newName == null) {
              newName = OidUtil.generateOid();
            }
            LOGGER.trace("Generating new name (bound to OID): {}", newName);
            PrismObjectDefinition<F> focusDefinition = focusContext.getObjectDefinition();
            PrismPropertyDefinition<PolyString> focusNameDef =
                focusDefinition.findPropertyDefinition(FocusType.F_NAME);
            PropertyDelta<PolyString> nameDelta =
                focusNameDef.createEmptyDelta(new ItemPath(FocusType.F_NAME));
            nameDelta.setValueToReplace(
                new PrismPropertyValue<PolyString>(
                    new PolyString(newName), OriginType.USER_POLICY, null));
            focusContext.swallowToSecondaryDelta(nameDelta);
            focusContext.recompute();
          }
        }
      }

      ExpressionVariables variables =
          Utils.getDefaultExpressionVariables(
              focusContext.getObjectNew(), null, null, null, context.getSystemConfiguration());
      if (iterationToken == null) {
        iterationToken =
            LensUtil.formatIterationToken(
                context,
                focusContext,
                iterationSpecificationType,
                iteration,
                expressionFactory,
                variables,
                task,
                result);
      }

      // We have to remember the token and iteration in the context.
      // The context can be recomputed several times. But we always want
      // to use the same iterationToken if possible. If there is a random
      // part in the iterationToken expression that we need to avoid recomputing
      // the token otherwise the value can change all the time (even for the same inputs).
      // Storing the token in the secondary delta is not enough because secondary deltas can be
      // dropped
      // if the context is re-projected.
      focusContext.setIteration(iteration);
      focusContext.setIterationToken(iterationToken);
      LOGGER.trace(
          "Focus {} processing, iteration {}, token '{}'",
          new Object[] {focusContext.getHumanReadableName(), iteration, iterationToken});

      String conflictMessage;
      if (!LensUtil.evaluateIterationCondition(
          context,
          focusContext,
          iterationSpecificationType,
          iteration,
          iterationToken,
          true,
          expressionFactory,
          variables,
          task,
          result)) {

        conflictMessage = "pre-iteration condition was false";
        LOGGER.debug(
            "Skipping iteration {}, token '{}' for {} because the pre-iteration condition was false",
            new Object[] {iteration, iterationToken, focusContext.getHumanReadableName()});
      } else {

        // INBOUND

        if (consistencyChecks) context.checkConsistence();
        // Loop through the account changes, apply inbound expressions
        inboundProcessor.processInbound(context, now, task, result);
        if (consistencyChecks) context.checkConsistence();
        context.recomputeFocus();
        LensUtil.traceContext(LOGGER, activityDescription, "inbound", false, context, false);
        if (consistencyChecks) context.checkConsistence();

        // ACTIVATION

        processActivation(context, now, result);

        // OBJECT TEMPLATE (before assignments)

        objectTemplateProcessor.processTemplate(
            context,
            ObjectTemplateMappingEvaluationPhaseType.BEFORE_ASSIGNMENTS,
            now,
            task,
            result);

        // ASSIGNMENTS

        assignmentProcessor.processAssignmentsProjections(context, now, task, result);
        assignmentProcessor.processOrgAssignments(context, result);
        context.recompute();

        assignmentProcessor.checkForAssignmentConflicts(context, result);

        // OBJECT TEMPLATE (after assignments)

        objectTemplateProcessor.processTemplate(
            context, ObjectTemplateMappingEvaluationPhaseType.AFTER_ASSIGNMENTS, now, task, result);
        context.recompute();

        // PASSWORD POLICY

        passwordPolicyProcessor.processPasswordPolicy(focusContext, context, result);

        // Processing done, check for success

        if (resetOnRename && !wasResetIterationCounter && willResetIterationCounter(focusContext)) {
          // Make sure this happens only the very first time during the first recompute.
          // Otherwise it will always change the token (especially if the token expression has a
          // random part)
          // hence the focusContext.getIterationToken() == null
          wasResetIterationCounter = true;
          if (iteration != 0) {
            iteration = 0;
            iterationToken = null;
            LOGGER.trace("Resetting iteration counter and token because rename was detected");
            cleanupContext(focusContext);
            continue;
          }
        }

        PrismObject<F> previewObjectNew = focusContext.getObjectNew();
        if (previewObjectNew == null) {
          // this must be delete
        } else {
          // Explicitly check for name. The checker would check for this also. But checking it here
          // will produce better error message
          PolyStringType objectName = previewObjectNew.asObjectable().getName();
          if (objectName == null || objectName.getOrig().isEmpty()) {
            throw new SchemaException(
                "No name in new object "
                    + objectName
                    + " as produced by template "
                    + objectTemplate
                    + " in iteration "
                    + iteration
                    + ", we cannot process an object without a name");
          }
        }

        // Check if iteration constraints are OK
        FocusConstraintsChecker<F> checker = new FocusConstraintsChecker<>();
        checker.setPrismContext(prismContext);
        checker.setContext(context);
        checker.setRepositoryService(cacheRepositoryService);
        checker.check(previewObjectNew, result);
        if (checker.isSatisfiesConstraints()) {
          LOGGER.trace(
              "Current focus satisfies uniqueness constraints. Iteration {}, token '{}'",
              iteration,
              iterationToken);

          if (LensUtil.evaluateIterationCondition(
              context,
              focusContext,
              iterationSpecificationType,
              iteration,
              iterationToken,
              false,
              expressionFactory,
              variables,
              task,
              result)) {
            // stop the iterations
            break;
          } else {
            conflictMessage = "post-iteration condition was false";
            LOGGER.debug(
                "Skipping iteration {}, token '{}' for {} because the post-iteration condition was false",
                new Object[] {iteration, iterationToken, focusContext.getHumanReadableName()});
          }
        } else {
          LOGGER.trace(
              "Current focus does not satisfy constraints. Conflicting object: {}; iteration={}, maxIterations={}",
              new Object[] {checker.getConflictingObject(), iteration, maxIterations});
          conflictMessage = checker.getMessages();
        }

        if (!wasResetIterationCounter) {
          wasResetIterationCounter = true;
          if (iteration != 0) {
            iterationToken = null;
            iteration = 0;
            LOGGER.trace("Resetting iteration counter and token after conflict");
            cleanupContext(focusContext);
            continue;
          }
        }
      }

      // Next iteration
      iteration++;
      iterationToken = null;
      if (iteration > maxIterations) {
        StringBuilder sb = new StringBuilder();
        if (iteration == 1) {
          sb.append("Error processing ");
        } else {
          sb.append("Too many iterations (" + iteration + ") for ");
        }
        sb.append(focusContext.getHumanReadableName());
        if (iteration == 1) {
          sb.append(": constraint violation: ");
        } else {
          sb.append(": cannot determine values that satisfy constraints: ");
        }
        if (conflictMessage != null) {
          sb.append(conflictMessage);
        }
        throw new ObjectAlreadyExistsException(sb.toString());
      }
      cleanupContext(focusContext);
    }

    addIterationTokenDeltas(focusContext, iteration, iterationToken);
    if (consistencyChecks) context.checkConsistence();
  }
  /** {@inheritDoc} */
  @Override
  public void deleteFarm(Long farmNo) {
    // 引数チェック
    if (farmNo == null) {
      throw new AutoApplicationException("ECOMMON-000003", "farmNo");
    }

    // ファームの存在チェック
    Farm farm = farmDao.read(farmNo);
    if (farm == null) {
      // ファームが存在しない場合
      return;
    }

    // コンポーネントが停止しているかどうかのチェック
    List<Component> components = componentDao.readByFarmNo(farmNo);
    for (Component component : components) {
      // ロードバランサのコンポーネントはチェックしない
      if (BooleanUtils.isTrue(component.getLoadBalancer())) {
        continue;
      }

      List<ComponentInstance> componentInstances =
          componentInstanceDao.readByComponentNo(component.getComponentNo());
      for (ComponentInstance componentInstance : componentInstances) {
        ComponentInstanceStatus status =
            ComponentInstanceStatus.fromStatus(componentInstance.getStatus());
        if (status != ComponentInstanceStatus.STOPPED) {
          // コンポーネントが停止状態でない場合
          throw new AutoApplicationException("ESERVICE-000202", component.getComponentName());
        }
      }
    }

    // インスタンスが停止しているかどうかのチェック
    List<Instance> instances = instanceDao.readByFarmNo(farmNo);
    for (Instance instance : instances) {
      // ロードバランサのインスタンスはチェックしない
      if (BooleanUtils.isTrue(instance.getLoadBalancer())) {
        continue;
      }

      if (InstanceStatus.fromStatus(instance.getStatus()) != InstanceStatus.STOPPED) {
        // インスタンスが停止状態でない場合
        throw new AutoApplicationException("ESERVICE-000203", instance.getInstanceName());
      }
    }

    // ロードバランサが停止しているかどうかのチェック
    List<LoadBalancer> loadBalancers = loadBalancerDao.readByFarmNo(farmNo);
    for (LoadBalancer loadBalancer : loadBalancers) {
      if (LoadBalancerStatus.fromStatus(loadBalancer.getStatus()) != LoadBalancerStatus.STOPPED) {
        // ロードバランサが停止状態でない場合
        throw new AutoApplicationException("ESERVICE-000207", loadBalancer.getLoadBalancerName());
      }
    }

    // ホストグループの削除処理
    Boolean useZabbix = BooleanUtils.toBooleanObject(Config.getProperty("zabbix.useZabbix"));
    if (BooleanUtils.isTrue(useZabbix)) {
      zabbixHostProcess.deleteFarmHostgroup(farmNo);
    }

    // ロードバランサの削除処理
    for (LoadBalancer loadBalancer : loadBalancers) {
      loadBalancerService.deleteLoadBalancer(loadBalancer.getLoadBalancerNo());
    }

    // コンポーネントの削除処理
    for (Component component : components) {
      componentService.deleteComponent(component.getComponentNo());
    }

    // インスタンスの削除処理
    for (Instance instance : instances) {
      instanceService.deleteInstance(instance.getInstanceNo());
    }

    // AWS関連の削除処理
    // AWSボリュームの削除処理
    // TODO: ボリューム自体の削除処理を別で行うようにする
    List<AwsVolume> awsVolumes = awsVolumeDao.readByFarmNo(farmNo);
    for (AwsVolume awsVolume : awsVolumes) {
      if (StringUtils.isEmpty(awsVolume.getVolumeId())) {
        continue;
      }

      IaasGatewayWrapper gateway =
          iaasGatewayFactory.createIaasGateway(farm.getUserNo(), awsVolume.getPlatformNo());
      try {
        // ボリュームの削除
        gateway.deleteVolume(awsVolume.getVolumeId());

        // EC2ではDeleteVolumeに時間がかかるため、Waitしない
        // awsProcessClient.waitDeleteVolume(volumeId);
      } catch (AutoException ignore) {
        // ボリュームが存在しない場合などに備えて例外を握りつぶす
      }
    }
    awsVolumeDao.deleteByFarmNo(farmNo);

    // VMware関連の削除処理
    // VLANの割り当てを解除
    List<VmwareNetwork> vmwareNetworks = vmwareNetworkDao.readByFarmNo(farmNo);
    for (VmwareNetwork vmwareNetwork : vmwareNetworks) {
      // PortGroupを削除
      VmwareProcessClient vmwareProcessClient =
          vmwareProcessClientFactory.createVmwareProcessClient(vmwareNetwork.getPlatformNo());
      try {
        vmwareNetworkProcess.removeNetwork(vmwareProcessClient, vmwareNetwork.getNetworkNo());
      } finally {
        vmwareProcessClient.getVmwareClient().logout();
      }

      // VLAN割り当てを解除
      vmwareNetwork.setFarmNo(null);
      vmwareNetworkDao.update(vmwareNetwork);
    }

    // ユーザ権限の削除
    userAuthDao.deleteByFarmNo(farmNo);

    // ファームの削除処理
    farmDao.deleteByFarmNo(farmNo);

    // イベントログ出力
    eventLogger.log(
        EventLogLevel.INFO,
        farmNo,
        farm.getFarmName(),
        null,
        null,
        null,
        null,
        "FarmDelete",
        null,
        null,
        null);
  }
  private BlockVirtualPoolUpdateBuilder apply(BlockVirtualPoolUpdateBuilder builder) {
    applyCommon(builder);
    builder.setSnapshots(defaultInt(maxSnapshots));
    builder.setContinuousCopies(maxContinuousCopies, uri(continuousCopyVirtualPool));

    // Only allow updating these fields if not locked
    if (!isLocked()) {
      builder.setMinPaths(defaultInt(minPaths, 1));
      builder.setMaxPaths(defaultInt(maxPaths, 1));
      builder.setPathsPerInitiator(defaultInt(initiatorPaths, 1));
      builder.setAutoTieringPolicyName(autoTierPolicy);
      builder.setDriveType(driveType);
      builder.setExpandable(defaultBoolean(expandable));
      builder.setFastExpansion(defaultBoolean(fastExpansion));
      builder.setThinVolumePreAllocationPercentage(thinPreAllocationPercent);
      builder.setUniquePolicyNames(defaultBoolean(uniqueAutoTierPolicyNames));
      builder.setMultiVolumeConsistency(defaultBoolean(multiVolumeConsistency));
      builder.setRaidLevels(defaultSet(raidLevels));
      builder.setHostIOLimitBandwidth(defaultInt(hostIOLimitBandwidth, 0));
      builder.setHostIOLimitIOPs(defaultInt(hostIOLimitIOPs, 0));

      if (ProtectionSystemTypes.isRecoverPoint(remoteProtection)) {
        builder.setRecoverPointJournalSize(
            RPCopyForm.formatJournalSize(rpJournalSize, rpJournalSizeUnit));
        builder.setRecoverPointRemoteCopyMode(rpRemoteCopyMode);
        builder.setRecoverPointRpo(rpRpoValue, rpRpoType);
        Set<VirtualPoolProtectionVirtualArraySettingsParam> copies = Sets.newLinkedHashSet();
        for (RPCopyForm rpCopy : rpCopies) {
          if (rpCopy != null && rpCopy.isEnabled()) {
            copies.add(rpCopy.write());
          }
        }
        builder.setRecoverPointCopies(copies);
        builder.setJournalVarrayAndVpool(uri(sourceJournalVArray), uri(sourceJournalVPool));
      } else {
        builder.disableRecoverPoint();
      }

      if (ProtectionSystemTypes.isSRDF(remoteProtection)) {
        Set<VirtualPoolRemoteProtectionVirtualArraySettingsParam> copies = Sets.newHashSet();
        for (SrdfCopyForm srdfCopyForm : srdfCopies) {
          if (srdfCopyForm != null && srdfCopyForm.isEnabled()) {
            copies.add(srdfCopyForm.write(srdfCopyMode));
          }
        }
        builder.setRemoteCopies(copies);
      } else {
        builder.disableRemoteCopies();
      }

      if (HighAvailability.isHighAvailability(highAvailability)) {
        boolean activeProtectionAtHASite = BooleanUtils.isTrue(protectHASite);
        boolean metroPoint = false;
        if (BooleanUtils.isTrue(protectSourceSite) && BooleanUtils.isTrue(protectHASite)) {
          metroPoint = true;
          activeProtectionAtHASite =
              StringUtils.equalsIgnoreCase(activeSite, HighAvailability.VPLEX_HA);
          builder.setJournalVarrayAndVpool(uri(sourceJournalVArray), uri(sourceJournalVPool));
          builder.setStandByJournalVArrayVpool(uri(haJournalVArray), uri(haJournalVPool));
        } else {
          if (activeProtectionAtHASite) {
            builder.setJournalVarrayAndVpool(uri(haJournalVArray), uri(haJournalVPool));
          } else {
            builder.setJournalVarrayAndVpool(uri(sourceJournalVArray), uri(sourceJournalVPool));
          }
        }
        builder.setHighAvailability(
            highAvailability,
            enableAutoCrossConnExport,
            uri(haVirtualArray),
            uri(haVirtualPool),
            activeProtectionAtHASite,
            metroPoint);
      } else {
        builder.disableHighAvailability();
      }
    }

    return builder;
  }
  /**
   * @param command
   * @param result
   * @return
   */
  @RequestMapping(method = RequestMethod.POST)
  public ModelAndView searchCarta(
      @Valid @ModelAttribute("command") ShowExplorerVolumeCommand command, BindingResult result) {
    if (command.getInsertNum() != null
        || command.getInsertLet() != null
        || command.getImageProgTypeNum() != null
        || command.getMissedNumbering() != null) {
      // validation should be launched only when insert and folio details have a value (at least one
      // of them)
      getValidator().validate(command, result);
    }

    if (result.hasErrors()) {
      // in case of errors we need to remove imageType and imageProgTypeNum, so we return imageOrder
      // which is previous image.
      command.setImageType(null);
      // command.setImageProgTypeNum(null);
      return setupForm(command, result);
    } else {
      Map<String, Object> model = new HashMap<String, Object>(0);

      VolumeExplorer volumeExplorer =
          new VolumeExplorer(command.getSummaryId(), command.getVolNum(), command.getVolLetExt());
      volumeExplorer.setImage(new Image());
      if (!StringUtils.isNullableString(command.getInsertNum())) {
        volumeExplorer.getImage().setInsertNum(StringUtils.nullTrim(command.getInsertNum()));
        volumeExplorer.getImage().setInsertLet(StringUtils.nullTrim(command.getInsertLet()));
      }
      volumeExplorer.getImage().setImageProgTypeNum(command.getImageProgTypeNum());
      volumeExplorer
          .getImage()
          .setMissedNumbering(StringUtils.nullTrim(command.getMissedNumbering()));
      volumeExplorer
          .getImage()
          .setImageRectoVerso(
              Image.ImageRectoVerso.convertFromString(
                  StringUtils.nullTrim(command.getImageRectoVerso())));
      volumeExplorer.getImage().setImageOrder(command.getImageOrder());
      volumeExplorer.getImage().setImageType(command.getImageType());
      volumeExplorer.setTotal(command.getTotal());
      volumeExplorer.setTotalRubricario(command.getTotalRubricario());
      volumeExplorer.setTotalCarta(command.getTotalCarta());
      volumeExplorer.setTotalAppendix(command.getTotalAppendix());
      volumeExplorer.setTotalOther(command.getTotalOther());
      volumeExplorer.setTotalGuardia(command.getTotalGuardia());

      try {
        Boolean hasInserts =
            getVolBaseService().hasInserts(command.getVolNum(), command.getVolLetExt());
        model.put("hasInsert", hasInserts);

        volumeExplorer = getVolBaseService().getVolumeExplorer(volumeExplorer);
        model.put("volumeExplorer", volumeExplorer);
      } catch (ApplicationThrowable applicationThrowable) {
        model.put("applicationThrowable", applicationThrowable);
        return new ModelAndView("error/ShowExplorerVolume", model);
      }

      if (BooleanUtils.isTrue(command.getModalWindow())) {
        return new ModelAndView("volbase/ShowExplorerVolumeModalWindow", model);
      } else {
        return new ModelAndView("volbase/ShowExplorerVolume", model);
      }
    }
  }
 private static boolean isOverriding(Symbol symbol) {
   return symbol.isMethodSymbol()
       && BooleanUtils.isTrue(((MethodTreeImpl) symbol.declaration()).isOverriding());
 }
Beispiel #19
0
 public boolean isManualSeverity() {
   return BooleanUtils.isTrue(
       (Boolean) getField(IssueIndexDefinition.FIELD_ISSUE_MANUAL_SEVERITY));
 }