X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fcom%2Findexdata%2Fmkjsf%2Fpazpar2%2Fcommands%2Fsp%2FCategoriesCommand.java;h=bccd65c0a744f7e60ffff22674adfb85b961aa45;hb=9cd922c29f423b69da6f52eabf0c7fdb0b0b6ca5;hp=65e1f268454d28cc2c8e03b8f2d930eb0d3905ac;hpb=d400a082759c1a58cb79713f04ab2f3d62bca97c;p=mkjsf-moved-to-github.git diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/CategoriesCommand.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/CategoriesCommand.java index 65e1f26..bccd65c 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/CategoriesCommand.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/CategoriesCommand.java @@ -1,19 +1,46 @@ package com.indexdata.mkjsf.pazpar2.commands.sp; +import org.apache.log4j.Logger; + +import com.indexdata.mkjsf.pazpar2.Pz2Service; import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command; -import com.indexdata.mkjsf.pazpar2.state.StateManager; +import com.indexdata.mkjsf.pazpar2.data.sp.CategoriesResponse; public class CategoriesCommand extends Pazpar2Command implements ServiceProxyCommand { private static final long serialVersionUID = 5023993689780291641L; + private static Logger logger = Logger.getLogger(CategoriesCommand.class); - public CategoriesCommand(StateManager stateMgr) { - super("categories", stateMgr); + public CategoriesCommand() { + super("categories"); + } + + @Override + public CategoriesResponse run () { + if (Pz2Service.get().getPzresp().getSp().getCategories().unsupportedCommand()) { + logger.info("Skipping seemingly unsupported categories command"); + return new CategoriesResponse(); + } else { + if (Pz2Service.get().isServiceProxyService()) { + try { + CategoriesResponse response = (CategoriesResponse) super.run(); + if (response.unsupportedCommand()) { + logger.warn("Command 'categories' not supported by this Service Proxy"); + } + return response; + } catch (Exception e) { + e.printStackTrace(); + return new CategoriesResponse(); + } + } else { + return new CategoriesResponse(); + } + } } @Override public Pazpar2Command copy() { - CategoriesCommand newCommand = new CategoriesCommand(stateMgr); + CategoriesCommand newCommand = new CategoriesCommand(); return newCommand; } @@ -22,4 +49,9 @@ public class CategoriesCommand extends Pazpar2Command implements ServiceProxyCom return this; } + @Override + public boolean spOnly() { + return true; + } + }