X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fcom%2Findexdata%2Fmkjsf%2Fpazpar2%2Fcommands%2Fsp%2FCategoriesCommand.java;h=e94ce2605c359756da75f76fed333391ea0bb49b;hb=86f289cd42ba95846c80d22129ed565e4e9d6dde;hp=ad5723fbf1317c74ffe72fe2314be9bc2d1797bd;hpb=11ff48b9d37193a89a4b74da75db8c58415c46a6;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 ad5723f..e94ce26 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,14 +1,57 @@ 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.data.sp.CategoriesResponse; +/** + * Represents a Service Proxy categories command, can be accessed by pzreq.sp.categories + * + *

Retrieves target categories available to the current Service Proxy user.

+ *

Target categories can be used to limit a search to resources tagged with the given + * category. The following request in a Faces page would obtain categories for display in, say, a select list: + *

+ * pzreq.sp.categories.run().targetCategories + *

+ * This would get the Service Proxy extension commands, pick the categories command, execute it, and retrieve + * a list of TargetCategory objects from the returned response data object. + *

+ * @author Niels Erik + * + */ public class CategoriesCommand extends Pazpar2Command implements ServiceProxyCommand { private static final long serialVersionUID = 5023993689780291641L; + private static Logger logger = Logger.getLogger(CategoriesCommand.class); 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() {