d52ec51d3cdaffed45915817e7ecea74c5296cdc
[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 org.apache.log4j.Logger;\r
4 \r
5 import com.indexdata.mkjsf.pazpar2.commands.sp.InitCommandSp;\r
6 import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommand;\r
7 \r
8 public class InitCommand extends Pazpar2Command implements ServiceProxyCommand {\r
9 \r
10   private static final long serialVersionUID = -4915976465898889987L;\r
11   private static Logger logger = Logger.getLogger(InitCommand.class);\r
12   private InitCommandSp spCommand = null;\r
13   \r
14   public InitCommand() {\r
15     super("init");\r
16   }\r
17   \r
18   public void setClear(String clear) { \r
19     setParameterInState(new CommandParameter("clear","=",clear));\r
20   }\r
21   \r
22   public String getClear() {\r
23     return getParameterValue("clear");\r
24   }\r
25   \r
26   public void setService(String serviceId) {    \r
27     setParameterInState(new CommandParameter("service","=",serviceId));\r
28   }\r
29   \r
30   public String getService() {\r
31     return getParameterValue("service");\r
32   }\r
33   \r
34   @Override\r
35   public void setSession (String sessionId) {\r
36     throw new UnsupportedOperationException("Cannot set session id on init command");\r
37   }\r
38   \r
39   @Override\r
40   public String getSession () {\r
41     throw new UnsupportedOperationException("Cannot set or get session id on init command");\r
42   }  \r
43   \r
44   public InitCommand copy () {\r
45     logger.info("Copying init command");\r
46     InitCommand newCommand = new InitCommand();\r
47     for (String parameterName : parameters.keySet()) {\r
48       newCommand.setParameterInState(parameters.get(parameterName).copy());      \r
49     }\r
50     newCommand.spCommand = this.spCommand;\r
51     return newCommand;\r
52   }\r
53   \r
54   public ServiceProxyCommand getSp() {\r
55     if (spCommand==null) {\r
56       spCommand = new InitCommandSp(this);\r
57     } \r
58     return spCommand;\r
59   }\r
60 \r
61   @Override\r
62   public boolean spOnly() {\r
63     return false;\r
64   }\r
65 \r
66 \r
67 }\r