All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mycore.services.packaging.MCRPacker Maven / Gradle / Ivy

There is a newer version: 2024.05
Show newest version
/*
 * This file is part of ***  M y C o R e  ***
 * See http://www.mycore.de/ for details.
 *
 * MyCoRe is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MyCoRe is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MyCoRe.  If not, see .
 */

package org.mycore.services.packaging;

import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ExecutionException;

import org.mycore.access.MCRAccessException;
import org.mycore.common.MCRUsageException;

/**
 * Base class for every Packer. You should implement {@link #pack()} and {@link #rollback()}.
 * The will be initialized two times. One time to just call {@link #checkSetup()} and one time to {@link #pack()}
 */
public abstract class MCRPacker {

    public static final String PACKER_CONFIGURATION_PREFIX = "MCR.Packaging.Packer.";

    private Map configuration;

    private Map parameter;

    /**
     * should check if all required parameters are set!
     * @throws MCRUsageException if parameters are illegal
     * @throws MCRAccessException if the Users doesn't have the rights to use the Packer
     */
    public abstract void checkSetup() throws MCRUsageException, MCRAccessException;

    /**
     * This method will be called and the MCRPacker should start packing according to the {@link #getConfiguration()}
     * and {@link #getParameters()}!
* WARNING: do all checks for parameters and user access in {@link #checkSetup()}, because the packer is already * stored in the DB if pack is called and the pack JOB runs a System-User instead of the User who * produces the call. * * @throws ExecutionException Unable to pack */ public abstract void pack() throws ExecutionException; /** * This method can be called in case of error and the MCRPacker should clean up trash from {@link #pack()} */ public abstract void rollback(); /** * @return a unmodifiable map with all properties (MCR.Packaging.Packer.MyPackerID. prefix will be removed from key) * of this packer-id. */ protected final Map getConfiguration() { return Collections.unmodifiableMap(this.configuration); } final void setConfiguration(Map configuration) { this.configuration = configuration; } /** * @return a unmodifiable map with parameters of a specific {@link MCRPackerJobAction}. */ protected final Map getParameters() { return Collections.unmodifiableMap(this.parameter); } final void setParameter(Map parameter) { this.parameter = parameter; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy