package com.indexdata.mkjsf.pazpar2.commands.sp;\r
\r
+import org.apache.log4j.Logger;\r
+\r
+import com.indexdata.mkjsf.pazpar2.Pz2Service;\r
import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command;\r
-import com.indexdata.mkjsf.pazpar2.state.StateManager;\r
+import com.indexdata.mkjsf.pazpar2.data.sp.CategoriesResponse;\r
\r
public class CategoriesCommand extends Pazpar2Command implements ServiceProxyCommand {\r
\r
private static final long serialVersionUID = 5023993689780291641L;\r
+ private static Logger logger = Logger.getLogger(CategoriesCommand.class);\r
\r
- public CategoriesCommand(StateManager stateMgr) {\r
- super("categories", stateMgr);\r
+ public CategoriesCommand() {\r
+ super("categories");\r
+ }\r
+ \r
+ @Override\r
+ public CategoriesResponse run () {\r
+ if (Pz2Service.get().getPzresp().getSp().getCategories().unsupportedCommand()) {\r
+ logger.info("Skipping seemingly unsupported categories command"); \r
+ return new CategoriesResponse();\r
+ } else {\r
+ if (Pz2Service.get().isServiceProxyService()) {\r
+ try {\r
+ CategoriesResponse response = (CategoriesResponse) super.run();\r
+ if (response.unsupportedCommand()) {\r
+ logger.warn("Command 'categories' not supported by this Service Proxy"); \r
+ }\r
+ return response;\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ return new CategoriesResponse();\r
+ }\r
+ } else {\r
+ return new CategoriesResponse();\r
+ }\r
+ }\r
}\r
\r
@Override\r
public Pazpar2Command copy() {\r
- CategoriesCommand newCommand = new CategoriesCommand(stateMgr);\r
+ CategoriesCommand newCommand = new CategoriesCommand();\r
return newCommand;\r
}\r
\r
return this;\r
}\r
\r
+ @Override\r
+ public boolean spOnly() {\r
+ return true;\r
+ }\r
+\r
}\r