]> git.argeo.org Git - gpl/argeo-slc.git/blob - legacy/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/DetachedSession.java
Clean up directories
[gpl/argeo-slc.git] / legacy / runtime / org.argeo.slc.detached / src / main / java / org / argeo / slc / detached / DetachedSession.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.slc.detached;
17
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.Vector;
21
22 /** A session within the detached context. */
23 public class DetachedSession {
24 public final static String PROP_DO_IT_AGAIN_POLICY = "slc.detached.doItAgainPolicy";
25 public final static String SKIP_UNTIL_ERROR = "skipUntilError";
26 public final static String REPLAY = "replay";
27
28 private String uuid = null;
29 private List requests = new Vector();
30 private List answers = new Vector();
31 private String doItAgainPolicy = REPLAY;
32 private List refreshedBundleNames = new ArrayList();
33
34 public boolean isClosed() {
35 if (answers.size() > 0) {
36 DetachedAnswer answer = (DetachedAnswer) answers
37 .get(answers.size() - 1);
38 return answer.getStatus() == DetachedAnswer.CLOSED_SESSION;
39 } else {
40 return false;
41 }
42 }
43
44 public boolean lastActionIsError() {
45 if (answers.size() > 0) {
46 DetachedAnswer answer = (DetachedAnswer) answers
47 .get(answers.size() - 1);
48 return answer.getStatus() == DetachedAnswer.ERROR;
49 } else {
50 return false;
51 }
52 }
53
54 public int getExecutedStepCount() {
55 if(requests.size() != answers.size()) {
56 throw new DetachedException("requests.size() != answers.size() in DetachedSession");
57 }
58 return answers.size();
59 }
60
61 public String getDoItAgainPolicy() {
62 return doItAgainPolicy;
63 }
64
65 public void setDoItAgainPolicy(String doItAgainPolicy) {
66 this.doItAgainPolicy = doItAgainPolicy;
67 }
68
69 public List getRequests() {
70 return requests;
71 }
72
73 public String getUuid() {
74 return uuid;
75 }
76
77 public void setUuid(String uuid) {
78 this.uuid = uuid;
79 }
80
81 public List getAnswers() {
82 return answers;
83 }
84
85 public List getRefreshedBundleNames() {
86 return refreshedBundleNames;
87 }
88
89 public String toString() {
90 StringBuffer buf = new StringBuffer(getClass().getName());
91 buf.append("#").append(uuid);
92 buf.append(" doItAgainPolicy=").append(doItAgainPolicy);
93 return buf.toString();
94 }
95 }