blob: 86632c0058e4704763a467e22c87b7d4e124dc8b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/*******************************************************************************
* Copyright (c) 2012 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal.branch;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.enums.BranchState;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.ReadableBranch;
import org.eclipse.osee.framework.core.model.cache.BranchCache;
import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.core.ds.BranchDataStore;
import org.eclipse.osee.orcs.core.internal.SessionContext;
public class ChangeBranchStateCallable extends AbstractBranchCallable<ReadableBranch> {
private final BranchCache cache;
private final IOseeBranch branchToken;
private final BranchState branchState;
public ChangeBranchStateCallable(Log logger, SessionContext sessionContext, BranchDataStore branchStore, BranchCache cache, IOseeBranch branch, BranchState branchState) {
super(logger, sessionContext, branchStore);
this.cache = cache;
this.branchToken = branch;
this.branchState = branchState;
}
@Override
protected ReadableBranch innerCall() throws Exception {
Conditions.checkNotNull(branchToken, "branch");
Conditions.checkNotNull(branchState, "branchState");
Branch branch = cache.get(branchToken);
Conditions.checkNotNull(branch, "branch");
BranchState original = branch.getBranchState();
try {
branch.setBranchState(branchState);
cache.storeItems(branch);
} catch (Exception ex) {
branch.setBranchState(original);
throw ex;
} finally {
// TODO Event ?
}
return branch;
}
}
|