use of org.eclipse.che.api.factory.server.urlfactory.DefaultFactoryUrl in project devspaces-images by redhat-developer.
the class DefaultFactoryParameterResolver method createFactory.
/**
* Creates factory based on provided parameters. Presumes url parameter as direct URL to a devfile
* content.
*
* @param factoryParameters map containing factory data parameters provided through URL
*/
@Override
public FactoryMetaDto createFactory(@NotNull final Map<String, String> factoryParameters) throws ApiException {
// This should never be null, because our contract in #accept prohibits that
String devfileLocation = factoryParameters.get(URL_PARAMETER_NAME);
URI devfileURI;
try {
devfileURI = new URL(devfileLocation).toURI();
} catch (MalformedURLException | URISyntaxException e) {
throw new BadRequestException(format("Unable to process provided factory URL. Please check its validity and try again. Parser message: %s", e.getMessage()));
}
return urlFactoryBuilder.createFactoryFromDevfile(new DefaultFactoryUrl().withDevfileFileLocation(devfileLocation), new URLFileContentProvider(devfileURI, urlFetcher), extractOverrideParams(factoryParameters)).orElse(null);
}
use of org.eclipse.che.api.factory.server.urlfactory.DefaultFactoryUrl in project che-server by eclipse-che.
the class DefaultFactoryParameterResolver method createFactory.
/**
* Creates factory based on provided parameters. Presumes url parameter as direct URL to a devfile
* content.
*
* @param factoryParameters map containing factory data parameters provided through URL
*/
@Override
public FactoryMetaDto createFactory(@NotNull final Map<String, String> factoryParameters) throws ApiException {
// This should never be null, because our contract in #accept prohibits that
String devfileLocation = factoryParameters.get(URL_PARAMETER_NAME);
URI devfileURI;
try {
devfileURI = new URL(devfileLocation).toURI();
} catch (MalformedURLException | URISyntaxException e) {
throw new BadRequestException(format("Unable to process provided factory URL. Please check its validity and try again. Parser message: %s", e.getMessage()));
}
return urlFactoryBuilder.createFactoryFromDevfile(new DefaultFactoryUrl().withDevfileFileLocation(devfileLocation), new URLFileContentProvider(devfileURI, urlFetcher), extractOverrideParams(factoryParameters)).orElse(null);
}
Aggregations