void add(final OtherResource resource) {
    contextHandler
        .getMutex()
        .writeAccess(
            new Runnable() {

              public void run() {
                Document document = contextHandler.getContextDocument();
                Element root = contextHandler.getRootElement(document);

                Element tasksElement = findElement(root, TAG_RESOURCES_PATHS);
                // check foldersElement null and create element
                if (tasksElement == null) {
                  tasksElement = document.createElement(TAG_RESOURCES_PATHS);
                  root.appendChild(tasksElement);
                }
                Element taskElement = document.createElement(TAG_PATH);
                tasksElement.appendChild(taskElement);
                taskElement.setAttribute(TAG_ID, resource.getPath());
                if (resource.getProjectId() != null) {
                  taskElement.setAttribute(TAG_PROJECT_ID, resource.getProjectId());
                }

                contextHandler.saveContextDocument(document);
              }
            });
  }
  List<OtherResource> refresh() {
    final List<OtherResource> resources = new ArrayList<OtherResource>();

    contextHandler
        .getMutex()
        .readAccess(
            new Runnable() {

              public void run() {
                Document document = contextHandler.getContextDocument();
                Element root = contextHandler.getRootElement(document);

                Element tasksElement = findElement(root, TAG_RESOURCES_PATHS);
                // check foldersElement null and create element
                if (tasksElement == null) {
                  tasksElement = document.createElement(TAG_RESOURCES_PATHS);
                  root.appendChild(tasksElement);
                }

                NodeList taskNodes = tasksElement.getElementsByTagName(TAG_PATH);
                for (int i = 0; i < taskNodes.getLength(); i++) {
                  Node node = taskNodes.item(i);
                  if (node.getNodeType() == Node.ELEMENT_NODE) {
                    Element element = (Element) node;
                    String id = element.getAttribute(TAG_ID);
                    String pid = element.getAttribute(TAG_PROJECT_ID);

                    resources.add(new OtherResource(pid, id));
                  }
                }
              }
            });

    return resources;
  }
  void remove(final OtherResource resource) {
    contextHandler
        .getMutex()
        .writeAccess(
            new Runnable() {

              public void run() {
                Document document = contextHandler.getContextDocument();
                Element root = contextHandler.getRootElement(document);

                Element tasksElement = findElement(root, TAG_RESOURCES_PATHS);
                // check foldersElement null and create element
                if (tasksElement == null) {
                  tasksElement = document.createElement(TAG_RESOURCES_PATHS);
                  root.appendChild(tasksElement);
                }

                NodeList taskNodes = tasksElement.getElementsByTagName(TAG_PATH);
                Element trelement = null;
                for (int i = 0; i < taskNodes.getLength(); i++) {
                  Node node = taskNodes.item(i);
                  if (node.getNodeType() == Node.ELEMENT_NODE) {
                    Element element = (Element) node;
                    String id = element.getAttribute(TAG_ID);
                    String pid = element.getAttribute(TAG_PROJECT_ID);

                    if (resource.getPath().equals(id)
                        && ((pid == null && resource.getProjectId() == null)
                            || (pid != null && pid.equals(resource.getProjectId())))) {
                      trelement = element;
                      break;
                    }
                  }
                }
                if (trelement != null) {
                  tasksElement.removeChild(trelement);
                  contextHandler.saveContextDocument(document);
                }
              }
            });
  }