Java Code Examples for com.sun.jersey.api.view.Viewable

The following are top voted examples for showing how to use com.sun.jersey.api.view.Viewable. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to product more good examples.

Example 1
Project: OpenClinica   File: ODMClinicaDataResource.java View source code 6 votes vote down vote up
/**
 * @api {get} /rest/clinicaldata/html/print/:study/:subject/:event/:form Retrieve case report forms - HTML
 * @apiVersion 3.8.0
 * @apiName getPrintCRFController
 * @apiGroup Subject
 * @apiPermission user
 *
 * @apiDescription Annotated case report forms in printable HTML format. Use asterisks in place of OIDs as wildcards
 *
 * @apiParam {String} study Study or Site OID.
 * @apiParam {String} subject Subject Key or ID.
 * @apiParam {String} event Study Event Definition OID. Use '*' for all.
 * @apiParam {String} form Case Report Form Version OID. Use '*' for all.
 *
 *
 * @apiError NoAccessRight Only authenticated users can access the data.
 * @apiError NotFound   The resource was not found.
 *
 * @apiErrorExample Response (example):
 *     HTTP/1.1 401 Not Authenticated
 *     {
 *       "error": "NoAccessRight"
 *     }
 */
@GET
@Path("/html/print/{studyOID}/{studySubjectIdentifier}/{eventOID}/{formVersionOID}")
public Viewable getPrintCRFController(@Context HttpServletRequest request,
		@Context HttpServletResponse response,
		@PathParam("studyOID") String studyOID,
		@PathParam("studySubjectIdentifier") String studySubjectIdentifier,
		@PathParam("eventOID") String eventOID,
		@PathParam("formVersionOID") String formVersionOID,	@DefaultValue("n") @QueryParam("includeDNs") String includeDns,
		@DefaultValue("n") @QueryParam("includeAudits") String includeAudits)
		throws Exception {
	request.setCharacterEncoding("UTF-8");
	request.setAttribute("studyOID", studyOID);
	request.setAttribute("studySubjectOID", getStudySubjectOID(studySubjectIdentifier,studyOID));
	request.setAttribute("eventOID", eventOID);
	request.setAttribute("formVersionOID", formVersionOID);
	request.setAttribute("includeAudits", includeAudits);
	request.setAttribute("includeDNs", includeDns);
	return new Viewable("/WEB-INF/jsp/printcrf.jsp", null);
}
 
Example 2
Project: JerseyTest   File: TemplateContext.java View source code 6 votes vote down vote up
/**
 * Resolve a [email protected] Viewable}.
 * <p>
 * If the template name of the viewable is not absolute then the resolving
 * class of the viewable is utilized to resolve the relative template name
 * into an absolute template name. 
 * 
 * If the resolving class is not set (a null value) then the class of the
 * model is utilized as the resolving class.
 *
 * If the model is not set (a null value) then a [email protected] TemplateContextException}
 * is thrown.
 *
 * @param v the viewable
 * @return the resolved viewable
 * @throws TemplateContextException if the viewable cannot be resolved.
 */
ResolvedViewable resolveViewable(Viewable v) throws TemplateContextException;
 
Example 3
Project: uBike   File: UbikeGroupResource.java View source code 6 votes vote down vote up
/**
 * Get method for retrieving an instance of UbikeGroup identified by id in XML format.
 *
 * @param id identifier for the entity
 * @return an instance of UbikeGroupConverter
 */
@GET
@Produces({MediaType.TEXT_HTML})
public Viewable getHTML(@QueryParam("expandLevel") @DefaultValue("1") int expandLevel) {

    UbikeGroup entity = getEntityWithMemberShips();
    BaseBean.setSessionAttribute("tmp_members", entity.getMemberShips());
    // Extracting entity statistics
    //extractStatistics(converter.getEntity());
    BaseBean.setSessionAttribute("client", entity);

    return new Viewable("/groupInfo.jsp", entity);
}
 
