예제 #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);
    }
  }
예제 #2
0
 public void setLocalName(String localName) throws MalformedContentNameStringException {
   if (null == _pxml.getLocalName()) {
     _pxml.setLocalName(localName);
   }
 }
예제 #3
0
 /**
  * Gets the local name currently used by this repository
  *
  * @return the local name as a slash separated String
  */
 public String getLocalName() {
   return _pxml.getLocalName();
 }