Exemple #1
0
  protected Set<String> getPaths(boolean primaryOnly) throws AfException {

    if (isNew()) {
      throw new AfException("this object is new, you can not get any paths");
    }

    if (!nodeRef.getStoreRef().equals(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE)) {
      throw new AfException("you cannot query the object's paths that is not in workspace");
    }

    NodeService nodeService = ServiceHelper.getNodeService(afSession);

    List<Path> ps = nodeService.getPaths(nodeRef, primaryOnly);
    Set<String> paths = new HashSet<String>();

    //		NodeRef parent = AFCHelper.getNodeRefByPath(afSession, "/");

    for (Path p : ps) {

      StringBuffer realPath = new StringBuffer();

      int length = p.size();
      for (int i = 0; i < length; i++) {

        QName qname = QName.createQName(p.get(i).getElementString());
        String fname = qname.getLocalName();

        if (fname.equals("/") || fname.equals("company_home")) {
          continue;
        } else if ("system".equals(fname) && i == 1) {
          break;
        }

        realPath.append('/');
        if (i == length - 1) {
          realPath.append(getObjectName());
        } else {
          realPath.append(ISO9075.decode(fname));
        }
      }

      if (realPath.length() != 0) {
        paths.add(realPath.toString());
      }
    }

    //		for (Path p : ps) {
    //
    //			NodeRef tmpParent = parent;
    //
    //			String realPath = "";
    //			for (int i = 0; i < p.size(); i++) {
    //				QName qname = QName.createQName(p.get(i).getElementString());
    //				String fname = qname.getLocalName();
    //
    //				if (fname.equals("/") || fname.equals("company_home")) {
    //					continue;
    //				}
    //
    //				String name = ISO9075.decode(fname);
    //
    //				tmpParent = getChildByAssName(nodeService, tmpParent, name);
    //
    //				if (tmpParent == null) {
    //					break;
    //				}
    //
    //				realPath += "/" + getNodeName(nodeService, tmpParent);
    //
    //			}
    //
    //			if (!realPath.equals("")) {
    // 				paths.add(realPath);
    //			}
    //
    //		}
    return paths;
  }