| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 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 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
|
|
|
| 86.4% |
Uncovered Elements: 3 (22) |
Complexity: 5 |
Complexity Density: 0.38 |
|
| 33 |
|
public class TransformForPOST extends TransformToServiceCall { |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
@see |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
|
|
|
| 85.7% |
Uncovered Elements: 3 (21) |
Complexity: 5 |
Complexity Density: 0.38 |
|
| 42 |
3
|
@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 |
|
} |