如何使用java上的move方法将文件从Alfresco Server一个绝对路径移动到另一个目标路径

时间:2014-12-01 11:57:26

标签: java alfresco

    Node node = session.getNodeByUUID(uuid);

    Workspace space = session.getWorkspace();
    Node targetNode = obtainNode(rootNode, "/app:company_home/app:user_homes/cm:admin/cm:test_space");

    try {

        String path = node.getPath();
        int index = path.lastIndexOf("/");
        String newPathName = path.substring(0, index);
        //newPathName = newPathName + "/" + node.getName();

        String tpath = targetNode.getPath();
        int tindex = tpath.lastIndexOf("/");
        String tnewPathName = tpath.substring(0, tindex);
        tnewPathName = tnewPathName + "/" + targetNode.getName();

        session.move(newPathName, newPathName);
        session.save();
        commit();

    } catch (ItemExistsException e) {
        e.printStackTrace();
    } catch (PathNotFoundException e) {
        e.printStackTrace();
    } catch (VersionException e) {
        e.printStackTrace();
    } catch (ConstraintViolationException e) {
        e.printStackTrace();
    } catch (LockException e) {
        e.printStackTrace();
    } catch (RepositoryException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

我在类文件中编写的代码没有从一个绝对路径移动到java中的目标路径。需要使用Alfresco Server Repository的JCR 1.0.jar这个例子来指导

1 个答案:

答案 0 :(得分:1)

您似乎正在将某些内容从newPathName移动到newPathName。不应该是:

session.move(path, newPathName);