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 java.util.Set; 019 020import javax.jcr.Node; 021 022import org.ametys.plugins.repository.AmetysRepositoryException; 023import org.ametys.plugins.repository.data.repositorydata.ModifiableRepositoryData; 024import org.ametys.plugins.repository.data.repositorydata.impl.JCRRepositoryData; 025import org.ametys.plugins.repository.jcr.DefaultTraversableAmetysObject; 026 027/** 028 * Object representing the versions root element. 029 */ 030public class VersionsAmetysObject extends DefaultTraversableAmetysObject<VersionsFactory> 031{ 032 /** Metadata name for storing a Node's lockToken */ 033 public static final String KNOWN_PLUGINS = "knownPlugins"; 034 035 /** The repository data */ 036 protected ModifiableRepositoryData _repositoryData; 037 038 /** 039 * Constructor. 040 * @param node the JCR Node. 041 * @param parentPath the parent path 042 * @param factory the corresponding factory. 043 */ 044 public VersionsAmetysObject(Node node, String parentPath, VersionsFactory factory) 045 { 046 super(node, parentPath, factory); 047 _repositoryData = new JCRRepositoryData(getNode()); 048 } 049 050 /** 051 * Get all the known plugins. 052 * @return the known plugins 053 */ 054 public Set<String> getKnownPlugins() 055 { 056 if (_repositoryData.hasValue(KNOWN_PLUGINS)) 057 { 058 return Set.of(_repositoryData.getStrings(KNOWN_PLUGINS)); 059 } 060 061 return Set.of(); 062 } 063 064 /** 065 * Set the known plugins. 066 * @param knownPlugins the known plugins 067 * @throws AmetysRepositoryException if an error occurs 068 */ 069 public void setKnownPlugins(Set<String> knownPlugins) throws AmetysRepositoryException 070 { 071 _repositoryData.setValues(KNOWN_PLUGINS, knownPlugins.toArray(String[]::new)); 072 } 073}