Search in sources :

Example 81 with RolesAllowed

use of javax.annotation.security.RolesAllowed in project iaf by ibissource.

the class ShowConfiguration method fullReload.

@PUT
@RolesAllowed({ "IbisAdmin", "IbisTester" })
@Path("/configurations")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response fullReload(LinkedHashMap<String, Object> json) throws ApiException {
    // PUT defaults to no content
    Response.ResponseBuilder response = Response.status(Response.Status.NO_CONTENT);
    for (Entry<String, Object> entry : json.entrySet()) {
        String key = entry.getKey();
        Object value = entry.getValue();
        if (key.equalsIgnoreCase("action")) {
            if (value.equals("reload")) {
                getIbisManager().handleAction(IbisAction.FULLRELOAD, "", "", "", getUserPrincipalName(), true);
            }
            response.entity("{\"status\":\"ok\"}");
        }
    }
    return response.build();
}
Also used : Response(javax.ws.rs.core.Response) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 82 with RolesAllowed

use of javax.annotation.security.RolesAllowed in project iaf by ibissource.

the class ShowConfiguration method uploadConfiguration.

@POST
@RolesAllowed({ "IbisTester", "IbisAdmin", "IbisDataAdmin" })
@Path("configurations")
@Produces(MediaType.APPLICATION_JSON)
public Response uploadConfiguration(MultipartBody inputDataMap) throws ApiException {
    String fileName = null;
    if (inputDataMap == null) {
        throw new ApiException("Missing post parameters");
    }
    String datasource = resolveStringFromMap(inputDataMap, "datasource", JndiDataSourceFactory.GLOBAL_DEFAULT_DATASOURCE_NAME);
    boolean multipleConfigs = resolveTypeFromMap(inputDataMap, "multiple_configs", boolean.class, false);
    boolean activateConfig = resolveTypeFromMap(inputDataMap, "activate_config", boolean.class, true);
    boolean automaticReload = resolveTypeFromMap(inputDataMap, "automatic_reload", boolean.class, false);
    InputStream file = resolveTypeFromMap(inputDataMap, "file", InputStream.class, null);
    String user = resolveTypeFromMap(inputDataMap, "user", String.class, "");
    if (StringUtils.isEmpty(user)) {
        user = getUserPrincipalName();
    }
    fileName = inputDataMap.getAttachment("file").getContentDisposition().getParameter("filename");
    Map<String, String> result = new LinkedHashMap<String, String>();
    try {
        if (multipleConfigs) {
            try {
                result = ConfigurationUtils.processMultiConfigZipFile(getIbisContext(), datasource, activateConfig, automaticReload, file, user);
            } catch (IOException e) {
                throw new ApiException(e);
            }
        } else {
            String configName = ConfigurationUtils.addConfigToDatabase(getIbisContext(), datasource, activateConfig, automaticReload, fileName, file, user);
            if (configName != null) {
                result.put(configName, "loaded");
            }
        }
        return Response.status(Response.Status.CREATED).entity(result).build();
    } catch (Exception e) {
        throw new ApiException("Failed to upload Configuration", e);
    }
}
Also used : InputStream(java.io.InputStream) IOException(java.io.IOException) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) LinkedHashMap(java.util.LinkedHashMap) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 83 with RolesAllowed

use of javax.annotation.security.RolesAllowed in project iaf by ibissource.

the class ShowConfiguration method getConfigurationByName.

@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/configurations/{configuration}")
@Produces(MediaType.APPLICATION_XML)
public Response getConfigurationByName(@PathParam("configuration") String configurationName, @QueryParam("loadedConfiguration") boolean loadedConfiguration) throws ApiException {
    String result = "";
    Configuration configuration = getIbisManager().getConfiguration(configurationName);
    if (configuration == null) {
        throw new ApiException("Configuration not found!");
    }
    if (loadedConfiguration) {
        result = configuration.getLoadedConfiguration();
    } else {
        result = configuration.getOriginalConfiguration();
    }
    return Response.status(Response.Status.OK).entity(result).build();
}
Also used : Configuration(nl.nn.adapterframework.configuration.Configuration) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 84 with RolesAllowed

use of javax.annotation.security.RolesAllowed in project iaf by ibissource.

the class ShowEnvironmentVariables method environmentVariables.

@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/environmentvariables")
@Produces(MediaType.APPLICATION_JSON)
public Response environmentVariables() throws ApiException {
    List<String> propsToHide = new ArrayList<String>();
    String propertiesHideString = AppConstants.getInstance().getString("properties.hide", null);
    if (propertiesHideString != null) {
        propsToHide.addAll(Arrays.asList(propertiesHideString.split("[,\\s]+")));
    }
    Map<String, Object> envVars = new HashMap<String, Object>();
    Map<String, Object> configVars = new HashMap<String, Object>();
    configVars.put("All", convertPropertiesToMap(AppConstants.getInstance(), propsToHide));
    for (Configuration config : getIbisManager().getConfigurations()) {
        if (config.getClassLoader() != null) {
            configVars.put(config.getName(), convertPropertiesToMap(AppConstants.getInstance(config.getClassLoader()), propsToHide));
        }
    }
    envVars.put("Application Constants", configVars);
    envVars.put("System Properties", convertPropertiesToMap(System.getProperties(), propsToHide));
    try {
        envVars.put("Environment Variables", convertPropertiesToMap(Misc.getEnvironmentVariables()));
    } catch (Throwable t) {
        log.warn("caught Throwable while getting EnvironmentVariables", t);
    }
    return Response.status(Response.Status.CREATED).entity(envVars).build();
}
Also used : Configuration(nl.nn.adapterframework.configuration.Configuration) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 85 with RolesAllowed

use of javax.annotation.security.RolesAllowed in project iaf by ibissource.

the class ShowLiquibaseScript method getConfigurations.

@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/jdbc/liquibase")
@Produces(MediaType.APPLICATION_JSON)
public Response getConfigurations() throws ApiException {
    List<String> configNames = new ArrayList<String>();
    for (Configuration config : getIbisManager().getConfigurations()) {
        DatabaseMigratorBase databaseMigrator = config.getBean("jdbcMigrator", DatabaseMigratorBase.class);
        if (databaseMigrator.hasMigrationScript()) {
            configNames.add(config.getName());
        }
    }
    HashMap<String, Object> resultMap = new HashMap<>();
    resultMap.put("configurationsWithLiquibaseScript", configNames);
    return Response.status(Response.Status.OK).entity(resultMap).build();
}
Also used : Configuration(nl.nn.adapterframework.configuration.Configuration) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DatabaseMigratorBase(nl.nn.adapterframework.jdbc.migration.DatabaseMigratorBase) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

RolesAllowed (javax.annotation.security.RolesAllowed)191 Path (javax.ws.rs.Path)127 Produces (javax.ws.rs.Produces)110 Consumes (javax.ws.rs.Consumes)55 GET (javax.ws.rs.GET)54 POST (javax.ws.rs.POST)40 PUT (javax.ws.rs.PUT)35 HashMap (java.util.HashMap)34 ArrayList (java.util.ArrayList)32 IOException (java.io.IOException)30 ApiOperation (io.swagger.annotations.ApiOperation)29 ApiResponses (io.swagger.annotations.ApiResponses)29 Response (javax.ws.rs.core.Response)28 Adapter (nl.nn.adapterframework.core.Adapter)21 DELETE (javax.ws.rs.DELETE)19 WebApplicationException (org.rembx.jeeshop.rest.WebApplicationException)19 LinkedHashMap (java.util.LinkedHashMap)16 Locale (java.util.Locale)16 Map (java.util.Map)12 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)12