Search in sources :

Example 1 with TemplateCall

use of com.peterphi.std.guice.web.rest.templating.TemplateCall in project stdlib by petergeneric.

the class JwtCreationRestServiceImpl method getIndex.

@Override
public String getIndex(String message) {
    final TemplateCall template = templater.template(PREFIX + "jwt_index.html");
    template.set("message", message);
    return template.process();
}
Also used : TemplateCall(com.peterphi.std.guice.web.rest.templating.TemplateCall)

Example 2 with TemplateCall

use of com.peterphi.std.guice.web.rest.templating.TemplateCall in project stdlib by petergeneric.

the class GuiceRestLoggingServiceImpl method getIndex.

@Override
public String getIndex() {
    TemplateCall call = templater.template(PREFIX + "logging.html");
    call.set("log4jProperties", getLog4jPropertiesAsString());
    return call.process();
}
Also used : TemplateCall(com.peterphi.std.guice.web.rest.templating.TemplateCall)

Example 3 with TemplateCall

use of com.peterphi.std.guice.web.rest.templating.TemplateCall in project stdlib by petergeneric.

the class RestServiceListImpl method getServiceDescription.

@Override
public String getServiceDescription(final int serviceId, final HttpHeaders headers, final UriInfo uriInfo) throws Exception {
    final TemplateCall template = templater.template(PREFIX + "service_describe.html");
    template.set("services", services);
    template.set("containerUrl", containerEndpoint.toString());
    template.set("restUrl", restEndpoint.toString());
    template.set("schemaGenerator", schemaGenerator);
    template.set("service", services.get(serviceId));
    return template.process();
}
Also used : TemplateCall(com.peterphi.std.guice.web.rest.templating.TemplateCall)

Example 4 with TemplateCall

use of com.peterphi.std.guice.web.rest.templating.TemplateCall in project stdlib by petergeneric.

the class ServiceManagerResourceUIServiceImpl method getResource.

/**
 * N.B. transaction may be read-write because this read operation may result in reading a new template (or discovering an
 * update was made to the template)
 *
 * @param id
 *
 * @return
 */
@Override
@Transactional
public String getResource(String id) {
    final TemplateCall call = templater.template("resource_template");
    final ResourceTemplateEntity entity = resourceProvisionService.getOrCreateTemplate(id);
    if (entity == null)
        throw new RestException(404, "No such resource with id: " + id);
    call.set("entity", entity);
    call.set("nonce", nonceStore.getValue());
    return call.process();
}
Also used : RestException(com.peterphi.std.guice.restclient.exception.RestException) ResourceTemplateEntity(com.peterphi.servicemanager.service.db.entity.ResourceTemplateEntity) TemplateCall(com.peterphi.std.guice.web.rest.templating.TemplateCall) Transactional(com.peterphi.std.guice.database.annotation.Transactional)

Example 5 with TemplateCall

use of com.peterphi.std.guice.web.rest.templating.TemplateCall in project stdlib by petergeneric.

the class RulesUIServiceImpl method getIndex.

@Override
public String getIndex() {
    final TemplateCall call = templater.template("rules");
    call.set("daemon", rulesDaemon);
    boolean inputsValid;
    Rules rules = null;
    try {
        rules = rulesProvider.get();
        Map<String, Object> varMap = rulesEngine.prepare(rules);
        call.set("varMap", varMap);
        inputsValid = true;
    } catch (Exception e) {
        inputsValid = false;
        call.set("inputsError", e.getMessage());
    }
    boolean expressionsValid;
    try {
        if (rules != null) {
            Map<String, String> validationResults = rulesEngine.validateSyntax(rules);
            if (validationResults.size() > 0) {
                expressionsValid = false;
                call.set("expressionsErrorMap", validationResults);
                call.set("expressionsError", "Parse erorrs");
            } else {
                expressionsValid = true;
            }
        } else {
            call.set("expressionsError", "Rules not loaded!");
            expressionsValid = false;
        }
    } catch (Exception e) {
        expressionsValid = false;
        call.set("expressionsError", e.getMessage());
    }
    call.set("inputsValid", inputsValid);
    call.set("expressionsValid", expressionsValid);
    return call.process();
}
Also used : Rules(com.peterphi.rules.types.Rules) TemplateCall(com.peterphi.std.guice.web.rest.templating.TemplateCall)

Aggregations

TemplateCall (com.peterphi.std.guice.web.rest.templating.TemplateCall)28 Transactional (com.peterphi.std.guice.database.annotation.Transactional)9 AuthConstraint (com.peterphi.std.guice.common.auth.annotations.AuthConstraint)6 WebQuery (com.peterphi.std.guice.restclient.jaxb.webquery.WebQuery)4 OAuthServiceEntity (com.peterphi.usermanager.db.entity.OAuthServiceEntity)3 RoleEntity (com.peterphi.usermanager.db.entity.RoleEntity)2 UserEntity (com.peterphi.usermanager.db.entity.UserEntity)2 AuthenticationFailureException (com.peterphi.usermanager.guice.authentication.AuthenticationFailureException)2 Function (java.util.function.Function)2 Response (javax.ws.rs.core.Response)2 Counting (com.codahale.metrics.Counting)1 Metered (com.codahale.metrics.Metered)1 Sampling (com.codahale.metrics.Sampling)1 Inject (com.google.inject.Inject)1 Named (com.google.inject.name.Named)1 Rules (com.peterphi.rules.types.Rules)1 ResourceTemplateEntity (com.peterphi.servicemanager.service.db.entity.ResourceTemplateEntity)1 LogSubscriber (com.peterphi.servicemanager.service.logging.hub.LogSubscriber)1 Doc (com.peterphi.std.annotation.Doc)1 GuiceProperties (com.peterphi.std.guice.apploader.GuiceProperties)1