當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpServletResponse.SC_METHOD_NOT_ALLOWED屬性代碼示例

本文整理匯總了Java中javax.servlet.http.HttpServletResponse.SC_METHOD_NOT_ALLOWED屬性的典型用法代碼示例。如果您正苦於以下問題:Java HttpServletResponse.SC_METHOD_NOT_ALLOWED屬性的具體用法?Java HttpServletResponse.SC_METHOD_NOT_ALLOWED怎麽用?Java HttpServletResponse.SC_METHOD_NOT_ALLOWED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.servlet.http.HttpServletResponse的用法示例。


在下文中一共展示了HttpServletResponse.SC_METHOD_NOT_ALLOWED屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: manageKalturaMediaEntries

/**
 * Allows use to get the various kaltura media entries for a user directly and to manage them as well
 */
@EntityCustomAction(action="kme", viewKey="")
public Object manageKalturaMediaEntries(EntityView view, Search search, Map<String, Object> data) {
    // GET /kaltura/kme
    // GET /kaltura/kme/keid
    // PUT /kaltura/kme/keid
    // DEL /kaltura/kme/keid
    Object result = null;
    String keid = view.getPathSegment(2);
    if ( StringUtils.isBlank(keid) ) {
        if (EntityView.Method.GET.name().equals(view.getMethod())) {
            // get all kaltura items
            String query = "";
            String qstr = (String) search.getRestrictionValueByProperties(new String[] {"search"});
            if (qstr != null) {
                query = qstr;
            }
            String[] keids = null;
            String keidsStr = (String) search.getRestrictionValueByProperties(new String[] {"keids"});
            if (keidsStr != null) {
                keids = StringUtils.split(keidsStr, ", "); // WARNING: will split on space OR comma
            }
            result = kalturaAPIService.getKalturaItems(query, keids, (int) search.getStart(), (int) search.getLimit());
        } else {
            throw new EntityException("Only GET is supported for retrieving the list of KMEs", view.getEntityURL(), HttpServletResponse.SC_METHOD_NOT_ALLOWED);
        }
    } else {
        // get the kaltura entry
        KalturaMediaEntry kme = kalturaAPIService.getKalturaItem(keid);
        if (kme == null) {
            throw new EntityNotFoundException("No kme with the given id: "+keid, view.getEntityURL());
        }
        if (EntityView.Method.GET.name().equals(view.getMethod())) {
            // return a single kme
            result = kme;
        } else if (EntityView.Method.DELETE.name().equals(view.getMethod())) {
            // remove this kme
            result = kalturaAPIService.removeKalturaItem(keid);
        } else {
            // update the kme
            developerHelperService.copyBean(data, kme, 0, null, true);
            result = kalturaAPIService.updateKalturaItem(kme);
        }
    }
    return result;
}
 
開發者ID:ITYug,項目名稱:kaltura-ce-sakai-extension,代碼行數:48,代碼來源:KalturaEntityProvider.java

示例2: getWebContentPrivate

private ResponseImpl getWebContentPrivate(Request request, @Nullable ProxyDetails proxy, boolean followRedirects)
{
	final String url = request.getUrl();
	try
	{
		@SuppressWarnings("unused")
		URL u = new URL(url); // NOSONAR
	}
	catch( MalformedURLException ex )
	{
		return new ResponseImpl(HttpServletResponse.SC_BAD_REQUEST, "Invalid URL: " + url);
	}
	HttpRequestBase httpMethod = null;
	try
	{
		httpMethod = getHttpMethod(request);
		if( httpMethod == null )
		{
			return new ResponseImpl(HttpServletResponse.SC_METHOD_NOT_ALLOWED,
				"Only GET, POST, HEAD, PUT, DELETE and OPTIONS methods are supported");
		}
		if( !followRedirects )
		{
			HttpClientParams.setRedirecting(httpMethod.getParams(), false);
		}

		final DefaultHttpClient client = createClient(httpMethod.getURI().getScheme().equals("https"));

		if( proxy != null && proxy.isConfigured() )
		{
			final URI uri = httpMethod.getURI();
			final String host = uri.getHost();
			if( !proxy.isHostExcepted(host) )
			{
				final HttpHost proxyHost = new HttpHost(proxy.getHost(), proxy.getPort());
				client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxyHost);
				if( !Check.isEmpty(proxy.getUsername()) )
				{
					client.getCredentialsProvider().setCredentials(
						new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT),
						new UsernamePasswordCredentials(proxy.getUsername(), proxy.getPassword()));

				}
			}
		}

		// TODO: see fixme about cookie cache
		final String cacheKey = /* req.getSession().getId() */"FIXME" + ':' + url;
		Cookies cookies = COOKIE_CACHE.getIfPresent(cacheKey);
		if( cookies == null )
		{
			cookies = new Cookies();
			COOKIE_CACHE.put(cacheKey, cookies);
		}

		final HttpResponse response = exec(client, httpMethod, cookies);
		return new ResponseImpl(response, httpMethod);
	}
	catch( Exception e )
	{
		throw new RuntimeException(e);
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:63,代碼來源:HttpServiceImpl.java


注:本文中的javax.servlet.http.HttpServletResponse.SC_METHOD_NOT_ALLOWED屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。