List of usage examples for com.google.common.net HttpHeaders CONTENT_TYPE
String CONTENT_TYPE
To view the source code for com.google.common.net HttpHeaders CONTENT_TYPE.
Click Source Link
From source file:eu.seaclouds.policy.SeaCloudsManagementPolicy.java
private HttpToolResponse post(String url, String mediaType, String username, String password, byte[] payload) { URI apiEndpoint = URI.create(url); // the uri is required by the HttpClientBuilder in order to set the AuthScope of the credentials if (username == null || password == null) { return HttpTool.httpPost(HttpTool.httpClientBuilder().build(), apiEndpoint, MutableMap.of(HttpHeaders.CONTENT_TYPE, mediaType, HttpHeaders.ACCEPT, mediaType), payload); } else {//from www . ja v a2s .c o m UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password); // the uri is required by the HttpClientBuilder in order to set the AuthScope of the credentials return HttpTool.httpPost(HttpTool.httpClientBuilder().uri(apiEndpoint).credentials(credentials).build(), apiEndpoint, MutableMap.of(HttpHeaders.CONTENT_TYPE, mediaType, HttpHeaders.ACCEPT, mediaType, HttpHeaders.AUTHORIZATION, HttpTool.toBasicAuthorizationValue(credentials)), payload); } }
From source file:com.tinspx.util.net.Headers.java
/** * Returns the value of the {@code Content-Type} header or the empty string * if missing. */ public String contentType() { return last(HttpHeaders.CONTENT_TYPE); }
From source file:com.tinspx.util.net.Headers.java
/** * Sets the value of the {@code Content-Type} header. */ public Headers contentType(@NonNull String contentType) { return set(HttpHeaders.CONTENT_TYPE, contentType); }
From source file:org.fenixedu.academic.api.FenixAPIv1.java
/** * calendar of all written evaluations (tests and exams). Available for * students and teachers./* ww w .jav a 2s. c o m*/ * * @summary Evaluations calendar * @param format * ("calendar" or "json") * @return If format is "calendar", returns iCal format. If not returns the * following json. * @servicetag SCHEDULE_SCOPE */ @FenixAPIScope(SCHEDULE_SCOPE) @OAuthEndpoint(SCHEDULE_SCOPE) @GET @Path("person/calendar/evaluations") public Response calendarEvaluation(@QueryParam("format") String format) { validateFormat(format); final Person person = getPerson(); if (!RoleType.STUDENT.isMember(person.getUser())) { return Response.status(Status.OK).header(HttpHeaders.CONTENT_TYPE, JSON_UTF8).entity("{}").build(); } if ("calendar".equals(format)) { String evaluationCalendarICal = evaluationCalendarICal(person); return Response.ok(evaluationCalendarICal, "text/calendar;charset=UTF-8").build(); } else { return Response.status(Status.OK).header(HttpHeaders.CONTENT_TYPE, JSON_UTF8) .entity(evaluationCalendarJson(person)).build(); } }
From source file:net.sourceforge.fenixedu.webServices.jersey.api.FenixAPIv1.java
/** * calendar of all written evaluations (tests and exams). Available for * students and teachers./*from w w w .java 2 s . c o m*/ * * @summary Evaluations calendar * @param format * ("calendar" or "json") * @return If format is "calendar", returns iCal format. If not returns the * following json. * @servicetag SCHEDULE_SCOPE */ @FenixAPIScope(SCHEDULE_SCOPE) @GET @Path("person/calendar/evaluations") public Response calendarEvaluation(@QueryParam("format") String format) { validateFormat(format); final Person person = getPerson(); if (!person.hasRole(RoleType.STUDENT)) { return Response.status(Status.OK).header(HttpHeaders.CONTENT_TYPE, JSON_UTF8).entity("{}").build(); } if ("calendar".equals(format)) { String evaluationCalendarICal = evaluationCalendarICal(person); return Response.ok(evaluationCalendarICal, "text/calendar;charset=UTF-8").build(); } else { return Response.status(Status.OK).header(HttpHeaders.CONTENT_TYPE, JSON_UTF8) .entity(evaluationCalendarJson(person)).build(); } }
From source file:org.fenixedu.academic.api.FenixAPIv1.java
/** * calendar of all lessons of students and teachers * * @summary Classes calendar//w w w . j ava2s . c om * @param format * ("calendar" or "json") * @return If format is "calendar", returns iCal format. If not returns the * following json. * @servicetag SCHEDULE_SCOPE */ @FenixAPIScope(SCHEDULE_SCOPE) @OAuthEndpoint(SCHEDULE_SCOPE) @GET @Path("person/calendar/classes") public Response calendarClasses(@QueryParam("format") String format) { validateFormat(format); Person person = getPerson(); if ("calendar".equals(format)) { String classesCalendarICal = classesCalendarICal(person); return Response.ok(classesCalendarICal, "text/calendar; charset=UTF-8").build(); } else { return Response.status(Status.OK).header(HttpHeaders.CONTENT_TYPE, JSON_UTF8) .entity(classesCalendarJson(person)).build(); } }
From source file:net.sourceforge.fenixedu.webServices.jersey.api.FenixAPIv1.java
/** * calendar of all lessons of students and teachers * * @summary Classes calendar/*from w ww . j a va 2s . c om*/ * @param format * ("calendar" or "json") * @return If format is "calendar", returns iCal format. If not returns the * following json. * @servicetag SCHEDULE_SCOPE */ @FenixAPIScope(SCHEDULE_SCOPE) @GET @Path("person/calendar/classes") public Response calendarClasses(@QueryParam("format") String format) { validateFormat(format); Person person = getPerson(); if ("calendar".equals(format)) { String classesCalendarICal = classesCalendarICal(person); return Response.ok(classesCalendarICal, "text/calendar; charset=UTF-8").build(); } else { return Response.status(Status.OK).header(HttpHeaders.CONTENT_TYPE, JSON_UTF8) .entity(classesCalendarJson(person)).build(); } }
From source file:pt.ist.fenixedu.integration.api.FenixAPIv1.java
/** * calendar of all written evaluations (tests and exams). Available for * students and teachers./*from w ww .j av a 2 s .co m*/ * * @param format * ("calendar" or "json") * @return If format is "calendar", returns iCal format. If not returns the * following json. */ @OAuthEndpoint(SCHEDULE_SCOPE) @GET @Path("person/calendar/evaluations") public Response calendarEvaluation(@QueryParam("format") String format) { validateFormat(format); final Person person = getPerson(); if (!new ActiveStudentsGroup().isMember(person.getUser())) { return Response.status(Status.OK).header(HttpHeaders.CONTENT_TYPE, JSON_UTF8).entity("{}").build(); } if ("calendar".equals(format)) { String evaluationCalendarICal = evaluationCalendarICal(person); return Response.ok(evaluationCalendarICal, "text/calendar;charset=UTF-8").build(); } else { return Response.status(Status.OK).header(HttpHeaders.CONTENT_TYPE, JSON_UTF8) .entity(evaluationCalendarJson(person)).build(); } }
From source file:pt.ist.fenixedu.integration.api.FenixAPIv1.java
/** * calendar of all lessons of students and teachers * /* w w w . ja va 2 s . c o m*/ * @param format * ("calendar" or "json") * @return If format is "calendar", returns iCal format. If not returns the * following json. */ @OAuthEndpoint(SCHEDULE_SCOPE) @GET @Path("person/calendar/classes") public Response calendarClasses(@QueryParam("format") String format) { validateFormat(format); Person person = getPerson(); if ("calendar".equals(format)) { String classesCalendarICal = classesCalendarICal(person); return Response.ok(classesCalendarICal, "text/calendar; charset=UTF-8").build(); } else { return Response.status(Status.OK).header(HttpHeaders.CONTENT_TYPE, JSON_UTF8) .entity(classesCalendarJson(person)).build(); } }
From source file:org.gaul.s3proxy.S3ProxyHandler.java
private void handleCopyBlob(HttpServletRequest request, HttpServletResponse response, BlobStore blobStore, String destContainerName, String destBlobName) throws IOException, S3Exception { String copySourceHeader = request.getHeader("x-amz-copy-source"); copySourceHeader = URLDecoder.decode(copySourceHeader, "UTF-8"); if (copySourceHeader.startsWith("/")) { // Some clients like boto do not include the leading slash copySourceHeader = copySourceHeader.substring(1); }/*from www . j a v a2 s . c o m*/ String[] path = copySourceHeader.split("/", 2); if (path.length != 2) { throw new S3Exception(S3ErrorCode.INVALID_REQUEST); } String sourceContainerName = path[0]; String sourceBlobName = path[1]; boolean replaceMetadata = "REPLACE".equalsIgnoreCase(request.getHeader("x-amz-metadata-directive")); if (sourceContainerName.equals(destContainerName) && sourceBlobName.equals(destBlobName) && !replaceMetadata) { throw new S3Exception(S3ErrorCode.INVALID_REQUEST); } CopyOptions.Builder options = CopyOptions.builder(); if (replaceMetadata) { ContentMetadataBuilder contentMetadata = ContentMetadataBuilder.create(); ImmutableMap.Builder<String, String> userMetadata = ImmutableMap.builder(); for (String headerName : Collections.list(request.getHeaderNames())) { String headerValue = Strings.nullToEmpty(request.getHeader(headerName)); if (headerName.equalsIgnoreCase(HttpHeaders.CONTENT_DISPOSITION)) { contentMetadata.contentDisposition(headerValue); } else if (headerName.equalsIgnoreCase(HttpHeaders.CONTENT_ENCODING)) { contentMetadata.contentEncoding(headerValue); } else if (headerName.equalsIgnoreCase(HttpHeaders.CONTENT_LANGUAGE)) { contentMetadata.contentLanguage(headerValue); } else if (headerName.equalsIgnoreCase(HttpHeaders.CONTENT_TYPE)) { contentMetadata.contentType(headerValue); } else if (headerName.toLowerCase().startsWith(USER_METADATA_PREFIX)) { userMetadata.put(headerName.substring(USER_METADATA_PREFIX.length()), headerValue); } // TODO: Expires } options.contentMetadata(contentMetadata.build()); options.userMetadata(userMetadata.build()); } String eTag; try { eTag = blobStore.copyBlob(sourceContainerName, sourceBlobName, destContainerName, destBlobName, options.build()); } catch (KeyNotFoundException knfe) { throw new S3Exception(S3ErrorCode.NO_SUCH_KEY, knfe); } // TODO: jclouds should include this in CopyOptions String cannedAcl = request.getHeader("x-amz-acl"); if (cannedAcl != null && !cannedAcl.equalsIgnoreCase("private")) { handleSetBlobAcl(request, response, blobStore, destContainerName, destBlobName); } BlobMetadata blobMetadata = blobStore.blobMetadata(destContainerName, destBlobName); try (Writer writer = response.getWriter()) { XMLStreamWriter xml = xmlOutputFactory.createXMLStreamWriter(writer); xml.writeStartDocument(); xml.writeStartElement("CopyObjectResult"); xml.writeDefaultNamespace(AWS_XMLNS); writeSimpleElement(xml, "LastModified", blobStore.getContext().utils().date().iso8601DateFormat(blobMetadata.getLastModified())); writeSimpleElement(xml, "ETag", "\"" + eTag + "\""); xml.writeEndElement(); xml.flush(); } catch (XMLStreamException xse) { throw new IOException(xse); } }