Search in sources :

Example 1 with Dir2Map

use of nl.nn.adapterframework.util.Dir2Map in project iaf by ibissource.

the class ShowLogging method getLogDirectory.

@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/logging")
@Relation("logging")
@Produces(MediaType.APPLICATION_JSON)
public Response getLogDirectory(@QueryParam("directory") String directory, @QueryParam("sizeFormat") String sizeFormatParam, @QueryParam("wildcard") String wildcard) throws ApiException {
    Map<String, Object> returnMap = new HashMap<String, Object>();
    if (directory == null || directory.isEmpty())
        directory = AppConstants.getInstance().getResolvedProperty("logging.path").replace("\\\\", "\\");
    boolean sizeFormat = (sizeFormatParam == null || sizeFormatParam.isEmpty()) ? true : Boolean.parseBoolean(sizeFormatParam);
    if (wildcard == null || wildcard.isEmpty())
        wildcard = AppConstants.getInstance().getProperty("logging.wildcard");
    try {
        if (!FileUtils.readAllowed(FileViewerServlet.permissionRules, servletRequest, directory)) {
            throw new ApiException("Access to path (" + directory + ") not allowed!");
        }
        Dir2Map dir = new Dir2Map(directory, sizeFormat, wildcard, showDirectories, maxItems);
        returnMap.put("list", dir.getList());
        returnMap.put("count", dir.size());
        returnMap.put("directory", dir.getDirectory());
        returnMap.put("sizeFormat", sizeFormat);
        returnMap.put("wildcard", wildcard);
    } catch (IOException e) {
        throw new ApiException("Error while trying to retreive directory information", e);
    }
    return Response.status(Response.Status.OK).entity(returnMap).build();
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Dir2Map(nl.nn.adapterframework.util.Dir2Map) IOException(java.io.IOException) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 RolesAllowed (javax.annotation.security.RolesAllowed)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Dir2Map (nl.nn.adapterframework.util.Dir2Map)1