001/*
002 *  Copyright 2020 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.plugins.repository.migration.jcr.data.repository;
017
018import javax.jcr.Node;
019
020import org.ametys.plugins.repository.AmetysRepositoryException;
021import org.ametys.plugins.repository.data.repositorydata.ModifiableRepositoryData;
022import org.ametys.plugins.repository.data.repositorydata.impl.JCRRepositoryData;
023import org.ametys.plugins.repository.jcr.DefaultTraversableAmetysObject;
024
025/**
026 * Class representing a version component
027 */
028public class VersionComponentAmetysObject extends DefaultTraversableAmetysObject<VersionComponentFactory>
029{
030    /** Metadata name for storing a Node's lockToken */
031    public static final String COMPONENT_ID = "componentId";
032
033    /** The repository data */
034    protected ModifiableRepositoryData _repositoryData;
035
036    /**
037     * Constructor.
038     * @param node the JCR Node.
039     * @param parentPath the parent path
040     * @param factory the corresponding factory.
041     */
042    public VersionComponentAmetysObject(Node node, String parentPath, VersionComponentFactory factory)
043    {
044        super(node, parentPath, factory);
045        _repositoryData = new JCRRepositoryData(getNode());
046    }
047    
048    /**
049     * Get the component identifier.
050     * @return the component identifier
051     */
052    public String getComponentId()
053    {
054        return _repositoryData.getString(COMPONENT_ID);
055    }
056    
057    /**
058     * Set the component identifier.
059     * @param componentId the component identifier
060     * @throws AmetysRepositoryException if an error occurs
061     */
062    public void setComponentId(String componentId) throws AmetysRepositoryException
063    {
064        _repositoryData.setValue(COMPONENT_ID, componentId);
065    }
066}