Example 4
Project: action-core   File: HdfsBrowser.java View source code 6 votes vote down vote up
/**
 * Build a Viewable to browse HDFS.
 *
 * @param path      path in HDFS to render (directory listing or file), defaults to /
 * @param raw       optional, whether to try to deserialize
 * @param recursive optional, whether to crawl all files under a directory
 * @return Viewable to render the jsp
 * @throws IOException HDFS crawling error
 */
@GET
@Path("/hdfs")
@Produces({"text/html", "text/plain"})
@Timed
public Viewable getListing(@QueryParam("path") String path,
                           @QueryParam("raw") final boolean raw,
                           @QueryParam("recursive") final boolean recursive) throws IOException
{
    log.debug(String.format("Got request for path=[%s], raw=[%s] and recursive=[%s]", path, raw, recursive));

    if (path == null) {
        path = "/";
    }

    if (hdfsReader.isDir(path) && !recursive) {
        return new Viewable("/rest/listing.jsp", hdfsReader.getListing(path));
    }
    else {
        if (raw) {
            return new Viewable("/rest/contentRaw.jsp", hdfsReader.getListing(path, raw, recursive));
        }
        else {
            return new Viewable("/rest/content.jsp", hdfsReader.getListing(path, raw, recursive));
        }
    }
}
 
Example 5
Project: jsonhome   File: JsonHomeResource.java View source code 6 votes vote down vote up
@GET
@Produces(MediaType.TEXT_HTML)
public Response getAsTextHtmlHome() {
    final Map<String,Object> resources = new HashMap<String, Object>();
    resources.put("resources", jsonHomeSource.getJsonHome().getResources().values());
    final Viewable viewable = new Viewable("/jsonhome/resources", resources);
    return addCacheControlHeaders(Response.ok(viewable), maxAge);
}
 
Example 6
Project: hwi   File: VelocityViewProcessor.java View source code 6 votes vote down vote up
@Override
public void writeTo(String resolvedPath, Viewable viewable, OutputStream out)
		throws IOException {
	
	// Commit the status and headers to the HttpServletResponse
	out.flush();

	v.render(resolvedPath, request.get(), new OutputStreamWriter(out));
}
 
Example 7
Project: action-core-0.1.x   File: HdfsBrowser.java View source code 6 votes vote down vote up
/**
 * Build a Viewable to browse HDFS.
 *
 * @param path      path in HDFS to render (directory listing or file), defaults to /
 * @param range     optional, bucket of lines to read (e.g. 200-250) (used in the content.jsp only)
 * @param raw       optional, whether to try to deserialize
 * @param recursive optional, whether to crawl all files under a directory
 * @return Viewable to render the jsp
 * @throws IOException HDFS crawling error
 */
@GET
@Path("/hdfs")
@Produces({"text/html", "text/plain"})
public Viewable getListing(
    @QueryParam("path") String path,
    @QueryParam("range") String range,
    @QueryParam("raw") boolean raw,
    @QueryParam("recursive") boolean recursive
) throws IOException
{
    log.debug(String.format("Got request for path=[%s], raw=[%s] and recursive=[%s]", path, raw, recursive));

    if (path == null) {
        path = "/";
    }

    if (hdfsReader.isDir(path) && !recursive) {
        return new Viewable("/rest/listing.jsp", hdfsReader.getListing(path));
    }
    else {
        if (raw) {
            return new Viewable("/rest/contentRaw.jsp", hdfsReader.getListing(path, raw, recursive));
        }
        else {
            return new Viewable("/rest/content.jsp", hdfsReader.getListing(path, raw, recursive));
        }
    }
}
 
Example 8
Project: activityinfo   File: ConfirmInviteControllerTest.java View source code 6 votes vote down vote up
@Test
public void requestWithValidKeyShouldGetView() throws Exception {

    Viewable response = resource.getPage(RestMockUtils
            .mockUriInfo("http://www.activityinfo.org/confirm?xyz123"));

    assertThat(response.getModel(), instanceOf(ConfirmInvitePageModel.class));

}
 
