本文整理汇总了Java中org.glassfish.jersey.server.mvc.Viewable类的典型用法代码示例。如果您正苦于以下问题:Java Viewable类的具体用法?Java Viewable怎么用?Java Viewable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Viewable类属于org.glassfish.jersey.server.mvc包,在下文中一共展示了Viewable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: updateSystemOption
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
@POST
@Path("/option/{optionName}")
@Consumes("application/x-www-form-urlencoded")
@Produces(MediaType.TEXT_HTML)
public Viewable updateSystemOption(@FormParam("name") String name, @FormParam("value") String value,
@FormParam("kind") String kind) {
try {
work.getContext()
.getOptionManager()
.setOption(OptionValue.createOption(
OptionValue.Kind.valueOf(kind),
OptionValue.OptionType.SYSTEM,
name,
value));
} catch (Exception e) {
logger.debug("Could not update.", e);
}
return getSystemOptions();
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:20,代码来源:StatusResources.java
示例2: defaultPage
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
@GET
@Produces(MediaType.TEXT_HTML)
public Response defaultPage(@Context UriInfo ui) throws URISyntaxException {
/*
* This redirect is required due to change of "Jersey" version from "1.17" to "2.13".
* The "1.*" version of jersey has property "FEATURE_REDIRECT".
* For example, when making request "localhost:8888/context/dev", Jersey checks whether "FEATURE_REDIRECT" is set to "true" in ServletContainer and request does not end with '/'.
* If so, trailing slash is added and redirect is occurred to "localhost:8888/context/dev/"
*
* Jersey "2.*" does not contain property "FEATURE_REDIRECT".
* The code that made redirect in "1.*" jersey is commented out in ServletContainer.java:504
* Jersey "2.*" resolves request even if '/' was not present in the end.
* But all links in our *.jsp and *.html to *.js and *.css are relative. So without adding '/' in the end, files can not be opened.
* To solve it, we introduced this redirect
*/
if (!ui.getAbsolutePath().toString().endsWith("/")) {
return Response.temporaryRedirect(new URI(ui.getAbsolutePath().toString() + "/")).build();
} else {
return Response.ok(new Viewable("/index.jsp", new HashMap<String, Object>())).build();
}
}
开发者ID:Comcast,项目名称:redirector,代码行数:22,代码来源:RedirectorOfflineUI.java
示例3: writeTo
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
@Override
public void writeTo(String templateReference, Viewable viewable, MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders, OutputStream out) throws IOException {
// 获取 模板引擎
VelocityEngine velocityEngine = getVelocityEngine();
// 实例化一个VelocityContext
VelocityContext context = (VelocityContext) viewable.getModel();
Enumeration<String> enums = request.getParameterNames();
while (enums.hasMoreElements()) {
String key = enums.nextElement();
context.put(key, request.getParameter(key));
}
// 把request放进模板上下文里
context.put("request", request);
// 渲染并输出
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(out);
velocityEngine.mergeTemplate(templateReference, "utf8", context, outputStreamWriter);
outputStreamWriter.flush();
outputStreamWriter.close(); // 有必要关闭吗? 关闭了是否对jax-rs拦截器,servlet有影响,需要继续学习,参考jsp模板实现
}
开发者ID:xixifeng,项目名称:fastquery,代码行数:24,代码来源:VelocityTemplateProcessor.java
示例4: writeTo
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
@Override
public void writeTo(final Template template, final Viewable viewable, final MediaType mediaType,
final MultivaluedMap<String, Object> httpHeaders, final OutputStream out) throws IOException {
try {
Object model = viewable.getModel();
if (!(model instanceof Map)) {
model = new HashMap<String, Object>() {{
put("model", viewable.getModel());
}};
}
Charset encoding = setContentType(mediaType, httpHeaders);
template.process(model, new OutputStreamWriter(out, encoding));
} catch (TemplateException te) {
throw new ContainerException(te);
}
}
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:18,代码来源:FreemarkerViewProcessor.java
示例5: updateSystemOption
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
@SuppressWarnings("resource")
@POST
@Path("option/{optionName}")
@RolesAllowed(DrillUserPrincipal.ADMIN_ROLE)
@Consumes("application/x-www-form-urlencoded")
@Produces(MediaType.TEXT_HTML)
public Viewable updateSystemOption(@FormParam("name") String name,
@FormParam("value") String value,
@FormParam("kind") String kind) {
SystemOptionManager optionManager = work.getContext()
.getOptionManager();
try {
optionManager.setLocalOption(OptionValue.Kind.valueOf(kind), name, value);
} catch (Exception e) {
logger.debug("Could not update.", e);
}
if (optionManager.getOptionDefinition(name).getMetaData().isInternal()) {
return getSystemInternalOptions();
} else {
return getSystemPublicOptions();
}
}
开发者ID:axbaretto,项目名称:drill,代码行数:25,代码来源:StatusResources.java
示例6: submitQuery
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
@POST
@Path("/query")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.TEXT_HTML)
public Viewable submitQuery(@FormParam("query") String query,
@FormParam("queryType") String queryType) throws Exception {
try {
final String trimmedQueryString = CharMatcher.is(';').trimTrailingFrom(query.trim());
final QueryResult result = submitQueryJSON(new QueryWrapper(trimmedQueryString, queryType));
return ViewableWithPermissions.create(authEnabled.get(), "/rest/query/result.ftl", sc, new TabularResult(result));
} catch (Exception | Error e) {
logger.error("Query from Web UI Failed", e);
return ViewableWithPermissions.create(authEnabled.get(), "/rest/query/errorMessage.ftl", sc, e);
}
}
开发者ID:axbaretto,项目名称:drill,代码行数:17,代码来源:QueryResources.java
示例7: getLoginPage
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
@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);
}
开发者ID:axbaretto,项目名称:drill,代码行数:17,代码来源:LogInLogOutResources.java
示例8: getSpnegoLogin
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
@GET
@Path(WebServerConstants.SPENGO_LOGIN_RESOURCE_PATH)
@Produces(MediaType.TEXT_HTML)
public Viewable getSpnegoLogin(@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)) {
request.getRequestDispatcher(WebServerConstants.WEBSERVER_ROOT_PATH).forward(request, response);
return null;
}
final String errorString = "Invalid SPNEGO credentials or SPNEGO is not configured";
final DrillConfig drillConfig = workManager.getContext().getConfig();
MainLoginPageModel model = new MainLoginPageModel(errorString, drillConfig);
return ViewableWithPermissions.createMainLoginPage(model);
}
开发者ID:axbaretto,项目名称:drill,代码行数:17,代码来源:LogInLogOutResources.java
示例9: doLogin
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
@GET
public Response doLogin(@PathParam("code") final String code) {
final Validation v = commonValidation(code);
if (v.getError() != null) {
return v.getError();
}
final LoginCode loginCode = v.getLoginCode();
final List<UserClientScope> userClientScopes = getUserClientScopes(loginCode);
if (!loginCode.getClient().isShowPromptNoScopes() &&
(userClientScopes.isEmpty() || userClientScopes.stream().allMatch(ucs -> ucs.getAcceptedScope() != null))) {
return acceptPermissions(code, "ok", new MultivaluedHashMap<>());
}
return Response.ok(
new Viewable("/templates/Permissions.ftl", new PermissionsModel(loginCode, userClientScopes))
).build();
}
开发者ID:moodysalem,项目名称:oauth-service,代码行数:21,代码来源:LoginResource.java
示例10: root
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
@GET
@Produces(MediaType.TEXT_HTML)
public Response root() {
LOG.info("Mainpage is requested");
List<DeploymentArtifactTopology> dats = new ArrayList<DeploymentArtifactTopology>();
try {
dats.addAll(new DATopologyDataSource().getDATs());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return Response.ok(
new Viewable("index", new MainResourceDAO(Configuration
.getInstance(), dats))).build();
}
开发者ID:nyuuyn,项目名称:XaaSPackager,代码行数:19,代码来源:MainResource.java
示例11: index
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
@GET
@Path("{userName}")
@Produces(MediaType.TEXT_HTML)
public Viewable index(@PathParam("userName") String userName, @QueryParam("tab") final String tab) {
Account account = userService.findAccount(userName);
MapViewable viewable = new MapViewable("/user/main.ftl").add("account", account).add("tab", tab);
if ("activity".equals(tab)) {
} else {
viewable.add("repositories", repositoryService.getByOwner(userName));
}
return viewable;
}
开发者ID:kamegu,项目名称:git-webapp,代码行数:17,代码来源:UserHtmlResource.java
示例12: writeTo
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
@Override
public void writeTo(JasperReport jr, Viewable vwbl, MediaType mt, MultivaluedMap<String, Object> mm, OutputStream outputStream) throws IOException {
JasperModel jasperModel = null;
try{
jasperModel = findJasperModel(vwbl);
}catch(JRException e){
throw new IllegalStateException("Cannot load jasper model", e);
}
try {
JasperPrint print = getJasperFactory().getJasperProxy().fillReport(jr,
jasperModel.getParameters(),
jasperModel.getListModels());
factory.getJasperProxy().exportReportToPDFStream(print, outputStream);
} catch (JRException jre) {
throw new IOException("Houve um problema ao gerar a ficha do snapshot/processo", jre);
}
}
开发者ID:marcosvpcortes,项目名称:jersey-mvc-jasper,代码行数:18,代码来源:JasperViewProcessor.java
示例13: writeViewable
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
/**
* <p>writeViewable.</p>
*
* @param viewable a {@link org.glassfish.jersey.server.mvc.Viewable} object.
* @param mediaType a {@link javax.ws.rs.core.MediaType} object.
* @param httpHeaders a {@link javax.ws.rs.core.MultivaluedMap} object.
* @param entityStream a {@link java.io.OutputStream} object.
* @throws java.io.IOException if any.
*/
protected void writeViewable(Viewable viewable,
MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
OutputStream entityStream) throws IOException {
MessageBodyWriter<Viewable> writer = workers.get().getMessageBodyWriter(Viewable.class, null,
new Annotation[]{}, null);
if (writer != null) {
writer.writeTo(viewable,
Viewable.class,
Viewable.class,
new Annotation[0],
mediaType,
httpHeaders,
entityStream);
}
}
开发者ID:icode,项目名称:ameba,代码行数:26,代码来源:ErrorPageGenerator.java
示例14: resolveRelativeViewable
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
/**
* Resolve given {@link Viewable viewable} with relative template name using {@link MediaType media type},
* {@code resolving class} and {@link TemplateProcessor template processor}.
*
* @param viewable viewable to be resolved.
* @param mediaType media type of te output.
* @param resolvingClass resolving class.
* @param templateProcessor template processor to be used.
* @return resolved viewable or {@code null} if the viewable cannot be resolved.
*/
private ResolvedViewable resolveRelativeViewable(final Viewable viewable,
final Class<?> resolvingClass,
final MediaType mediaType,
final TemplateProcessor templateProcessor) {
final String path = TemplateHelper.getTemplateName(viewable);
ResolvedViewable resolvedViewable = resolveRelativeViewable(Viewables.PROTECTED_DIR + "/" + path,
viewable, resolvingClass, mediaType, templateProcessor);
if (resolvedViewable == null) {
resolvedViewable = resolveRelativeViewable(path,
viewable, resolvingClass, mediaType, templateProcessor);
}
return resolvedViewable;
}
开发者ID:icode,项目名称:ameba,代码行数:27,代码来源:ResolvingViewableContext.java
示例15: writeTo
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void writeTo(T templateReference, Viewable viewable, MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders, OutputStream out) throws IOException {
MediaType m = (MediaType) httpHeaders.getFirst(HttpHeaders.CONTENT_TYPE);
if (m == null) m = mediaType;
setContentType(m, httpHeaders);
try {
writeTemplate(templateReference, viewable, mediaType, httpHeaders, out);
} catch (Exception e) {
RuntimeException r;
try {
r = createException(e, templateReference);
} catch (Exception ex) {
if (ex instanceof AmebaException) {
r = (RuntimeException) ex;
} else {
r = new TemplateException("create writeTo Exception error", e, -1);
}
}
throw r;
}
}
开发者ID:icode,项目名称:ameba,代码行数:24,代码来源:AbstractTemplateProcessor.java
示例16: resolve
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
/**
* Resolve given {@link org.glassfish.jersey.server.mvc.Viewable viewable}
* for a list of {@link javax.ws.rs.core.MediaType mediaTypes} and a {@link Class resolvingClass}
* using given {@link org.glassfish.jersey.server.mvc.spi.ViewableContext viewableContext}
* and a set of {@link org.glassfish.jersey.server.mvc.spi.TemplateProcessor templateProcessors}
*
* @param viewable viewable to be resolved.
* @param mediaTypes producible media types.
* @param resolvingClass non-null resolving class.
* @param viewableContext viewable context.
* @param templateProcessors collection of available template processors.
* @return resolved viewable or {@code null}, if the viewable cannot be resolved.
*/
private ResolvedViewable resolve(final Viewable viewable,
final List<MediaType> mediaTypes,
final Class<?> resolvingClass,
final ViewableContext viewableContext,
final Set<TemplateProcessor> templateProcessors) {
for (TemplateProcessor templateProcessor : templateProcessors) {
for (final MediaType mediaType : mediaTypes) {
final ResolvedViewable resolvedViewable = viewableContext
.resolveViewable(viewable, mediaType, resolvingClass, templateProcessor);
if (resolvedViewable != null) {
return resolvedViewable;
}
}
}
return null;
}
开发者ID:icode,项目名称:ameba,代码行数:32,代码来源:ViewableMessageBodyWriter.java
示例17: aroundWriteTo
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
@Override
public void aroundWriteTo(final WriterInterceptorContext context) throws IOException, WebApplicationException {
final Object entity = context.getEntity();
if (entity instanceof Viewable) {
User user = (User) securityContext.getUserPrincipal();
if ( ((Viewable) entity).getModel() instanceof ViewData) {
ViewData model = ((ViewData) ((Viewable) entity).getModel());
model.set("authUser", user);
String templateName = ((Viewable) entity).getTemplateName();
context.setEntity(new Viewable(templateName, model.getData()));
}
}
context.proceed();
}
开发者ID:autoschool,项目名称:splinter,代码行数:17,代码来源:UserDataInterceptor.java
示例18: writeTo
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
@Override
public void writeTo(ErrorMessage errorMessage,
Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
OutputStream entityStream) throws IOException, WebApplicationException {
ContainerRequestContext request = requestProvider.get();
int status = errorMessage.getStatus();
if (status >= 500 && application.getMode().isDev()) {
//开发模式,显示详细错误信息
Error error = new Error(
request,
status,
errorMessage.getThrowable(),
errorMessage);
Viewable viewable = Viewables.newDefaultViewable(DEFAULT_5XX_DEV_ERROR_PAGE, error);
writeViewable(viewable, mediaType, httpHeaders, entityStream);
} else {
super.writeTo(errorMessage, type, genericType, annotations, mediaType, httpHeaders, entityStream);
}
}
开发者ID:icode,项目名称:ameba-dev,代码行数:24,代码来源:DevErrorPageGenerator.java
示例19: handleViewable
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
public Viewable handleViewable(String template, Object model, String organizationName) {
OrganizationConfig orgConfig;
try {
if (!StringUtils.isBlank(organizationName)) {
orgConfig = management.getOrganizationConfigByName(organizationName);
} else {
orgConfig = management.getOrganizationConfigDefaultsOnly();
}
}
catch (Exception e) {
// fall back to non-org
if (logger.isInfoEnabled()) {
logger.info("handleViewable: unable to retrieve org config by org name: " + organizationName);
}
orgConfig = management.getOrganizationConfigDefaultsOnly();
}
return handleViewable(template, model, orgConfig);
}
开发者ID:apache,项目名称:usergrid,代码行数:19,代码来源:AbstractContextResource.java
示例20: showAuthorizeForm
import org.glassfish.jersey.server.mvc.Viewable; //导入依赖的package包/类
@GET
@Path( "authorize" )
@Produces( MediaType.TEXT_HTML )
public Viewable showAuthorizeForm( @Context UriInfo ui, @QueryParam( "response_type" ) String response_type,
@QueryParam( "client_id" ) String client_id,
@QueryParam( "redirect_uri" ) String redirect_uri,
@QueryParam( "scope" ) String scope, @QueryParam( "state" ) String state ) {
responseType = response_type;
clientId = client_id;
redirectUri = redirect_uri;
this.scope = scope;
this.state = state;
return handleViewable( "authorize_form", this );
}
开发者ID:apache,项目名称:usergrid,代码行数:17,代码来源:ManagementResource.java
注:本文中的org.glassfish.jersey.server.mvc.Viewable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论