當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。