Example 9
Project: gyrex-jaxrs-application   File: TemplateContext.java View source code 6 votes vote down vote up
/**
 * Resolve a [email protected] Viewable}.
 * <p>
 * If the template name of the viewable is not absolute then the resolving
 * class of the viewable is utilized to resolve the relative template name
 * into an absolute template name. 
 * 
 * If the resolving class is not set (a null value) then the class of the
 * model is utilized as the resolving class.
 *
 * If the model is not set (a null value) then a [email protected] TemplateContextException}
 * is thrown.
 *
 * @param v the viewable
 * @return the resolved viewable
 * @throws TemplateContextException if the viewable cannot be resolved.
 */
ResolvedViewable resolveViewable(Viewable v) throws TemplateContextException;
 
Example 10
Project: anudc   File: PambuSearchResource.java View source code 6 votes vote down vote up
/**
 * doGetPAMBUHTML
 *
 * Returns a html response for a get for pambu
 *
 * <pre>
 * Version	Date		Developer				Description
 * 0.1		08/06/2012	Genevieve Turner(GT)	Initial
 * 0.3		10/08/2012	Genevieve Turner (GT)	Updated to provide more get options.
 * </pre>
 * 
 * @return The html response
 */
@GET
@Path("/search")
@Produces(MediaType.TEXT_HTML)
public Response doGetPAMBUHTML(@Context HttpServletRequest request) {
	Response response = null;

	if (Util.isNotEmpty(request.getParameter("submit"))) {
		response = doPostPAMBUHTML(request);
	}
	else if (Util.isNotEmpty(request.getParameter("browseAll"))) {
		response = doPostPAMBUHTML(request);
	}
	else {
		response = Response.ok(new Viewable("/pambu/pambusearch.jsp")).build();
	}
	
	return response;
}
 
Example 11
Project: Tenuki   File: VelocityViewProcessor.java View source code 6 votes vote down vote up
@Override
public void writeTo(Template t, Viewable viewable, OutputStream out)
		throws IOException {
	OutputStreamWriter writer = new OutputStreamWriter(out);
	t.merge((org.apache.velocity.context.Context) viewable.getModel(),
			writer);
	writer.close();
}
 
Example 12
Project: Nicobar   File: ScriptManagerHomeResource.java View source code 6 votes vote down vote up
@GET
@Produces(MediaType.TEXT_HTML)
public Viewable showIndex()
{
    LOG.info("Script manager home page requested");
    Map<String, Object> model = new HashMap<String, Object>();
    return new Viewable( "/scriptmanager/home.ftl", model );
}
 
Example 13
Project: jersey-old   File: TemplateContext.java View source code 6 votes vote down vote up
/**
 * Resolve a [email protected] Viewable}.
 * <p>
 * If the template name of the viewable is not absolute then the resolving
 * class of the viewable is utilized to resolve the relative template name
 * into an absolute template name. 
 * 
 * If the resolving class is not set (a null value) then the class of the
 * model is utilized as the resolving class.
 *
 * If the model is not set (a null value) then a [email protected] TemplateContextException}
 * is thrown.
 *
 * @param v the viewable
 * @return the resolved viewable
 * @throws TemplateContextException if the viewable cannot be resolved.
 */
ResolvedViewable resolveViewable(Viewable v) throws TemplateContextException;
 
Example 14
Project: RemoteroidWeb   File: AdminREST.java View source code 6 votes vote down vote up
@GET
@Path("/init")
public Viewable createApiEntity(){
	
	// Check entity exists or not
	Query q = new Query(GCM._NAME);
	List<Entity> result = query(q);
	
	// Do only there are no entity for Google Cloud Messaging API Key
	if(result.size()==0){
		// API key entry not exists. Need to create new one.
		Entity entity = new Entity(GCM._NAME, getRemoteroidKey(GCM._NAME));
		
		// NOTE : You cannot change entity's value on localhost server.
		// If you intend to test GCM on your localhost, please replace API_KEY_PLACEHOLDER into your own
		// API key.
		entity.setProperty(GCM.API_KEY, "API_KEY_PLACEHOLDER");
		
		// Put api key entity to datastore
		DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
		datastore.put(entity);
		
		log.info("Created API key entity.");
	}
	
	return new Viewable("/configuration_done.html");
}
 
