    001/*
    002    Licensed to the Apache Software Foundation (ASF) under one
    003    or more contributor license agreements.  See the NOTICE file
    004    distributed with this work for additional information
    005    regarding copyright ownership.  The ASF licenses this file
    006    to you under the Apache License, Version 2.0 (the
    007    "License"); you may not use this file except in compliance
    008    with the License.  You may obtain a copy of the License at
    009
    010       http://www.apache.org/licenses/LICENSE-2.0
    011
    012    Unless required by applicable law or agreed to in writing,
    013    software distributed under the License is distributed on an
    014    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    015    KIND, either express or implied.  See the License for the
    016    specific language governing permissions and limitations
    017    under the License.
    018 */
    019package org.apache.wiki.ui.progress;
    020
    021/**
    022 *  Manages progressing items.  In general this class is used whenever JSPWiki is doing something which may require a long time.
    023 *  In addition, this manager provides a JSON interface for finding remotely what the progress is.  The JSON object name is
    024 *  JSON_PROGRESSTRACKER = "{@value #JSON_PROGRESSTRACKER}".
    025 *
    026 *  @since  2.6
    027 */
    028public interface ProgressManager {
    029
    030    String JSON_PROGRESSTRACKER = "progressTracker";
    031
    032    /**
    033     *  You can use this to get an unique process identifier.
    034     *
    035     *  @return A new random value
    036     */
    037    String getNewProgressIdentifier();
    038
    039    /**
    040     *  Call this method to get your ProgressItem into the ProgressManager queue. The ProgressItem will be moved to state STARTED.
    041     *
    042     *  @param pi ProgressItem to start
    043     *  @param id The progress identifier
    044     */
    045    void startProgress( ProgressItem pi, String id );
    046
    047    /**
    048     *  Call this method to remove your ProgressItem from the queue (after which getProgress() will no longer find it.
    049     *  The ProgressItem will be moved to state STOPPED.
    050     *
    051     *  @param id The progress identifier
    052     */
    053    void stopProgress( String id );
    054
    055    /**
    056     *  Get the progress in percents.
    057     *
    058     *  @param id The progress identifier.
    059     *  @return a value between 0 to 100 indicating the progress
    060     *  @throws IllegalArgumentException If no such progress item exists.
    061     */
    062    int getProgress( String id ) throws IllegalArgumentException;
    063
    064}