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();
}
Aggregations