Example 15
Project: karyon   File: AdminPageResource.java View source code 6 votes vote down vote up
@GET()
public Viewable showIndex() {
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("ajax_base", adminContainerConfig.ajaxDataResourceContext());
    model.put("template_base", adminContainerConfig.templateResourceContext());

    if (adminPageRegistry != null) {
        final Collection<AdminPageInfo> adminPages = adminPageRegistry.getAllPages();
        model.put("adminPages", adminPages);
    }

    return new Viewable("/webadmin/home.ftl", model);
}
 
Example 16
Project: tme   File: GraphManager.java View source code 6 votes vote down vote up
@GET
@Produces(MediaType.TEXT_HTML)
public Response getGraphIndex() throws CODIException {
    CacheControl cc = new CacheControl();
    cc.setMustRevalidate(true);
    cc.setNoCache(true);
    cc.setNoStore(true);
    return Response.status(Status.OK).cacheControl(cc).entity(new Viewable("/graph/index.jsp", getGraphList())).build();
}
 
Example 17
Project: koshinuke.java   File: UserService.java View source code 6 votes vote down vote up
@GET
public Viewable login(@Context HttpServletRequest req,
		@Context HttpServletResponse res) {
	if (AuthenticationFilterFactory.isLoggedIn(req)) {
		ServletUtil.redirect(res, "/");
		return null;
	}
	return AuthModel.of("/login", req.getSession());
}
 
Example 18
Project: segrada   File: MainController.java View source code 6 votes vote down vote up
@GET
@Produces(MediaType.TEXT_HTML)
public Viewable index() {
	// get version update variable
	String versionUpdate = service.getValue("versionUpdate");
	if (versionUpdate == null) versionUpdate = "";

	// test application if login is allowed
	String requireLogin = applicationSettings.getSetting("requireLogin");
	boolean showLogout = requireLogin != null && !requireLogin.isEmpty() && requireLogin.equalsIgnoreCase("true");

	// create model map
	Map<String, Object> model = new HashMap<>();
	model.put("version", SegradaUpdateChecker.currentVersion);
	model.put("versionUpdate", versionUpdate);
	model.put("showLogout", showLogout);

	return new Viewable("home", model);
}
 
Example 19
Project: Troia-Server   File: ConfigEntry.java View source code 6 votes vote down vote up
@GET
@Produces("text/html")
public Response getConfig() {
	Map<String, Object> model = new HashMap<String, Object>();
	Properties properties = (Properties)scontext.getAttribute(Constants.PROPERTIES);
	Boolean freezed = (Boolean) scontext.getAttribute(Constants.IS_FREEZED);
	List<NameValue> items = new ArrayList<NameValue>();
	for (String s : new ArrayList<String>(new TreeSet<String>(properties.stringPropertyNames()))){
		if (s.equals(Constants.JOBS_STORAGE))
			continue;
		if (freezed && (s.startsWith("DB") || s.endsWith("PATH")))
			continue;
		items.add(new NameValue(s, properties.get(s)));
	}
	model.put(Constants.IS_FREEZED, freezed);
	model.put("items", items);
	model.put(Constants.IS_INITIALIZED, scontext.getAttribute(Constants.IS_INITIALIZED));
	model.put("storages", new String[] {"MEMORY_FULL", "MEMORY_KV", "MEMORY_KV_JSON", "MEMORY_KV_SIMPLE", "DB_FULL", "DB_KV_JSON", "DB_KV_SIMPLE"});
	model.put(Constants.JOBS_STORAGE, ((Properties) scontext.getAttribute(Constants.PROPERTIES)).getProperty(Constants.JOBS_STORAGE));
	return Response.ok(new Viewable("/config", model)).build();
}
 
Example 20
Project: goodwill   File: Registrar.java View source code 6 votes vote down vote up
@GET
@Produces(MediaType.TEXT_HTML)
public Viewable getAll() throws IOException
{
    ThriftRegistrar registrar = new ThriftRegistrar(store.toJSON());
    registrar.setActionCoreURL(config.getActionCoreURL());

    return new Viewable("/registrar/type.jsp", registrar);
}