|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ConnectorContext | Line # 36 | 26 | 0% | 19 | 6 | 87.2% |
0.87234044
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (16) | |||
| Result | |||
|
0.80851066
|
net.sf.arestc.core.OverallDesignTest.testRepositoryRetrieval
net.sf.arestc.core.OverallDesignTest.testRepositoryRetrieval
|
1 PASS | |
|
0.80851066
|
net.sf.arestc.core.OverallDesignTest.testRepositoryMultiPost
net.sf.arestc.core.OverallDesignTest.testRepositoryMultiPost
|
1 PASS | |
|
0.80851066
|
net.sf.arestc.core.OverallDesignTest.testFileUpload
net.sf.arestc.core.OverallDesignTest.testFileUpload
|
1 PASS | |
|
0.80851066
|
net.sf.arestc.core.OverallDesignTest.testRepositoryCreate
net.sf.arestc.core.OverallDesignTest.testRepositoryCreate
|
1 PASS | |
|
0.80851066
|
net.sf.arestc.core.OverallDesignTest.testRepositoryDelete
net.sf.arestc.core.OverallDesignTest.testRepositoryDelete
|
1 PASS | |
|
0.7446808
|
net.sf.arestc.core.OverallDesignTest.testFileDownload
net.sf.arestc.core.OverallDesignTest.testFileDownload
|
1 PASS | |
|
0.7234042
|
net.sf.arestc.core.OverallDesignTest.testTicketRetrieval
net.sf.arestc.core.OverallDesignTest.testTicketRetrieval
|
1 PASS | |
|
0.5319149
|
net.sf.arestc.core.OverallDesignTest.testTicketRetrievalWithTicketer
net.sf.arestc.core.OverallDesignTest.testTicketRetrievalWithTicketer
|
1 PASS | |
|
0.21276596
|
net.sf.arestc.core.OverallDesignTest.testLoadResponseFromFile
net.sf.arestc.core.OverallDesignTest.testLoadResponseFromFile
|
1 PASS | |
|
0.12765957
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForDownloadFile
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForDownloadFile
|
1 PASS | |
|
0.12765957
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForUploadMultipart
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForUploadMultipart
|
1 PASS | |
|
0.12765957
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForLogin
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForLogin
|
1 PASS | |
|
0.12765957
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForUploadFile
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForUploadFile
|
1 PASS | |
|
0.12765957
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForNodeCreate
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForNodeCreate
|
1 PASS | |
|
0.12765957
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForNodeRetrieve
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForNodeRetrieve
|
1 PASS | |
|
0.12765957
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForNodeDelete
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForNodeDelete
|
1 PASS | |
| 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; | |
| 20 | ||
| 21 | import java.net.URI; | |
| 22 | import java.util.ArrayList; | |
| 23 | import java.util.List; | |
| 24 | ||
| 25 | import net.sf.arestc.core.services.RESTService; | |
| 26 | ||
| 27 | import org.apache.commons.httpclient.Credentials; | |
| 28 | import org.apache.commons.httpclient.Header; | |
| 29 | import org.apache.commons.httpclient.HttpClient; | |
| 30 | import org.apache.commons.httpclient.HttpMethod; | |
| 31 | ||
| 32 | // TODO: Auto-generated Javadoc | |
| 33 | /** | |
| 34 | * The Class ConnectorContext. | |
| 35 | */ | |
| 36 | public class ConnectorContext { | |
| 37 | ||
| 38 | /** The service uri. */ | |
| 39 | private URI serviceUri; | |
| 40 | ||
| 41 | /** The client. */ | |
| 42 | private final HttpClient client; | |
| 43 | ||
| 44 | /** The returned body. */ | |
| 45 | private Object returnedBody; | |
| 46 | ||
| 47 | /** The returned header. */ | |
| 48 | private Header[] returnedHeader; | |
| 49 | ||
| 50 | /** The method. */ | |
| 51 | private HttpMethod method; | |
| 52 | // private final ConnectorRequest request; | |
| 53 | // private ConnectorResponse response; | |
| 54 | ||
| 55 | /** The return stream. */ | |
| 56 | private boolean returnStream; | |
| 57 | ||
| 58 | /** The errors. */ | |
| 59 | private final List<ARESTCError> errors; | |
| 60 | ||
| 61 | /** The service. */ | |
| 62 | private final RESTService service; | |
| 63 | ||
| 64 | /** | |
| 65 | * Instantiates a new connector context. | |
| 66 | * | |
| 67 | * @param client | |
| 68 | * the client | |
| 69 | * @param theService | |
| 70 | * the the service | |
| 71 | */ | |
| 72 | 19 |
public ConnectorContext(final HttpClient client, |
| 73 | final RESTService theService) { | |
| 74 | // request = newRequest; | |
| 75 | 19 | service = theService; |
| 76 | ||
| 77 | 19 | errors = new ArrayList<ARESTCError>(); |
| 78 | 19 | this.client = client; |
| 79 | } | |
| 80 | ||
| 81 | /** | |
| 82 | * Adds the. | |
| 83 | * | |
| 84 | * @param e | |
| 85 | * the e | |
| 86 | * @return true, if successful | |
| 87 | */ | |
| 88 | 0 |
public boolean add(final ARESTCError e) { |
| 89 | 0 | return errors.add(e); |
| 90 | } | |
| 91 | ||
| 92 | /** | |
| 93 | * Gets the admin authentication. | |
| 94 | * | |
| 95 | * @param service | |
| 96 | * the service | |
| 97 | * @return the admin authentication | |
| 98 | */ | |
| 99 | 6 |
public Credentials getAdminAuthentication(final RESTService service) { |
| 100 | ||
| 101 | 6 | if ("admin".equals(service.getAuthenticatingUser())) { |
| 102 | 6 | return service.getAdminCredentials(); |
| 103 | } else { | |
| 104 | 0 | return null; |
| 105 | } | |
| 106 | ||
| 107 | } | |
| 108 | ||
| 109 | /** | |
| 110 | * Gets the client. | |
| 111 | * | |
| 112 | * @return the client | |
| 113 | */ | |
| 114 | 17 |
public HttpClient getClient() { |
| 115 | 17 | return client; |
| 116 | } | |
| 117 | ||
| 118 | /** | |
| 119 | * Gets the errors. | |
| 120 | * | |
| 121 | * @return the errors | |
| 122 | */ | |
| 123 | 0 |
public List<ARESTCError> getErrors() { |
| 124 | 0 | return errors; |
| 125 | } | |
| 126 | ||
| 127 | /** | |
| 128 | * Gets the method. | |
| 129 | * | |
| 130 | * @return the method | |
| 131 | */ | |
| 132 | 26 |
public HttpMethod getMethod() { |
| 133 | 26 | return method; |
| 134 | } | |
| 135 | ||
| 136 | /* | |
| 137 | * public ConnectorRequest getRequest() { return request; } | |
| 138 | * | |
| 139 | * public ConnectorResponse getResponse() { return response; } | |
| 140 | */ | |
| 141 | ||
| 142 | /** | |
| 143 | * Gets the returned body. | |
| 144 | * | |
| 145 | * @return the returned body | |
| 146 | */ | |
| 147 | 25 |
public Object getReturnedBody() { |
| 148 | 25 | return returnedBody; |
| 149 | } | |
| 150 | ||
| 151 | /** | |
| 152 | * Gets the returned header. | |
| 153 | * | |
| 154 | * @return the returned header | |
| 155 | */ | |
| 156 | 9 |
public Header[] getReturnedHeaders() { |
| 157 | 9 | Header[] ret = null; |
| 158 | ||
| 159 | 9 | if (null != returnedHeader) { |
| 160 | 8 | ret = new Header[returnedHeader.length]; |
| 161 | 8 | System.arraycopy(returnedHeader, 0, ret, 0, returnedHeader.length); |
| 162 | } | |
| 163 | 9 | return ret; |
| 164 | } | |
| 165 | ||
| 166 | /** | |
| 167 | * Gets the service. | |
| 168 | * | |
| 169 | * @return the service | |
| 170 | */ | |
| 171 | 97 |
public RESTService getService() { |
| 172 | 97 | return service; |
| 173 | } | |
| 174 | ||
| 175 | /** | |
| 176 | * Gets the service uri. | |
| 177 | * | |
| 178 | * @return the service uri | |
| 179 | */ | |
| 180 | 28 |
public URI getServiceUri() { |
| 181 | 28 | return serviceUri; |
| 182 | } | |
| 183 | ||
| 184 | /** | |
| 185 | * Checks if is error_occured. | |
| 186 | * | |
| 187 | * @return the error_occured | |
| 188 | */ | |
| 189 | 9 |
public boolean isError_occured() { |
| 190 | 9 | return !errors.isEmpty(); |
| 191 | } | |
| 192 | ||
| 193 | /** | |
| 194 | * Checks if is return stream. | |
| 195 | * | |
| 196 | * @return the returnStream | |
| 197 | */ | |
| 198 | 11 |
public boolean isReturnStream() { |
| 199 | 11 | return returnStream; |
| 200 | } | |
| 201 | ||
| 202 | /** | |
| 203 | * Sets the method. | |
| 204 | * | |
| 205 | * @param method | |
| 206 | * the method to set | |
| 207 | */ | |
| 208 | 10 |
public void setMethod(final HttpMethod method) { |
| 209 | 10 | this.method = method; |
| 210 | } | |
| 211 | ||
| 212 | /* | |
| 213 | * public void setResponse(final ConnectorResponse response) { this.response | |
| 214 | * = response; } | |
| 215 | */ | |
| 216 | ||
| 217 | /** | |
| 218 | * Sets the returned body. | |
| 219 | * | |
| 220 | * @param returnedBody | |
| 221 | * the new returned body | |
| 222 | */ | |
| 223 | 22 |
public void setReturnedBody(final Object returnedBody) { |
| 224 | 22 | this.returnedBody = returnedBody; |
| 225 | } | |
| 226 | ||
| 227 | /** | |
| 228 | * Sets the returned header. | |
| 229 | * | |
| 230 | * @param returnedHeader | |
| 231 | * the new returned header | |
| 232 | */ | |
| 233 | 9 |
public void setReturnedHeader(final Header[] returnedHeader) { |
| 234 | 9 | this.returnedHeader = new Header[returnedHeader.length]; |
| 235 | 9 | System.arraycopy(returnedHeader, 0, this.returnedHeader, 0, |
| 236 | returnedHeader.length); | |
| 237 | } | |
| 238 | ||
| 239 | /** | |
| 240 | * Sets the return stream. | |
| 241 | * | |
| 242 | * @param returnStream | |
| 243 | * the returnStream to set | |
| 244 | */ | |
| 245 | 1 |
public void setReturnStream(final boolean returnStream) { |
| 246 | 1 | this.returnStream = returnStream; |
| 247 | } | |
| 248 | ||
| 249 | /** | |
| 250 | * Sets the service uri. | |
| 251 | * | |
| 252 | * @param serviceUri | |
| 253 | * the new service uri | |
| 254 | */ | |
| 255 | 10 |
public void setServiceUri(final URI serviceUri) { |
| 256 | 10 | this.serviceUri = serviceUri; |
| 257 | } | |
| 258 | ||
| 259 | } | |
|
||||||||||||