下面列出了javax.ws.rs.core.MediaType#TEXT_HTML 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Updates the attributes of the podcast received via JSON for the given @param id
*
* If the podcast does not exist yet in the database (verified by <strong>id</strong>) then
* the application will try to create a new podcast resource in the db
*
* @param id
* @param podcast
* @return
*/
@PUT @Path("{id}")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.TEXT_HTML})
@Transactional
public Response updatePodcastById(@PathParam("id") Long id, Podcast podcast) {
if(podcast.getId() == null) podcast.setId(id);
String message;
int status;
if(podcastWasUpdated(podcast)){
status = 200; //OK
message = "Podcast has been updated";
} else if(podcastCanBeCreated(podcast)){
podcastDao.createPodcast(podcast);
status = 201; //Created
message = "The podcast you provided has been added to the database";
} else {
status = 406; //Not acceptable
message = "The information you provided is not sufficient to perform either an UPDATE or "
+ " an INSERTION of the new podcast resource <br/>"
+ " If you want to UPDATE please make sure you provide an existent <strong>id</strong> <br/>"
+ " If you want to insert a new podcast please provide at least a <strong>title</strong> and the <strong>feed</strong> for the podcast resource";
}
return Response.status(status).entity(message).build();
}
@GET
@Path(WebServerConstants.FORM_LOGIN_RESOURCE_PATH)
@Produces(MediaType.TEXT_HTML)
public Viewable getLoginPage(@Context HttpServletRequest request, @Context HttpServletResponse response,
@Context SecurityContext sc, @Context UriInfo uriInfo,
@QueryParam(WebServerConstants.REDIRECT_QUERY_PARM) String redirect) throws Exception {
if (AuthDynamicFeature.isUserLoggedIn(sc)) {
// if the user is already login, forward the request to homepage.
request.getRequestDispatcher(WebServerConstants.WEBSERVER_ROOT_PATH).forward(request, response);
return null;
}
updateSessionRedirectInfo(redirect, request);
return ViewableWithPermissions.createLoginPage(null);
}
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.TEXT_HTML)
@Path("/{id}/reset")
public Client resetClient(@PathParam("id") String id,
@FormParam("client_csrfToken") String csrfToken) {
// CSRF
checkCSRFToken(csrfToken);
checkSecurityContext();
Client c = getRegisteredClient(id);
if (c == null) {
throw new InvalidRegistrationException("The client id is invalid");
}
if (c.isConfidential()) {
c.setClientSecret(generateClientSecret());
}
clientProvider.setClient(c);
return c;
}
@PUT
@Path("/{name}")
@Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_HTML})
public Object startJob(@PathParam("name") String name) throws AppException, SchedulerException, IOException {
ScheduledJob job = MainScheduler.getJob(name);
if (job == null) {
throw new AppException(404, "Job "+name+" not found");
}
if (job.startTime != null) {
throw new IllegalArgumentException("Job "+name+" already started");
}
PostOffice.getInstance().broadcast(SCHEDULER_SERVICE, new Kv(ORIGIN, Platform.getInstance().getOrigin()),
new Kv(TYPE, START), new Kv(JOB_ID, name));
MainScheduler.startJob(job.name);
Map<String, Object> result = new HashMap<>();
result.put("type", "start");
result.put("message", "Job "+name+" started");
result.put("time", new Date());
return result;
}
@GET
@Path("/Document.action")
@Produces(MediaType.TEXT_HTML)
@Template(name = "/document_form")
public Map<String, Object> documentForm() {
Map<String, Object> map = new HashMap<>();
return map;
}
@GET
@Path("/echo")
@Produces(MediaType.TEXT_HTML)
public String echo() {
System.out.println("HELLO");
return "Hello world!";
}
@GET
@Path("/test/html/{id}")
@Produces({MediaType.TEXT_HTML})
public Mono<String> testHtml(@PathParam("id") Long id, ModelMap modelMap) {
modelMap.addAttribute("id", id);
return Mono.just("test");
}
/**
* Adds a new resource (podcast) from the given json format (at least title
* and feed elements are required at the DB level)
*
* @param podcast
* @return
*/
@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.TEXT_HTML })
@Transactional
public Response createPodcast(Podcast podcast) {
podcastDao.createPodcast(podcast);
return Response.status(201)
.entity("A new podcast/resource has been created").build();
}
@GET
@Path("/")
@Produces(MediaType.TEXT_HTML)
public AnalysisView result(@Session HttpSession session) {
try {
String accountId = NiPingAuthFilter.getAccountId(session);
return new AnalysisView(SUCCESS, taskService.listTasks(accountId));
} catch (NiPingException e) {
return new AnalysisView(e, null);
}
}
@GET
@Produces(MediaType.TEXT_HTML)
public String getHTML() {
if(this.cc != null) {
request.setAttribute("controller", this.cc);
return this.callViewer("ComponentViewer");
}
return null;
}
@GET
@Path("coursefolder/{path:.*}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_HTML, MediaType.APPLICATION_OCTET_STREAM })
public Response getCourseFiles(@PathParam("courseId") final Long courseId, @PathParam("path") final List<PathSegment> path, @Context final UriInfo uriInfo,
@Context final HttpServletRequest httpRequest, @Context final Request request) {
return getFiles(courseId, path, FolderType.COURSE_FOLDER, uriInfo, httpRequest, request);
}
@GET
@Path( "/payment/process/{merchantId}/{payId}/{dttm}/{signature}" )
@Produces(MediaType.TEXT_HTML)
Response paymentProcess(@PathParam("merchantId") String merchantId,
@PathParam("payId") String payId,
@PathParam("dttm") String dttm,
@PathParam("signature") String signature
);
@DELETE
@Path("/")
@Produces(MediaType.TEXT_HTML)
@AuditLog(title = "delete")
public String query() {
return "[delete]";
}
@GET
@Path("sharedfolder/{path:.*}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_HTML, MediaType.APPLICATION_OCTET_STREAM })
public Response getSharedFiles(@PathParam("courseId") final Long courseId, @PathParam("path") final List<PathSegment> path, @Context final UriInfo uriInfo,
@Context final HttpServletRequest httpRequest, @Context final Request request) {
return getFiles(courseId, path, FolderType.COURSE_FOLDER, uriInfo, httpRequest, request);
}
@GET
@Produces(MediaType.TEXT_HTML)
public String Test(){
CommonTools commonTools = new CommonTools();
Boolean isConnectionOK = commonTools.CheckIfDBConnectionIsOK();
String connectionStatus = "Database connected!";
if(!isConnectionOK)
connectionStatus = "Error creating database connection.";
return "API[" + commonTools.GetVersionOfSQLiteSyncCOM() + "] SQLite-Sync.COM is working correctly! " + connectionStatus;
}
@GET
@Path( "/payment/process/{merchantId}/{payId}/{dttm}/{signature}" )
@Produces(MediaType.TEXT_HTML)
Response paymentProcess(@PathParam("merchantId") String merchantId,
@PathParam("payId") String payId,
@PathParam("dttm") String dttm,
@PathParam("signature") String signature
);
@GET
@Path("repositoryActionWithNullResponse")
@Produces(MediaType.TEXT_HTML)
String repositoryActionWithNullResponse();
@GET
@Produces(MediaType.TEXT_HTML)
public InputStream getIndexPage() {
return getClass().getClassLoader().getResourceAsStream("static/index.html");
}
@GET
@Path("/")
@Produces(MediaType.TEXT_HTML)
public InputStream getStarTreeHtml() {
return getClass().getClassLoader().getResourceAsStream("star-tree.html");
}
@GET
@Path("/")
@Produces(MediaType.TEXT_HTML)
public LoginView welcome() {
return new LoginView(SUCCESS, null);
}