예제 #1
0
  /**
   * Now check if there a syncPreMatchAttribute, If the value for the attribute exists Check if the
   * attribute is of reference type. If it is reference type then for the value of this attribute
   * from WAS config get the resource reference value. If resource reference value is not found then
   * mark this object as prematch fail If resource reference value is found then match the resource
   * reference name to the value of in the resource object. This is to ensure that type of object
   * reterived is correct.
   *
   * <p>This is useful for object like ActivationSpec, QCF and AdminObject which have
   * connectiondefination and adminobject attribute which defines what type of object it is
   *
   * <p>By match these attributes we ensure that in sync operation that we do not fetch the objects
   * that are not required.
   */
  public boolean doesConfigObjectPreMatch(
      Session session,
      ConfigService configService,
      Resource resource,
      ObjectName configObject,
      Resource referencedResources)
      throws ConnectorException, ConfigServiceException, AttributeNotFoundException,
          MalformedObjectNameException, AttributeNotFoundException, DeployException {

    boolean syncPreMatch = true;

    if ((resource.getResourceMetaData().getSyncPreMatchAttribute() != null)
        && (resource.getResourceMetaData().getSyncPreMatchAttribute().trim().length() > 0)) {
      String preMatchAttributeName = resource.getResourceMetaData().getSyncPreMatchAttribute();
      String preMatchAttributeValue =
          resource.getAttributeList().get(preMatchAttributeName).toString();

      if (configService.getAttribute(session, configObject, preMatchAttributeName) != null) {
        Object preMatchAttributeConfigValue =
            configService.getAttribute(session, configObject, preMatchAttributeName).toString();

        boolean isReference =
            ResourceHelper.isAttributeReference(
                configService.getAttributesMetaInfo(resource.getName()), preMatchAttributeName);
        String attributeType =
            ResourceHelper.getAttributeType(
                configService.getAttributesMetaInfo(resource.getName()), preMatchAttributeName);
        if (isReference) {
          Resource referenceMatchResource =
              getMatchingResourceReferenceForConfigObject(
                  configService,
                  session,
                  referencedResources,
                  new ObjectName(preMatchAttributeConfigValue.toString()),
                  attributeType);
          if (referenceMatchResource == null) {
            logger.warn(attributeType + " not supported");
            syncPreMatch = false;
          } else {
            if (!(PropertiesConstant.VARIABLE_PREFIX
                    + referenceMatchResource.getName()
                    + PropertiesConstant.VARIABLE_SUFFIX)
                .equalsIgnoreCase(preMatchAttributeValue)) {
              logger.trace(
                  "Prematch false Config:"
                      + PropertiesConstant.VARIABLE_PREFIX
                      + referenceMatchResource.getName()
                      + PropertiesConstant.VARIABLE_SUFFIX
                      + " and DAKS:"
                      + preMatchAttributeValue);
              syncPreMatch = false;
            }
          }
        } else {
          if (!(preMatchAttributeValue.equals(preMatchAttributeConfigValue.toString()))) {
            logger.trace(
                "Prematch false Config:"
                    + preMatchAttributeConfigValue
                    + " and DAKS:"
                    + preMatchAttributeValue);
            syncPreMatch = false;
          }
        }
      } else {
        logger.trace(
            "Prematch false Config value is null for "
                + preMatchAttributeName
                + " and DAKS:"
                + preMatchAttributeValue);
        syncPreMatch = false;
      }
    }
    return syncPreMatch;
  }