001/*
002 *  Copyright 2019 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.webcontentio.archive;
017
018import java.io.IOException;
019import java.nio.file.Path;
020import java.util.zip.ZipOutputStream;
021
022import javax.jcr.Node;
023
024import org.ametys.plugins.contentio.archive.ImportReport;
025import org.ametys.plugins.contentio.archive.Merger;
026import org.ametys.web.repository.site.Site;
027
028/**
029 * Component responsible to archive site plugin data.
030 */
031public interface SitePluginArchiver
032{
033    /**
034     * Export plugin data into the destination archive
035     * @param site the current site.
036     * @param pluginName the plugin name.
037     * @param pluginNode the plugin {@link Node}.
038     * @param zos the output data stream.
039     * @param prefix the prefix for ZIP entries.
040     * @throws IOException if an error occurs while writing entries to the archive.
041     */
042    public void export(Site site, String pluginName, Node pluginNode, ZipOutputStream zos, String prefix) throws IOException;
043    
044    /**
045     * Import plugin data from the source archive
046     * @param site the current site.
047     * @param pluginName the plugin name.
048     * @param allPluginsNode the {@link Node} for all plugins.
049     * @param zipPath The input ZIP file
050     * @param zipPluginEntryPath The input ZIP entry
051     * @param merger The {@link Merger}
052     * @return The {@link ImportReport}
053     * @throws IOException if an error occurs while reading the archive.
054     */
055    public ImportReport partialImport(Site site, String pluginName, Node allPluginsNode, Path zipPath, String zipPluginEntryPath, Merger merger) throws IOException;
056}