1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package nl.toolforge.karma.core.cmd.impl;
20
21 import nl.toolforge.karma.core.boot.ManifestStore;
22 import nl.toolforge.karma.core.cmd.CommandDescriptor;
23 import nl.toolforge.karma.core.cmd.CommandException;
24 import nl.toolforge.karma.core.cmd.CommandResponse;
25 import nl.toolforge.karma.core.cmd.DefaultCommand;
26 import nl.toolforge.karma.core.cmd.event.ErrorEvent;
27 import nl.toolforge.karma.core.cmd.event.MessageEvent;
28 import nl.toolforge.karma.core.cmd.event.SimpleMessage;
29 import nl.toolforge.karma.core.vc.AuthenticationException;
30 import nl.toolforge.karma.core.vc.VersionControlException;
31 import org.apache.commons.logging.Log;
32 import org.apache.commons.logging.LogFactory;
33
34 /***
35 * Updates administrative data for a working context. The manifest-store and the location-store are updated.
36 *
37 * @author W.H. Schraal
38 * @author D.A. Smedes
39 *
40 * @version $Id: UpdateAdmin.java,v 1.1 2004/11/10 23:50:04 asmedes Exp $
41 */
42 public class UpdateAdmin extends DefaultCommand {
43
44 private static final Log logger = LogFactory.getLog(UpdateAdmin.class);
45
46 private CommandResponse commandResponse = new CommandResponse();
47
48 public UpdateAdmin(CommandDescriptor descriptor) {
49 super(descriptor);
50 }
51
52 public void execute() throws CommandException {
53
54 try {
55 ManifestStore mStore = getContext().getWorkingContext().getConfiguration().getManifestStore();
56
57 if (!mStore.getLocation().isAvailable()) {
58 commandResponse.addEvent(new MessageEvent(this, new SimpleMessage("Manifest store location unreachable!")));
59 } else {
60 commandResponse.addEvent(new MessageEvent(this, new SimpleMessage(("Updating manifests ..."))));
61 mStore.update();
62 }
63
64
65
66
67
68
69
70
71
72
73
74
75 } catch (VersionControlException e) {
76 logger.warn(new ErrorEvent(this, e.getErrorCode(), e.getMessageArguments()));
77 commandResponse.addEvent(new ErrorEvent(this, e.getErrorCode(), e.getMessageArguments()));
78 } catch (AuthenticationException e) {
79 logger.warn(new ErrorEvent(this, e.getErrorCode(), e.getMessageArguments()));
80 commandResponse.addEvent(new ErrorEvent(this, e.getErrorCode(), e.getMessageArguments()));
81 }
82 }
83
84 public CommandResponse getCommandResponse() {
85 return this.commandResponse;
86 }
87 }