/**
   * Get the primary configuration data for this project. The returned element will be named
   * according to {@link AntBasedProjectType#getPrimaryConfigurationDataElementName} and {@link
   * AntBasedProjectType#getPrimaryConfigurationDataElementNamespace}. The project may read this
   * document fragment to get custom information from <code>nbproject/project.xml</code> and <code>
   * nbproject/private/private.xml</code>. The fragment will have no parent node and while it may be
   * modified, you must use {@link #putPrimaryConfigurationData} to store any changes.
   *
   * @param shared if true, refers to <code>project.xml</code>, else refers to <code>private.xml
   *     </code>
   * @return the configuration data that is available
   */
  @Override
  public Element getPrimaryConfigurationData(final boolean shared) {
    final String name = type.getPrimaryConfigurationDataElementName(shared);
    assert name.indexOf(':') == -1;
    final String namespace = type.getPrimaryConfigurationDataElementNamespace(shared);
    assert namespace != null && namespace.length() > 0;
    return ProjectManager.mutex()
        .readAccess(
            new Mutex.Action<Element>() {

              @Override
              public Element run() {
                synchronized (modifiedMetadataPaths) {
                  Element el = getConfigurationFragment(name, namespace, shared);
                  if (el != null) {
                    return el;
                  } else {
                    // No such data, corrupt file.
                    return cloneSafely(
                        getConfigurationXml(shared).createElementNS(namespace, name));
                  }
                }
              }
            });
  }
 /**
  * Store the primary configuration data for this project. The supplied element must be named
  * according to {@link AntBasedProjectType#getPrimaryConfigurationDataElementName} and {@link
  * AntBasedProjectType#getPrimaryConfigurationDataElementNamespace}. The project may save this
  * document fragment to set custom information in <code>nbproject/project.xml</code> and <code>
  * nbproject/private/private.xml</code>. The fragment will be cloned and so further modifications
  * will have no effect.
  *
  * <p>Acquires write access from {@link ProjectManager#mutex}. However, you are well advised to
  * explicitly enclose a <em>complete</em> operation within write access, starting with {@link
  * #getPrimaryConfigurationData}, to prevent race conditions.
  *
  * @param data the desired new configuration data
  * @param shared if true, refers to <code>project.xml</code>, else refers to <code>private.xml
  *     </code>
  * @throws IllegalArgumentException if the element is not correctly named
  */
 @Override
 public void putPrimaryConfigurationData(Element data, boolean shared)
     throws IllegalArgumentException {
   String name = type.getPrimaryConfigurationDataElementName(shared);
   assert name.indexOf(':') == -1;
   String namespace = type.getPrimaryConfigurationDataElementNamespace(shared);
   assert namespace != null && namespace.length() > 0;
   if (!name.equals(data.getLocalName()) || !namespace.equals(data.getNamespaceURI())) {
     throw new IllegalArgumentException(
         "Wrong name/namespace: expected {"
             + namespace
             + "}"
             + name
             + " but was {"
             + data.getNamespaceURI()
             + "}"
             + data.getLocalName()); // NOI18N
   }
   putConfigurationFragment(data, shared);
 }