当前位置: 首页>>代码示例>>Java>>正文


Java SlingHttpServletRequest.getParameter方法代码示例

本文整理汇总了Java中org.apache.sling.api.SlingHttpServletRequest.getParameter方法的典型用法代码示例。如果您正苦于以下问题:Java SlingHttpServletRequest.getParameter方法的具体用法?Java SlingHttpServletRequest.getParameter怎么用?Java SlingHttpServletRequest.getParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.sling.api.SlingHttpServletRequest的用法示例。


在下文中一共展示了SlingHttpServletRequest.getParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doGet

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
    String version = request.getParameter("version");
    String groupId = request.getParameter("groupId");
    String artifactId = request.getParameter("artifactId");

    boolean dependenciesOnly = "true".equals(request.getParameter("dependenciesOnly"));

    String responseContent;
    if(dependenciesOnly)
    {
        responseContent = pomGenerator.generateDependenciesPomFragment(bundleContext, "");
    }
    else
    {
        responseContent = pomGenerator.generatePOM(bundleContext, groupId, artifactId, version);
    }
    response.getWriter().write(responseContent);
}
 
开发者ID:sbrinkmann,项目名称:aem-maven-repository,代码行数:20,代码来源:MavenDependencyServlet.java

示例2: getParameters

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
private BackgroundJobParameters getParameters(final SlingHttpServletRequest request,
		final SlingHttpServletResponse response) throws IOException {
	final String searchPath = request.getParameter(FILE_REQUEST_PARAMETER);
	final String modeName = request.getParameter(MODE_REQUEST_PARAMETER);
	final String userName = request.getUserPrincipal().getName();

	if (StringUtils.isEmpty(searchPath)) {
		ServletUtils.writeMessage(response, ERROR_RESPONSE_TYPE,
				"Please set the script file name: -d \"file=[name]\"");
		return null;
	}

	if (StringUtils.isEmpty(modeName)) {
		ServletUtils.writeMessage(response, ERROR_RESPONSE_TYPE, "Running mode not specified.");
		return null;
	}

	return new BackgroundJobParameters(searchPath, modeName, userName);
}
 
开发者ID:Cognifide,项目名称:APM,代码行数:20,代码来源:ScriptRunBackgroundServlet.java

示例3: ImportSummaryModel

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
@Inject
public ImportSummaryModel(SlingHttpServletRequest request, @OSGiService ScriptManager scriptManager,
		@OSGiService JobResultsCache jobResultsCache, @OSGiService ScriptFinder scriptFinder)
		throws RepositoryException, PersistenceException {
	ResourceResolver resolver = request.getResourceResolver();
	this.mode = request.getParameter(MODE_PARAMETER) != null ?
			Mode.valueOf(request.getParameter(MODE_PARAMETER)) :
			null;
	final String scriptPath = request.getParameter(FILE_PARAMETER);
	final String progressJobId = request.getParameter(JOB_ID_PARAMETER);

	this.script = scriptFinder.find(scriptPath, resolver);
	Progress progress;
	if (StringUtils.isNotBlank(progressJobId)) {
		progress = jobResultsCache.get(progressJobId);
		if (progress == null) {
			progress = new ProgressImpl(resolver.getUserID());
		}
	} else {
		progress = scriptManager.process(script, mode, resolver);
	}
	this.progressLogger = progress;
}
 
开发者ID:Cognifide,项目名称:APM,代码行数:24,代码来源:ImportSummaryModel.java

