001/* 002 * Copyright 2026 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 */ 016 017package org.ametys.plugins.ai.search; 018 019import javax.jcr.Node; 020import javax.jcr.PathNotFoundException; 021import javax.jcr.RepositoryException; 022import javax.jcr.ValueFormatException; 023 024import org.ametys.plugins.repository.AmetysRepositoryException; 025import org.ametys.plugins.repository.activities.Activity; 026import org.ametys.plugins.repository.jcr.DefaultTraversableAmetysObject; 027import org.ametys.plugins.repository.jcr.SimpleAmetysObject; 028 029/** 030 * A chunk of a cached content version 031 */ 032public class CacheContentVersionChunk extends SimpleAmetysObject<CacheContentVersionChunkFactory> 033{ 034 /** 035 * Creates an {@link Activity}. 036 * @param node the node backing this {@link Activity} 037 * @param parentPath the parentPath in the Ametys hierarchy 038 * @param factory the factory which created the activity 039 */ 040 public CacheContentVersionChunk(Node node, String parentPath, CacheContentVersionChunkFactory factory) 041 { 042 super(node, parentPath, factory); 043 } 044 045 /** 046 * Get the content id of the content this chunk belongs to. 047 * @return the content id 048 * @throws RepositoryException If an error occurs while accessing the repository 049 * @throws AmetysRepositoryException If an error occurs while accessing the Ametys repository 050 * @throws PathNotFoundException If the specified path is not found 051 * @throws ValueFormatException If the value is not in the expected format 052 */ 053 public String getContentId() throws ValueFormatException, PathNotFoundException, AmetysRepositoryException, RepositoryException 054 { 055 return ((DefaultTraversableAmetysObject) this.getParent().getParent()).getNode().getProperty("ametys-internal:" + CacheDAO.CACHEROOT_CONTENT_DATA_CONTENTID).getString(); 056 } 057}