本文整理汇总了Java中org.ligoj.app.resource.plugin.CurlProcessor类的典型用法代码示例。如果您正苦于以下问题:Java CurlProcessor类的具体用法?Java CurlProcessor怎么用?Java CurlProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CurlProcessor类属于org.ligoj.app.resource.plugin包,在下文中一共展示了CurlProcessor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getLastVersion
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
@Override
public String getLastVersion() throws Exception {
// Get the download json from the default repository
final String portletVersions = new CurlProcessor().get(
"https://my.vmware.com/web/vmware/downloads?p_p_id=ProductIndexPortlet_WAR_itdownloadsportlet&p_p_lifecycle=2&p_p_resource_id=allProducts");
// Extract the version from the rw String, because of the non stable
// content format, but the links
// Search for : "target":
// "./info/slug/datacenter_cloud_infrastructure/vmware_vcloud_suite/6_0"
final int linkIndex = Math.min(
ObjectUtils.defaultIfNull(portletVersions, "").indexOf("vmware_vcloud_suite/") + "vmware_vcloud_suite/".length(),
portletVersions.length());
return portletVersions.substring(linkIndex, Math.min(Math.max(portletVersions.indexOf('#', linkIndex), linkIndex),
Math.max(portletVersions.indexOf('\"', linkIndex), linkIndex)));
}
开发者ID:ligoj,项目名称:plugin-vm-vcloud,代码行数:17,代码来源:VCloudPluginResource.java
示例2: toSpace
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
/**
* Map API JSON Space and history values to a bean.
*/
private Space toSpace(final String baseUrl, final Map<String, Object> spaceRaw, final String history, final CurlProcessor processor)
throws MalformedURLException {
final Space space = toSpaceLight(spaceRaw);
final String hostUrl = StringUtils.removeEnd(baseUrl, new java.net.URL(baseUrl).getPath());
// Check the activity if available
final Matcher matcher = ACTIVITY_PATTERN.matcher(StringUtils.defaultString(history));
if (matcher.find()) {
// Activity has been found
final SpaceActivity activity = new SpaceActivity();
getAvatar(processor, activity, hostUrl + matcher.group(1));
activity.setAuthor(toSimpleUser(matcher.group(2), matcher.group(3)));
activity.setPageUrl(hostUrl + matcher.group(4));
activity.setPage(matcher.group(5));
activity.setMoment(matcher.group(6));
space.setActivity(activity);
}
return space;
}
开发者ID:ligoj,项目名称:plugin-km-confluence,代码行数:23,代码来源:ConfluencePluginResource.java
示例3: checkStatus
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
@Override
public boolean checkStatus(final Map<String, String> parameters) throws Exception {
// Status is UP <=> Administration access is UP (if defined)
validateAccess(parameters);
final CurlProcessor processor = new ConfluenceCurlProcessor();
try {
// Check the user can log-in to Confluence
authenticate(parameters, processor);
// Check the user has enough rights to access to the plugin page
validateAdminAccess(parameters, processor);
} finally {
processor.close();
}
return true;
}
开发者ID:ligoj,项目名称:plugin-km-confluence,代码行数:18,代码来源:ConfluencePluginResource.java
示例4: validateAdminAccess
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
/**
* Validate the basic REST connectivity to SonarQube.
*
* @param parameters
* the server parameters.
* @return the detected SonarQube version.
*/
protected String validateAdminAccess(final Map<String, String> parameters) throws Exception {
final String url = StringUtils.appendIfMissing(parameters.get(PARAMETER_URL), "/") + "sessions/new";
CurlProcessor.validateAndClose(url, PARAMETER_URL, "sonar-connection");
// Check the user can log-in to SonarQube with the preempted authentication processor
if (!StringUtils.trimToEmpty(getResource(parameters, "api/authentication/validate?format=json")).contains("true")) {
throw new ValidationJsonException(PARAMETER_USER, "sonar-login");
}
// Check the user has enough rights to access to the provisioning page
if (getResource(parameters, "provisioning") == null) {
throw new ValidationJsonException(PARAMETER_USER, "sonar-rights");
}
return getVersion(parameters);
}
开发者ID:ligoj,项目名称:plugin-qa-sonarqube,代码行数:23,代码来源:SonarPluginResource.java
示例5: getEC2Keys
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
/**
* Return EC2 keys
*
* @param subscription
* The related subscription.
* @return EC2 keys related to given subscription.
*/
@Path("ec2/keys/{subscription:\\d+}")
@GET
public List<NamedBean<String>> getEC2Keys(@PathParam("subscription") final int subscription) {
// Call "DescribeKeyPairs" service
final String query = "Action=DescribeKeyPairs&Version=2016-11-15";
final AWS4SignatureQueryBuilder signatureQueryBuilder = AWS4SignatureQuery.builder().service("ec2")
.host("ec2." + getRegion() + ".amazonaws.com").path("/").body(query);
final CurlRequest request = newRequest(signatureQueryBuilder, subscription);
// extract key pairs from response
final List<NamedBean<String>> keys = new ArrayList<>();
if (new CurlProcessor().process(request)) {
final Matcher keyNames = Pattern.compile("<keyName>(.*)</keyName>").matcher(request.getResponse());
while (keyNames.find()) {
keys.add(new NamedBean<>(keyNames.group(1), null));
}
}
return keys;
}
开发者ID:ligoj,项目名称:plugin-prov-aws,代码行数:26,代码来源:ProvAwsPluginResource.java
示例6: clearJiraCache
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
/**
* Clear JIRA Cache.
*
* @see "http://localhost:6080/plugins/servlet/scriptrunner/builtin?section=builtin_scripts#"
* @see "https://marketplace.atlassian.com/plugins/com.onresolve.jira.groovy.groovyrunner"
*/
protected boolean clearJiraCache(final ImportContext context, final ImportStatus result, final CurlProcessor processor) {
if (result.getScriptRunner()) {
final List<CurlRequest> requests = new ArrayList<>();
final String url = context.parameters.get(PARAMETER_URL) + "/secure/admin/groovy/CannedScriptRunner.jspa";
requests.add(new CurlRequest(HttpMethod.POST, url,
"cannedScript=com.onresolve.jira.groovy.canned.admin.ClearCaches" + "&cannedScriptArgs_FIELD_WHICH_CACHE=jira"
+ "&cannedScriptArgs_Hidden_FIELD_WHICH_CACHE=jira" + "&cannedScriptArgs_Hidden_output=Cache+cleared."
+ "&cannedScript=com.onresolve.jira.groovy.canned.admin.ClearCaches&id="
+ "&atl_token=B3WY-Y7OK-4J8S-4GH4%7Ca2a4f45ffb53fcf8fbb12453e587949470377ec7%7Clin" + "&RunCanned=Run"
+ "&webSudoIsPost=true&os_cookie=true",
"Accept:application/json, text/javascript, */*; q=0.01"));
return processor.process(requests);
}
return false;
}
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:22,代码来源:JiraImportPluginResource.java
示例7: authenticateAdmin
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
/**
* Prepare an authenticated connection to JIRA
*/
protected boolean authenticateAdmin(final Map<String, String> parameters, final CurlProcessor processor) {
final String user = parameters.get(PARAMETER_ADMIN_USER);
final String password = StringUtils.trimToEmpty(parameters.get(PARAMETER_ADMIN_PASSWORD));
final String baseUrl = parameters.get(PARAMETER_URL);
final String url = StringUtils.appendIfMissing(baseUrl, "/") + "login.jsp";
final List<CurlRequest> requests = new ArrayList<>();
requests.add(new CurlRequest(HttpMethod.GET, url, null));
requests.add(new CurlRequest(HttpMethod.POST, url,
"os_username=" + user + "&os_password=" + password + "&os_destination=&atl_token=&login=Connexion",
JiraCurlProcessor.LOGIN_CALLBACK, "Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"));
// Sudoing is only required for JIRA 4+
if ("4".compareTo(getVersion(parameters)) <= 0) {
requests.add(
new CurlRequest(HttpMethod.POST, StringUtils.appendIfMissing(baseUrl, "/") + "secure/admin/WebSudoAuthenticate.jspa",
"webSudoIsPost=false&os_cookie=true&authenticate=Confirm&webSudoPassword=" + password,
JiraCurlProcessor.SUDO_CALLBACK, "Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"));
}
return processor.process(requests);
}
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:24,代码来源:JiraBaseResource.java
示例8: testSynchronizeJiraNoScriptRunner
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
@Test
public void testSynchronizeJiraNoScriptRunner() throws Exception {
final ImportContext context = new ImportContext();
final ImportStatus result = new ImportStatus();
result.setCanSynchronizeJira(true);
final JiraImportPluginResource resource = Mockito.mock(JiraImportPluginResource.class);
Mockito.doCallRealMethod().when(resource).synchronizeJira(ArgumentMatchers.same(context), ArgumentMatchers.same(result));
Mockito.when(resource.authenticateAdmin(ArgumentMatchers.same(context), ArgumentMatchers.any(CurlProcessor.class)))
.thenReturn(true);
resource.synchronizeJira(context, result);
Mockito.verify(resource, Mockito.times(1)).authenticateAdmin(ArgumentMatchers.same(context),
ArgumentMatchers.any(CurlProcessor.class));
Mockito.verify(resource, Mockito.times(1)).clearJiraCache(ArgumentMatchers.same(context), ArgumentMatchers.same(result),
ArgumentMatchers.any(CurlProcessor.class));
Mockito.verify(resource, Mockito.never()).reIndexProject(ArgumentMatchers.same(context), ArgumentMatchers.same(result),
ArgumentMatchers.any(CurlProcessor.class));
Assert.assertFalse(result.getSynchronizedJira());
}
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:19,代码来源:JiraImportPluginResourceTest.java
示例9: testSynchronizeJiraReindexFailed
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
@Test
public void testSynchronizeJiraReindexFailed() throws Exception {
final ImportContext context = new ImportContext();
final ImportStatus result = new ImportStatus();
result.setCanSynchronizeJira(true);
final JiraImportPluginResource resource = Mockito.mock(JiraImportPluginResource.class);
Mockito.doCallRealMethod().when(resource).synchronizeJira(ArgumentMatchers.same(context), ArgumentMatchers.same(result));
Mockito.when(resource.authenticateAdmin(ArgumentMatchers.same(context), ArgumentMatchers.any(CurlProcessor.class)))
.thenReturn(true);
Mockito.when(resource.clearJiraCache(ArgumentMatchers.same(context), ArgumentMatchers.same(result),
ArgumentMatchers.any(CurlProcessor.class))).thenReturn(true);
resource.synchronizeJira(context, result);
Mockito.verify(resource, Mockito.times(1)).authenticateAdmin(ArgumentMatchers.same(context),
ArgumentMatchers.any(CurlProcessor.class));
Mockito.verify(resource, Mockito.times(1)).clearJiraCache(ArgumentMatchers.same(context), ArgumentMatchers.same(result),
ArgumentMatchers.any(CurlProcessor.class));
Mockito.verify(resource, Mockito.times(1)).reIndexProject(ArgumentMatchers.same(context), ArgumentMatchers.same(result),
ArgumentMatchers.any(CurlProcessor.class));
Assert.assertFalse(result.getSynchronizedJira());
}
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:21,代码来源:JiraImportPluginResourceTest.java
示例10: testSynchronizeJira
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
@Test
public void testSynchronizeJira() throws Exception {
final ImportContext context = new ImportContext();
final ImportStatus result = new ImportStatus();
result.setCanSynchronizeJira(true);
final JiraImportPluginResource resource = Mockito.mock(JiraImportPluginResource.class);
Mockito.doCallRealMethod().when(resource).synchronizeJira(ArgumentMatchers.same(context), ArgumentMatchers.same(result));
Mockito.when(resource.authenticateAdmin(ArgumentMatchers.same(context), ArgumentMatchers.any(CurlProcessor.class)))
.thenReturn(true);
Mockito.when(resource.clearJiraCache(ArgumentMatchers.same(context), ArgumentMatchers.same(result),
ArgumentMatchers.any(CurlProcessor.class))).thenReturn(true);
Mockito.when(resource.reIndexProject(ArgumentMatchers.same(context), ArgumentMatchers.same(result),
ArgumentMatchers.any(CurlProcessor.class))).thenReturn(true);
resource.synchronizeJira(context, result);
Assert.assertTrue(result.getSynchronizedJira());
}
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:17,代码来源:JiraImportPluginResourceTest.java
示例11: execute
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
/**
* Return/execute a vCloud resource. Return <code>null</code> when the
* resource is not found. Authentication should be proceeded before for
* authenticated query.
*/
protected String execute(final CurlProcessor processor, final String method, final String url, final String resource) {
// Get the resource using the preempted authentication
final CurlRequest request = new CurlRequest(method, StringUtils.appendIfMissing(url, "/") + StringUtils.removeStart(resource, "/"),
null);
request.setSaveResponse(true);
// Execute the requests
processor.process(request);
processor.close();
return request.getResponse();
}
开发者ID:ligoj,项目名称:plugin-vm-vcloud,代码行数:17,代码来源:VCloudPluginResource.java
示例12: authenticate
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
/**
* Prepare an authenticated connection to Confluence
*/
protected void authenticate(final Map<String, String> parameters, final CurlProcessor processor) {
final String user = parameters.get(PARAMETER_USER);
final String password = StringUtils.trimToEmpty(parameters.get(PARAMETER_PASSWORD));
final String url = StringUtils.appendIfMissing(parameters.get(PARAMETER_URL), "/") + "dologin.action";
final List<CurlRequest> requests = new ArrayList<>();
requests.add(new CurlRequest(HttpMethod.GET, url, null));
requests.add(new CurlRequest(HttpMethod.POST, url,
"os_username=" + user + "&os_password=" + password + "&os_destination=&atl_token=&login=Connexion",
ConfluenceCurlProcessor.LOGIN_CALLBACK, "Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"));
if (!processor.process(requests)) {
throw new ValidationJsonException(PARAMETER_URL, "confluence-login", parameters.get(PARAMETER_USER));
}
}
开发者ID:ligoj,项目名称:plugin-km-confluence,代码行数:17,代码来源:ConfluencePluginResource.java
示例13: validateAdminAccess
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
/**
* Validate the administration connectivity. Expect an authenticated
* connection.
*/
private void validateAdminAccess(final Map<String, String> parameters, final CurlProcessor processor) {
final List<CurlRequest> requests = new ArrayList<>();
// Request plugins access
final String url = parameters.get(PARAMETER_URL);
requests.add(new CurlRequest(HttpMethod.GET, StringUtils.appendIfMissing(url, "/") + "plugins/servlet/upm", null));
if (!processor.process(requests)) {
throw new ValidationJsonException(PARAMETER_URL, "confluence-admin", parameters.get(PARAMETER_USER));
}
}
开发者ID:ligoj,项目名称:plugin-km-confluence,代码行数:15,代码来源:ConfluencePluginResource.java
示例14: getAvatar
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
/**
* Return the avatar PNG file from URL.
*/
private void getAvatar(final CurlProcessor processor, final SpaceActivity activity, final String avatarUrl) {
if (!avatarUrl.endsWith("/default.png")) {
// Not default URL, get the PNG bytes
processor.process(new CurlRequest("GET", avatarUrl, null, (req, res) -> {
// PNG to DATA URL
if (res.getStatusLine().getStatusCode() == HttpServletResponse.SC_OK) {
activity.setAuthorAvatar("data:image/png;base64,"
+ DatatypeConverter.printBase64Binary(IOUtils.toByteArray(res.getEntity().getContent())));
}
return true;
}));
}
}
开发者ID:ligoj,项目名称:plugin-km-confluence,代码行数:17,代码来源:ConfluencePluginResource.java
示例15: getConfluenceResource
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
/**
* Return a Jenkins's resource. Return <code>null</code> when the resource
* is not found.
*/
protected String getConfluenceResource(final CurlProcessor processor, final String url, final String resource) {
// Get the resource using the preempted authentication
final CurlRequest request = new CurlRequest(HttpMethod.GET, StringUtils.removeEnd(url, "/") + resource, null);
request.setSaveResponse(true);
// Execute the requests
processor.process(request);
processor.close();
return request.getResponse();
}
开发者ID:ligoj,项目名称:plugin-km-confluence,代码行数:15,代码来源:ConfluencePluginResource.java
示例16: newCurlProcessor
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
/**
* Create a new processor using a basic authentication header.
*
* @param parameters
* The subscription parameters.
* @return The configured {@link CurlProcessor} to use.
*/
protected CurlProcessor newCurlProcessor(final Map<String, String> parameters) {
final String user = parameters.get(parameterUser);
final String password = StringUtils.trimToEmpty(parameters.get(parameterPassword));
// Authenticated access
return new AuthCurlProcessor(user, password);
}
开发者ID:ligoj,项目名称:plugin-scm,代码行数:15,代码来源:AbstractIndexBasedPluginResource.java
示例17: validateAdminAccess
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
/**
* Validate the administration connectivity. Expect an authenticated connection.
*/
private void validateAdminAccess(final Map<String, String> parameters, final CurlProcessor processor) {
final CurlRequest request = new CurlRequest(HttpMethod.GET, StringUtils.appendIfMissing(parameters.get(parameterUrl), "/"), null);
request.setSaveResponse(true);
// Request all repositories access
if (!processor.process(request) || !StringUtils.contains(request.getResponse(), "<a href=\"/\">")) {
throw new ValidationJsonException(parameterUrl, simpleName + "-admin", parameters.get(parameterUser));
}
}
开发者ID:ligoj,项目名称:plugin-scm,代码行数:12,代码来源:AbstractIndexBasedPluginResource.java
示例18: installPrices
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
/**
* Install AWS prices from the JSON file.
*
* @param node
* The related AWS {@link Node}
* @param regions
* The available regions.
* @param api
* The API name, only for log.
* @param endpoint
* The prices end-point JSON URL.
* @param apiClass
* The mapping model from JSON at region level.
* @param mapper
* The mapping function from JSON at region level to JPA entity.
*/
private <R extends AwsRegionPrices, T extends AwsPrices<R>> void installPrices(final Node node, final Map<String, ProvLocation> regions,
final String api, final String endpoint, final Class<T> apiClass, final BiFunction<R, ProvLocation, Integer> mapper)
throws IOException {
log.info("AWS {} prices...", api);
// Track the created instance to cache instance and price type
int priceCounter = 0;
importCatalogResource.nextStep(node.getId(), t -> t.setPhase(api));
try {
// Get the remote prices stream
String rawJson = StringUtils.defaultString(new CurlProcessor().get(endpoint), "callback({\"config\":{\"regions\":[]}});");
// All regions are considered
final int configIndex = rawJson.indexOf('{');
final int configCloseIndex = rawJson.lastIndexOf('}');
final T prices = objectMapper.readValue(rawJson.substring(configIndex, configCloseIndex + 1), apiClass);
// Install the region as needed
prices.getConfig().getRegions().forEach(r -> r
.setRegion(installRegion(regions, mapSpotToNewRegion.getOrDefault(r.getRegion(), r.getRegion()), node).getName()));
nextStep(node, null, 0);
// Install the (EC2 + Spot) prices for each region
priceCounter = prices.getConfig().getRegions().stream().mapToInt(r -> mapper.apply(r, regions.get(r.getRegion()))).sum();
} finally {
// Report
log.info("AWS {} import finished : {} prices", api, priceCounter);
nextStep(node, null, 1);
}
}
开发者ID:ligoj,项目名称:plugin-prov-aws,代码行数:48,代码来源:ProvAwsPriceImportResource.java
示例19: validateAccess
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
/**
* Check AWS connection and account.
*
* @param parameters
* Subscription parameters.
* @return <code>true</code> if AWS connection is up
*/
private boolean validateAccess(final Map<String, String> parameters) {
// Call S3 ls service
// TODO Use EC2 instead of S3
final AWS4SignatureQueryBuilder signatureQueryBuilder = AWS4SignatureQuery.builder().method("GET").service("s3").host(getS3Host())
.path("/");
return new CurlProcessor().process(newRequest(signatureQueryBuilder, parameters));
}
开发者ID:ligoj,项目名称:plugin-prov-aws,代码行数:15,代码来源:ProvAwsPluginResource.java
示例20: synchronizeJira
import org.ligoj.app.resource.plugin.CurlProcessor; //导入依赖的package包/类
/**
* Synchronize JIRA
*/
protected void synchronizeJira(final ImportContext context, final ImportStatus result) {
if (result.getCanSynchronizeJira()) {
// Administration account has been provided
final CurlProcessor processor = new JiraCurlProcessor();
result.setSynchronizedJira(authenticateAdmin(context, processor) && clearJiraCache(context, result, processor)
&& reIndexProject(context, result, processor));
processor.close();
}
}
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:13,代码来源:JiraImportPluginResource.java
注:本文中的org.ligoj.app.resource.plugin.CurlProcessor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论