1 /*
2 * This file is part of Waarp Project (named also Waarp or GG).
3 *
4 * Copyright (c) 2019, Waarp SAS, and individual contributors by the @author
5 * tags. See the COPYRIGHT.txt in the distribution for a full listing of
6 * individual contributors.
7 *
8 * All Waarp Project is free software: you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY
14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * Waarp . If not, see <http://www.gnu.org/licenses/>.
19 */
20 package org.waarp.common.file;
21
22 import org.waarp.common.command.exception.CommandAbstractException;
23 import org.waarp.common.exception.NoRestartException;
24
25 /**
26 * Restart object that implements the REST command.<br>
27 * Note that if necessary, according to the implementation of {@link
28 * DirInterface} and {@link FileInterface},
29 * one could want to implement a way to store or retrieve Marker from/to the
30 * client specification.
31 */
32 public abstract class Restart {
33 /**
34 * SessionInterface
35 */
36 private final SessionInterface session;
37
38 /**
39 * Is the current Restart object in context set
40 */
41 private boolean isSet;
42
43 /**
44 * Default constructor
45 *
46 * @param session
47 */
48 protected Restart(final SessionInterface session) {
49 isSet = false;
50 this.session = session;
51 }
52
53 /**
54 * @return the isSet
55 */
56 protected final boolean isSet() {
57 return isSet;
58 }
59
60 /**
61 * @param isSet the isSet to set
62 */
63 public void setSet(final boolean isSet) {
64 this.isSet = isSet;
65 }
66
67 /**
68 * @return the session
69 */
70 protected final SessionInterface getSession() {
71 return session;
72 }
73
74 /**
75 * Restart from a Marker for the next FileInterface
76 *
77 * @param marker
78 *
79 * @return True if the Marker is OK
80 *
81 * @throws CommandAbstractException
82 */
83 public abstract boolean restartMarker(String marker)
84 throws CommandAbstractException;
85
86 /**
87 * @return the position from a previous REST command
88 *
89 * @throws NoRestartException if no REST command was issued before
90 */
91 public abstract long getPosition() throws NoRestartException;
92
93 // FIXME Additionally the implementation should implement a way to get the
94 // values
95
96 /**
97 * @param nextBlock
98 *
99 * @return the max between the available size and the nextblock size
100 */
101 public abstract int getMaxSize(int nextBlock);
102 }