Example #1
0
  /**
   * Applies policy changes
   *
   * @param pxml policy data
   * @return
   * @throws XMLStreamException
   */
  public void update(PolicyXML pxml, boolean fromNet) throws RepositoryException {
    Log.info(Log.FAC_REPO, "Updating policy");
    if (pxml._version == null) throw new RepositoryException("No version in policy file");
    if (!pxml._version.equals(POLICY_VERSION)) {
      Log.warning(Log.FAC_REPO, "Bad version in policy file: {0}", pxml._version);
      throw new RepositoryException("Bad version in policy file");
    }

    if (null == pxml._localName) throw new RepositoryException("No local name in policy file");
    if (fromNet) {
      if (!pxml._localName.equals(_pxml.getLocalName())) {
        Log.warning(
            Log.FAC_REPO, "Repository local name doesn't match: request = {0}", pxml._localName);
        throw new RepositoryException("Repository local name doesn't match policy file");
      }
    } else {
      try {
        setLocalName(pxml._localName);
      } catch (MalformedContentNameStringException e) {
        throw new RepositoryException(e.getMessage());
      }
    }

    if (null == pxml._globalPrefix) throw new RepositoryException("No globalPrefix in policy file");

    if (fromNet) {
      if (!pxml.getGlobalPrefix().equals(_pxml.getGlobalPrefix())) {
        Log.warning("Repository globalPrefix doesn't match: request = {0}", pxml._globalPrefix);
        throw new RepositoryException("Repository global prefix doesn't match policy file");
      }
    } else {
      _pxml.setGlobalPrefixOnly(pxml._globalPrefix);
    }

    _pxml.setNamespace(pxml.getNamespace());
    if (null != pxml.getNamespace()) {
      String message = "";
      for (ContentName name : pxml.getNamespace()) {
        message += name.toString() + ':';
      }
      Log.info(Log.FAC_REPO, "Policy has been updated. New namespace is: " + message);
    }
  }
Example #2
0
 /**
  * Gets the global prefix currently in use for this repository
  *
  * @return the global prefix as a ContentName
  */
 public ContentName getGlobalPrefix() {
   return _pxml.getGlobalPrefix();
 }
Example #3
0
 /**
  * Gets the policy path for this repository
  *
  * @return the policy path as a ContentName
  */
 public ContentName getPolicyName() {
   return getPolicyName(_pxml.getGlobalPrefix());
 }