|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BaseRequestTransformer | Line # 33 | 9 | 0% | 5 | 5 | 61.5% |
0.61538464
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (15) | |||
| Result | |||
|
0.61538464
|
net.sf.arestc.core.OverallDesignTest.testFileDownload
net.sf.arestc.core.OverallDesignTest.testFileDownload
|
1 PASS | |
|
0.61538464
|
net.sf.arestc.core.OverallDesignTest.testRepositoryRetrieval
net.sf.arestc.core.OverallDesignTest.testRepositoryRetrieval
|
1 PASS | |
|
0.61538464
|
net.sf.arestc.core.OverallDesignTest.testRepositoryMultiPost
net.sf.arestc.core.OverallDesignTest.testRepositoryMultiPost
|
1 PASS | |
|
0.61538464
|
net.sf.arestc.core.OverallDesignTest.testFileUpload
net.sf.arestc.core.OverallDesignTest.testFileUpload
|
1 PASS | |
|
0.61538464
|
net.sf.arestc.core.OverallDesignTest.testRepositoryCreate
net.sf.arestc.core.OverallDesignTest.testRepositoryCreate
|
1 PASS | |
|
0.61538464
|
net.sf.arestc.core.OverallDesignTest.testRepositoryDelete
net.sf.arestc.core.OverallDesignTest.testRepositoryDelete
|
1 PASS | |
|
0.3846154
|
net.sf.arestc.core.OverallDesignTest.testTicketRetrieval
net.sf.arestc.core.OverallDesignTest.testTicketRetrieval
|
1 PASS | |
|
0.3846154
|
net.sf.arestc.core.OverallDesignTest.testTicketRetrievalWithTicketer
net.sf.arestc.core.OverallDesignTest.testTicketRetrievalWithTicketer
|
1 PASS | |
|
0.15384616
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForDownloadFile
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForDownloadFile
|
1 PASS | |
|
0.15384616
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForUploadMultipart
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForUploadMultipart
|
1 PASS | |
|
0.15384616
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForLogin
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForLogin
|
1 PASS | |
|
0.15384616
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForUploadFile
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForUploadFile
|
1 PASS | |
|
0.15384616
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForNodeCreate
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForNodeCreate
|
1 PASS | |
|
0.15384616
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForNodeRetrieve
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForNodeRetrieve
|
1 PASS | |
|
0.15384616
|
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.net.URISyntaxException; | |
| 23 | import java.text.MessageFormat; | |
| 24 | ||
| 25 | ||
| 26 | import org.apache.commons.httpclient.auth.AuthScope; | |
| 27 | import org.apache.log4j.Logger; | |
| 28 | ||
| 29 | // TODO: Auto-generated Javadoc | |
| 30 | /** | |
| 31 | * The Class BaseRequestTransformer. | |
| 32 | */ | |
| 33 | public abstract class BaseRequestTransformer implements RequestTransformer { | |
| 34 | ||
| 35 | /** The Constant ERROR_OCCURED_IN_PROCESS. */ | |
| 36 | private static final String ERROR_OCCURED_IN_PROCESS = "Error occured in process:"; | |
| 37 | /** The Constant ERROR_WHILE_TRYING_TO_CREATE_URI_FOR_THE_SERVICE. */ | |
| 38 | private static final String ERROR_WHILE_TRYING_TO_CREATE_URI_FOR_THE_SERVICE = "Error while trying to create URI for the service"; | |
| 39 | ||
| 40 | /** The Constant LOGGER. */ | |
| 41 | private static final Logger LOGGER = Logger.getLogger(BaseRequestTransformer.class | |
| 42 | .getName()); | |
| 43 | ||
| 44 | /** The command. */ | |
| 45 | private final ConnectorCommand command; | |
| 46 | ||
| 47 | /** | |
| 48 | * Instantiates a new base request transformer. | |
| 49 | * | |
| 50 | * @param com | |
| 51 | * the com | |
| 52 | */ | |
| 53 | 17 |
public BaseRequestTransformer(final ConnectorCommand com) { |
| 54 | 17 | command = com; |
| 55 | } | |
| 56 | ||
| 57 | /* | |
| 58 | * (non-Javadoc) | |
| 59 | * | |
| 60 | * @see | |
| 61 | * net.sf.arestc.core.commands.RequestTransformer#addError(net.sf.arestc | |
| 62 | * .core.ConnectorContext, java.lang.String) | |
| 63 | */ | |
| 64 | 0 |
public void addError(final ConnectorContext context, final String ErrorMsg) { |
| 65 | 0 | context.getErrors().add( |
| 66 | new BaseError(-1, command, ErrorMsg, context.getService())); | |
| 67 | } | |
| 68 | ||
| 69 | /* | |
| 70 | * (non-Javadoc) | |
| 71 | * | |
| 72 | * @see | |
| 73 | * net.sf.arestc.core.commands.RequestTransformer#authenticate(net.sf.arestc | |
| 74 | * .core.ConnectorRequest, net.sf.arestc.core.ConnectorContext) | |
| 75 | */ | |
| 76 | 6 |
public void authenticate(final ConnectorRequest request, |
| 77 | final ConnectorContext context) { | |
| 78 | 6 | request.setCredentials(context.getAdminAuthentication(context |
| 79 | .getService())); | |
| 80 | 6 | context.getClient() |
| 81 | .getState() | |
| 82 | .setCredentials( | |
| 83 | new AuthScope(context.getServiceUri().getHost(), | |
| 84 | context.getServiceUri().getPort(), | |
| 85 | AuthScope.ANY_REALM, context.getServiceUri() | |
| 86 | .getScheme()), request.getCredentials()); | |
| 87 | } | |
| 88 | ||
| 89 | /* | |
| 90 | * (non-Javadoc) | |
| 91 | * | |
| 92 | * @see | |
| 93 | * net.sf.arestc.core.commands.RequestTransformer#prepareUri(net.sf.arestc | |
| 94 | * .core.ConnectorRequest, net.sf.arestc.core.ConnectorContext, | |
| 95 | * java.lang.Object[]) | |
| 96 | */ | |
| 97 | 10 |
public void prepareUri(final ConnectorRequest request, |
| 98 | final ConnectorContext context, final Object[] params) | |
| 99 | throws CommandException { | |
| 100 | 10 | try { |
| 101 | 10 | context.setServiceUri(new URI(MessageFormat.format(context |
| 102 | .getService().getMethod().getURLPattern(), params))); | |
| 103 | } catch (final URISyntaxException e) { | |
| 104 | 0 | LOGGER.error(ERROR_OCCURED_IN_PROCESS, e); |
| 105 | 0 | addError(context, "URI Syntax for the service was wrong"); |
| 106 | 0 | throw new CommandException( |
| 107 | ERROR_WHILE_TRYING_TO_CREATE_URI_FOR_THE_SERVICE, e); | |
| 108 | } | |
| 109 | } | |
| 110 | ||
| 111 | } | |
|
||||||||||||