1 package com.indexdata.mkjsf.pazpar2.commands.sp;
\r
3 import org.apache.log4j.Logger;
\r
5 import com.indexdata.mkjsf.pazpar2.Pz2Service;
\r
6 import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command;
\r
7 import com.indexdata.mkjsf.pazpar2.data.sp.CategoriesResponse;
\r
10 * Represents a Service Proxy <code>categories</code> command, can be accessed by <code>pzreq.sp.categories</code>
\r
12 * <p>Retrieves target categories available to the current Service Proxy user.</p>
\r
13 * <p>Target categories can be used to limit a search to resources tagged with the given
\r
14 * category. The following request in a Faces page would obtain categories for display in, say, a select list:
\r
16 * <code>pzreq.sp.categories.run().targetCategories</code>
\r
18 * This would get the Service Proxy extension commands, pick the categories command, execute it, and retrieve
\r
19 * a list of TargetCategory objects from the returned response data object.
\r
21 * @author Niels Erik
\r
24 public class CategoriesCommand extends Pazpar2Command implements ServiceProxyCommand {
\r
26 private static final long serialVersionUID = 5023993689780291641L;
\r
27 private static Logger logger = Logger.getLogger(CategoriesCommand.class);
\r
29 public CategoriesCommand() {
\r
30 super("categories");
\r
34 public CategoriesResponse run () {
\r
35 if (Pz2Service.get().getPzresp().getSp().getCategories().unsupportedCommand()) {
\r
36 logger.info("Skipping seemingly unsupported categories command");
\r
37 return new CategoriesResponse();
\r
39 if (Pz2Service.get().isServiceProxyService()) {
\r
41 CategoriesResponse response = (CategoriesResponse) super.run();
\r
42 if (response.unsupportedCommand()) {
\r
43 logger.warn("Command 'categories' not supported by this Service Proxy");
\r
46 } catch (Exception e) {
\r
47 e.printStackTrace();
\r
48 return new CategoriesResponse();
\r
51 return new CategoriesResponse();
\r
57 public Pazpar2Command copy() {
\r
58 CategoriesCommand newCommand = new CategoriesCommand();
\r
63 public ServiceProxyCommand getSp() {
\r
68 public boolean spOnly() {
\r