View Javadoc

1   /*
2    * #%L
3    * Bitrepository Core
4    * %%
5    * Copyright (C) 2010 - 2012 The State and University Library, The Royal Library and The State Archives, Denmark
6    * %%
7    * This program is free software: you can redistribute it and/or modify
8    * it under the terms of the GNU Lesser General Public License as 
9    * published by the Free Software Foundation, either version 2.1 of the 
10   * License, or (at your option) any later version.
11   * 
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Lesser Public License for more details.
16   * 
17   * You should have received a copy of the GNU General Lesser Public 
18   * License along with this program.  If not, see
19   * <http://www.gnu.org/licenses/lgpl-2.1.html>.
20   * #L%
21   */
22  package org.bitrepository.service.contributor.handler;
23  
24  import org.bitrepository.bitrepositoryelements.StatusCode;
25  import org.bitrepository.bitrepositoryelements.StatusInfo;
26  import org.bitrepository.bitrepositorymessages.GetStatusFinalResponse;
27  import org.bitrepository.bitrepositorymessages.IdentifyContributorsForGetStatusRequest;
28  import org.bitrepository.bitrepositorymessages.IdentifyContributorsForGetStatusResponse;
29  import org.bitrepository.bitrepositorymessages.MessageResponse;
30  import org.bitrepository.common.utils.ResponseInfoUtils;
31  import org.bitrepository.service.contributor.ContributorContext;
32  
33  /**
34   * Handler for the IdentifyContributorsForGetStatusRequest.
35   */
36  public class IdentifyContributorsForGetStatusRequestHandler 
37          extends AbstractRequestHandler<IdentifyContributorsForGetStatusRequest> {
38      
39      /**
40       * Constructor.
41       * @param context The context for the contributor.
42       */
43      public IdentifyContributorsForGetStatusRequestHandler(ContributorContext context) {
44          super(context);
45      }
46  
47      @Override
48      public Class<IdentifyContributorsForGetStatusRequest> getRequestClass() {
49          return IdentifyContributorsForGetStatusRequest.class;
50      }
51  
52      @Override
53      public void processRequest(IdentifyContributorsForGetStatusRequest request) {
54          IdentifyContributorsForGetStatusResponse response = new IdentifyContributorsForGetStatusResponse();
55          response.setContributor(getContext().getSettings().getComponentID());
56          response.setResponseInfo(ResponseInfoUtils.getPositiveIdentification());
57          getContext().getResponseDispatcher().dispatchResponse(response, request);
58      }
59  
60      @Override
61      public MessageResponse generateFailedResponse(IdentifyContributorsForGetStatusRequest request) {
62          GetStatusFinalResponse response = new GetStatusFinalResponse();
63          return response;
64      }
65  
66      /**
67       * Creates the default status info for the response.
68       * @return The status info for the response.
69       */
70      protected StatusInfo getStatus() {
71          StatusInfo status = new StatusInfo();
72          status.setStatusCode(StatusCode.OK);
73          status.setStatusText("Ok");
74          return status;
75      }
76  }