Clover Coverage Report - ARESTC 0.1.5
Coverage timestamp: Tue Aug 10 2010 10:22:22 CEST
../../../../../img/srcFileCovDistChart9.png 44% of files have more coverage
13   81   5   13
8   43   0.38   1
1     5  
1    
 
  TransformForPOST       Line # 33 13 0% 5 3 86.4% 0.8636364
 
  (3)
 
1    /*
2    *
3    * (C)opyright 2010, Nikolaos Georgosopoulos
4    *
5    * This file is part of ARESTC.
6    *
7    * ARESTC is free software: you can redistribute it and/or modify it under the
8    * terms of the Lesser General Public License as published by the Free Software
9    * Foundation, either version 3 of the License, or (at your option) any later
10    * version.
11    *
12    * ARESTC is distributed in the hope that it will be useful, but WITHOUT ANY
13    * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14    * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15    *
16    * You should have received a copy of the Lesser General Public License along
17    * with ARESTC. If not, see <http://www.gnu.org/licenses/>.
18    */
19    package net.sf.arestc.core.commands;
20   
21    import net.sf.arestc.core.CommandException;
22    import net.sf.arestc.core.ConnectorContext;
23    import net.sf.arestc.core.ConnectorRequest;
24   
25    import org.apache.commons.httpclient.auth.AuthScope;
26    import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
27    import org.apache.commons.httpclient.methods.PutMethod;
28   
29    // TODO: Auto-generated Javadoc
30    /**
31    * The Class TransformForPOST.
32    */
 
33    public class TransformForPOST extends TransformToServiceCall {
34   
35    /*
36    * (non-Javadoc)
37    *
38    * @see
39    * net.sf.arestc.core.commands.TransformToServiceCall#process(net.sf.arestc
40    * .core.ConnectorRequest, net.sf.arestc.core.ConnectorContext)
41    */
 
42  3 toggle @Override
43    public ConnectorContext process(final ConnectorRequest request,
44    final ConnectorContext context) throws CommandException {
45   
46  3 if (getValidator().validateRequest(request, context)) {
47   
48  3 prepareUri(request, context);
49  3 context.setMethod(context.getService().getMethod()
50    .getMethod(context.getServiceUri().toString()));
51  3 prepareBody(request, context);
52   
53  3 ((EntityEnclosingMethod) context.getMethod())
54    .setRequestEntity(request.getBody());
55  3 if (PutMethod.class
56    .isAssignableFrom(context.getMethod().getClass())) {
57  1 context.getMethod().addRequestHeader("Content-Type",
58    context.getService().getContentType());
59    }
60  3 if (context.getService().isAuthenticationRequired()) {
61  3 request.setCredentials(context.getAdminAuthentication(context
62    .getService()));
63  3 if (context.getService().isAuthenticationRequired()) {
64  3 request.setCredentials(context
65    .getAdminAuthentication(context.getService()));
66  3 context.getClient()
67    .getState()
68    .setCredentials(
69    new AuthScope(context.getServiceUri()
70    .getHost(), context.getServiceUri()
71    .getPort(), AuthScope.ANY_REALM,
72    context.getServiceUri().getScheme()),
73    request.getCredentials());
74    }
75    }
76   
77    }
78   
79  3 return super.process(request, context);
80    }
81    }