Adds check for SP only commands.
[mkjsf-moved-to-github.git] / src / main / java / com / indexdata / mkjsf / pazpar2 / commands / InitCommand.java
1 package com.indexdata.mkjsf.pazpar2.commands;\r
2 \r
3 import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommand;\r
4 import com.indexdata.mkjsf.pazpar2.state.StateManager;\r
5 \r
6 public class InitCommand extends Pazpar2Command implements ServiceProxyCommand {\r
7 \r
8   private static final long serialVersionUID = -4915976465898889987L;\r
9 \r
10   public InitCommand(StateManager stateMgr) {\r
11     super("init",stateMgr);\r
12   }\r
13   \r
14   public void setClear(String clear) { \r
15     setParameterInState(new CommandParameter("clear","=",clear));\r
16   }\r
17   \r
18   public String getClear() {\r
19     return getParameterValue("clear");\r
20   }\r
21   \r
22   public void setService(String serviceId) {    \r
23     setParameterInState(new CommandParameter("service","=",serviceId));\r
24   }\r
25   \r
26   public String getService() {\r
27     return getParameterValue("service");\r
28   }\r
29   \r
30   @Override\r
31   public void setSession (String sessionId) {\r
32     throw new UnsupportedOperationException("Cannot set session id on init command");\r
33   }\r
34   \r
35   @Override\r
36   public String getSession () {\r
37     throw new UnsupportedOperationException("Cannot set or get session id on init command");\r
38   }\r
39   \r
40   public InitCommand copy () {\r
41     InitCommand newCommand = new InitCommand(stateMgr);\r
42     for (String parameterName : parameters.keySet()) {\r
43       newCommand.setParameterInState(parameters.get(parameterName).copy());      \r
44     }    \r
45     return newCommand;\r
46   }\r
47   \r
48   public ServiceProxyCommand getSp() {\r
49     return this;\r
50   }\r
51 \r
52   @Override\r
53   public boolean spOnly() {\r
54     return false;\r
55   }\r
56 \r
57 \r
58 }\r