示例4: doModifyProduct

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
private void doModifyProduct(SlingHttpServletRequest request, SlingHttpServletResponse response, CommerceSession session) throws IOException {
    String qty = request.getParameter("quantity");
    int quantity = StringUtils.isNumeric(qty) ? xssAPI.getValidInteger(qty, 1) : -1;
    if (quantity < 0) {
        response.sendError(HttpServletResponse.SC_FORBIDDEN);
        return;
    }

    String entryNumber = request.getParameter("entryNumber");
    int entry = xssAPI.getValidInteger(entryNumber, -1);
    try {
        if (entry < 0 || entry >= session.getCartEntries().size()) {
            response.sendError(HttpServletResponse.SC_FORBIDDEN);
            return;
        }

        if (quantity > 0) {
            session.modifyCartEntry(entry, quantity);
        } else {
            session.deleteCartEntry(entry);
        }

    } catch (CommerceException e) {
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:27,代码来源:CartEntryServlet.java

示例5: doAddProduct

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
private void doAddProduct(SlingHttpServletRequest request, SlingHttpServletResponse response, CommerceSession session)
        throws IOException {
    String productPath = request.getParameter("product-path");
    String qty = request.getParameter("product-quantity");

    Resource productResource = request.getResourceResolver().getResource(productPath);
    Product product = productResource.adaptTo(Product.class);

    int quantity = 1;
    if (qty != null && qty.length() > 0) {
        quantity = xssAPI.getValidInteger(qty, 1);
        if (quantity < 0) {
            quantity = 1;
        }
    }

    try {
        session.addCartEntry(product, quantity);
    } catch (CommerceException e) {
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:23,代码来源:CartEntryServlet.java

示例6: doFilter

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
@Override
public final void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
        throws IOException, ServletException {

    // Since we are in the context of a SlingFilter; the Request is always a SlingHttpServletRequest
    SlingHttpServletRequest slingHttpServletRequest = (SlingHttpServletRequest) request;

    // Set the thread local value based on your use case; in this case the thread local variable is set to "true"
    // if a HTTP Request parameter of "preview" is provided
    if (slingHttpServletRequest.getParameter("preview") != null) {
        THREAD_LOCAL.set(true);
    }

    try {
        // Continue processing the request chain
        chain.doFilter(request, response);
    } finally {
        // Good housekeeping; Clean up after yourself!!!
        THREAD_LOCAL.remove();
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-samples,代码行数:22,代码来源:SampleThreadLocalFilter.java

示例7: UptimeEntryModel

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
public UptimeEntryModel(SlingHttpServletRequest request) {
	this.resourceResolver = request.getResourceResolver();
	this.path = request.getParameter("path");
	
	if (this.path != null) {
		this.entryResource = resourceResolver.getResource(this.path);
		this.valueMap = this.entryResource.getValueMap();
	}
}
 
开发者ID:auniverseaway,项目名称:aem-touch-admin-console,代码行数:10,代码来源:UptimeEntryModel.java

示例8: doPost

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
@Override
protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
		throws ServletException, IOException {
	final String content = request.getParameter("content");
	if (StringUtils.isEmpty(content)) {
		response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
		ServletUtils.writeMessage(response, "error", "Script content is required");
		return;
	}

	try {
		final Progress progress = scriptManager.evaluate(content, Mode.VALIDATION, request.getResourceResolver());
		if (progress.isSuccess()) {
			ServletUtils.writeMessage(response, "success", "Script passes validation");
		} else {
			final String message = progress.getLastError().getLastMessageText();
			final Map<String, Object> context = new HashMap<>();

			if (message != null) {
				context.put("error", message);
			}

			ServletUtils.writeMessage(response, "error", "Script does not pass validation", context);
		}
	} catch (RepositoryException e) {
		response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
		ServletUtils.writeMessage(response, "error", String.format(
				"Script' cannot be validated because of " + "repository error: %s", e.getMessage()));
	}
}
 
开发者ID:Cognifide,项目名称:APM,代码行数:31,代码来源:ScriptValidationServlet.java

示例9: doPost

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
@Override
protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
		throws ServletException, IOException {
	final String all = request.getParameter("confirmation");
	final String fileName = request.getParameter("file");
	ResourceResolver resolver = request.getResourceResolver();
	if (fileName != null) {
		removeSingleFile(resolver, response, fileName);
	} else if (all != null) {
		removeAllFiles(resolver, response, all);
	} else {
		response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
		ServletUtils.writeMessage(response, "error", "Invalid arguments specified");
	}
}
 
开发者ID:Cognifide,项目名称:APM,代码行数:16,代码来源:ScriptRemoveServlet.java

示例10: doPost

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
@Override
protected void doPost(final SlingHttpServletRequest request, final SlingHttpServletResponse response)
		throws ServletException, IOException {

	String fileName = request.getParameter("filename");
	String content = request.getParameter("content");

	if (fileName == null || fileName.length() == 0) {
		LOGGER.error("Parameter fileName is required");
		return;
	}

	response.setContentType("application/octet-stream"); // Your content type
	response.setHeader("Content-Disposition",
			"attachment; filename=" + URLEncoder.encode(fileName, "UTF-8"));

	InputStream input = IOUtils.toInputStream(content);

	int read = 0;
	byte[] bytes = new byte[BYTES_DOWNLOAD];
	OutputStream os = response.getOutputStream();

	while ((read = input.read(bytes)) != -1) {
		os.write(bytes, 0, read);
	}
	input.close();
	os.flush();
	os.close();
}
 
开发者ID:Cognifide,项目名称:APM,代码行数:30,代码来源:ScriptResultServlet.java

示例11: doGet

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
@Override
protected void doGet(final SlingHttpServletRequest request, final SlingHttpServletResponse response)
		throws ServletException, IOException {
	final String id = request.getParameter(ID_REQUEST_PARAMETER);
	if (id == null) {
		return;
	}
	JobProgressOutput jobProgressOutput = scriptRunnerJobManager.checkJobStatus(id);
	ServletUtils.writeJson(response, gson.toJson(jobProgressOutput));
}
 
开发者ID:Cognifide,项目名称:APM,代码行数:11,代码来源:ScriptRunBackgroundServlet.java

示例12: doPost

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
@Override
protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
		throws ServletException, IOException {
	final ResourceResolver resolver = request.getResourceResolver();
	final String searchPath = request.getParameter("scriptPath");
	final Script script = scriptFinder.find(searchPath, resolver);
	if (script == null) {
		ServletUtils.writeMessage(response, "error", "Script not found: " + searchPath);
		return;
	}
	final ModifiableScript modifiableScript = new ModifiableScriptWrapper(resolver, script);
	try {
		final String executionMode = request.getParameter("executionMode");
		if (executionMode != null) {
			modifiableScript.setExecutionMode(ExecutionMode.valueOf(executionMode.toUpperCase()));
		}

		final String executionEnabled = request.getParameter("executionEnabled");
		if (executionEnabled != null) {
			modifiableScript.setExecutionEnabled(BooleanUtils.toBoolean(executionEnabled));
		}

		ServletUtils.writeMessage(response, "success", "Script configuration updated");
	} catch (PersistenceException e) {
		response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
		ServletUtils
				.writeMessage(response, "error", "Cannot update script configuration: " + e.getMessage());
	}
}
 
开发者ID:Cognifide,项目名称:APM,代码行数:30,代码来源:ScriptConfigServlet.java

示例13: ExecutionHistoryModel

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
@Inject
public ExecutionHistoryModel(@OSGiService History history, SlingHttpServletRequest request) {
	this.filter = request.getParameter("filter");
	executions = new ArrayList<>();
	for (Entry entry : history.findAll()) {
		executions.add(entry);
	}
	Collections.sort(executions);
}
 
开发者ID:Cognifide,项目名称:APM,代码行数:10,代码来源:ExecutionHistoryModel.java

示例14: getResults

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
private List<ListItem> getResults(SlingHttpServletRequest request, Resource searchResource, Page currentPage) {
    ValueMap valueMap = searchResource.getValueMap();
    ValueMap contentPolicyMap = getContentPolicyProperties(searchResource, request.getResource());
    int searchTermMinimumLength = valueMap.get(Search.PN_SEARCH_TERM_MINIMUM_LENGTH, contentPolicyMap.get(Search
            .PN_SEARCH_TERM_MINIMUM_LENGTH, SearchImpl.PROP_SEARCH_TERM_MINIMUM_LENGTH_DEFAULT));
    int resultsSize = valueMap.get(Search.PN_RESULTS_SIZE, contentPolicyMap.get(Search.PN_RESULTS_SIZE,
            SearchImpl.PROP_RESULTS_SIZE_DEFAULT));
    String searchRootPagePath = getSearchRootPagePath(searchResource, currentPage, contentPolicyMap);
    if (StringUtils.isEmpty(searchRootPagePath)) {
        searchRootPagePath = currentPage.getPath();
    }
    List<ListItem> results = new ArrayList<>();
    String fulltext = request.getParameter(PARAM_FULLTEXT);
    if (fulltext == null || fulltext.length() < searchTermMinimumLength) {
        return results;
    }
    long resultsOffset = 0;
    if (request.getParameter(PARAM_RESULTS_OFFSET) != null) {
        resultsOffset = Long.parseLong(request.getParameter(PARAM_RESULTS_OFFSET));
    }
    Map<String, String> predicatesMap = new HashMap<>();
    predicatesMap.put(PREDICATE_FULLTEXT, fulltext);
    predicatesMap.put(PREDICATE_PATH, searchRootPagePath);
    predicatesMap.put(PREDICATE_TYPE, NameConstants.NT_PAGE);
    PredicateGroup predicates = PredicateConverter.createPredicates(predicatesMap);
    ResourceResolver resourceResolver = request.getResource().getResourceResolver();
    Query query = queryBuilder.createQuery(predicates, resourceResolver.adaptTo(Session.class));
    if (resultsSize != 0) {
        query.setHitsPerPage(resultsSize);
    }
    if (resultsOffset != 0) {
        query.setStart(resultsOffset);
    }
    SearchResult searchResult = query.getResult();

    List<Hit> hits = searchResult.getHits();
    if (hits != null) {
        for (Hit hit : hits) {
            try {
                Resource hitRes = hit.getResource();
                Page page = getPage(hitRes);
                if (page != null) {
                    results.add(new PageListItemImpl(request, page));
                }
            } catch (RepositoryException e) {
                LOGGER.error("Unable to retrieve search results for query.", e);
            }
        }
    }
    return results;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:52,代码来源:SearchResultServlet.java

示例15: doDeleteProduct

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
private void doDeleteProduct(SlingHttpServletRequest request, SlingHttpServletResponse response, CommerceSession session) throws IOException {
    String entryNumber = request.getParameter("entryNumber");
    int entry = xssAPI.getValidInteger(entryNumber, -1);
    try {
        if (entry < 0 || entry >= session.getCartEntries().size()) {
            response.sendError(HttpServletResponse.SC_FORBIDDEN);
            return;
        }
        session.deleteCartEntry(entry);
    } catch (CommerceException e) {
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:14,代码来源:CartEntryServlet.java


注:本文中的org.apache.sling.api.SlingHttpServletRequest.getParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。