Hi Marcel,
here a piece of code that shows more less what I'm trying to do. I have the
NodeState of the verison I want to modify (versionNodeState) and I create
from it the updated version (updatedNodeState), but then I don't understand
how can I use it to update the actual value in the FrozenNode:

    public void changeFirstVersionProperty(NodeStore nodeStore, Node
myFolder) throws IOException, InvalidFileStoreVersionException,
RepositoryException {
        NodeState versionNodeState = getNodeState(nodeStore, myFolder);
        NodeState updatedNodeState =
versionNodeState.builder().setProperty("custom:trashed",
true).getNodeState();

    }

    private NodeState getNodeState(NodeStore nodeStore, Node node) throws
RepositoryException {
        NodeState rootState = nodeStore.getRoot();
        NodeState versionStorageState =
rootState.getChildNode(JcrConstants.JCR_SYSTEM).getChildNode(JcrConstants.JCR_VERSIONSTORAGE);
        NodeState versionHistoryState =
getVersionHistoryState(versionStorageState, node.getIdentifier());
        return
versionHistoryState.getChildNode("1.0").getChildNode(JcrConstants.JCR_FROZENNODE);
    }

    private NodeState getVersionHistoryState(NodeState nodeState, String
remainingIdentifier) {
        String clusterFolderName = remainingIdentifier.substring(0, 2);
        NodeState childNode = nodeState.getChildNode(clusterFolderName);
        if (childNode.exists()) {
            return getVersionHistoryState(childNode,
remainingIdentifier.substring(2));
        } else {
            String versionHistoryNodeName = getFirstChild(nodeState);
            return nodeState.getChildNode(versionHistoryNodeName);
        }
    }

    private String getFirstChild(NodeState nodeState) {
        return nodeState.getChildNodeNames().iterator().next();
    }

Marco.

On Tue, Jan 9, 2018 at 8:46 AM Marcel Reutegger <mreut...@adobe.com.invalid>
wrote:

> Hi,
>
> can you please provide a link to the upgrade script you have?
>
> Regards
>   Marcel
>
> On 08/01/18 18:24, Marco Piovesana wrote:
> > Hi all,
> > I'm trying to modify a frozen node property in a custom upgrade script. I
> > was following this
> > <
> http://oak.markmail.org/message/htxdaeffnr73m3q6?q=frozen+node#query:frozen%20node+page:1+mid:ib57du3viyaz7x4b+state:results
> >
> > post and I tried to use the NodeStore API to do so. I am able to get the
> > NodeState of the required node (from the version storage), create a new
> > node state from its NodeBuilder, but then I don't understand how to
> replace
> > the previous node state with the new one so that the corresponding frozen
> > node will have the updated properties values. Am I doing it wrong? How
> can
> > I use the NodeStore API to modify a frozen node?
> >
> > Marco.
> >
>

Reply via email to