package org.carlspring.strongbox.rest;

import org.carlspring.logging.rest.AbstractLoggingManagementRestlet;

import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.io.InputStream;

import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;

/**
 * @author carlspring
 */
@Component
@Path("/logging")
@Api(value = "/logging")
public class LoggingManagementRestlet
        extends AbstractLoggingManagementRestlet
{


    @ApiOperation(value = "Used to add a logger.", position = 0)
    @ApiResponses(value = { @ApiResponse(code = 200, message = "The logger was added successfully."),
                            @ApiResponse(code = 500, message = "Failed to add logger!") })
    @Override
    @PreAuthorize("hasAuthority('CONFIGURATION_ADD_LOGGER')")
    public Response addLogger(@ApiParam(value = "The package to log", required = true)
                                      String loggerPackage,
                              @ApiParam(value = "The logging level", required = true)
                                      String level,
                              @ApiParam(value = "The name of the appender", required = true)
                                      String appenderName)
    {
        return super.addLogger(loggerPackage, level, appenderName);
    }

    @ApiOperation(value = "Used to update a logger.")
    @ApiResponses(value = { @ApiResponse(code = 200, message = "The logger was updated successfully."),
                            @ApiResponse(code = 400, message = "Failed to update logger!"),
                            @ApiResponse(code = 404, message = "Logger '${loggerPackage}' not found.") })
    @Override
    @PreAuthorize("hasAuthority('CONFIGURATION_UPDATE_LOGGER')")
    public Response updateLogger(@ApiParam(value = "The package to log", required = true)
                                         String loggerPackage,
                                 @ApiParam(value = "The logging level", required = true)
                                         String level)
    {
        return super.updateLogger(loggerPackage, level);
    }

    @ApiOperation(value = "Used to delete a logger.")
    @ApiResponses(value = { @ApiResponse(code = 200, message = "The logger was deleted successfully."),
                            @ApiResponse(code = 400, message = "Failed to delete the logger!"),
                            @ApiResponse(code = 404, message = "Logger '${loggerPackage}' not found.") })
    @Override
    @PreAuthorize("hasAuthority('CONFIGURATION_DELETE_LOGGER')")
    public Response deleteLogger(@ApiParam(value = "The logger to delete", required = true)
                                         String loggerPackage)
            throws IOException
    {
        return super.deleteLogger(loggerPackage);
    }

    @ApiOperation(value = "Used to download a log file.")
    @ApiResponses(value = { @ApiResponse(code = 200, message = "", response = String.class),
                            @ApiResponse(code = 400, message = "Failed to resolve the log!") })
    @Override
    @PreAuthorize("hasAuthority('CONFIGURATION_RETRIEVE_LOG')")
    public Response downloadLog(@ApiParam(value = "The relative path to the log file", required = true)
                                        String path)
    {
        return super.downloadLog(path);
    }

    @ApiOperation(value = "Used to download the Logback configuration file.")
    @ApiResponses(value = { @ApiResponse(code = 200, message = ""),
                            @ApiResponse(code = 400, message = "Failed to resolve the logging configuration!") })
    @Override
    @PreAuthorize("hasAuthority('CONFIGURATION_RETRIEVE_LOGBACK_CFG')")
    public Response downloadLogbackConfiguration()
    {
        return super.downloadLogbackConfiguration();
    }

    @ApiOperation(value = "Used to upload and re-load a Logback configuration file.")
    @ApiResponses(value = { @ApiResponse(code = 200, message = "Logback configuration uploaded successfully."),
                            @ApiResponse(code = 400, message = "Failed to resolve the logging configuration!") })
    @Override
    @PreAuthorize("hasAuthority('CONFIGURATION_UPLOAD_LOGBACK_CFG')")
    public Response uploadLogbackConfiguration(
                                                      @ApiParam(value = "The input stream of the the Logback configuration file to load", required = true)
                                                              InputStream is)
    {
        return super.uploadLogbackConfiguration(is);
    }
}

@@ -989,32 +989,24 @@
             
-        
 String logge
@@ -1007,32 +1007,32 @@
  loggerPackage,%0A
+
                 
@@ -1097,32 +1097,24 @@
 red = true)%0A
-        
             
@@ -1145,16 +1145,16 @@
  level,%0A
+
         
@@ -1234,32 +1234,24 @@
 red = true)%0A
-        
             
@@ -1289,16 +1289,16 @@
 erName)%0A
+
     %7B%0A  
@@ -1891,32 +1891,24 @@
 red = true)%0A
-        
             
@@ -1942,32 +1942,32 @@
  loggerPackage,%0A
+
                 
@@ -2035,32 +2035,24 @@
 red = true)%0A
-        
             
@@ -2086,16 +2086,16 @@
  level)%0A
+
     %7B%0A  
@@ -2683,32 +2683,24 @@
 red = true)%0A
-        
             
@@ -2742,16 +2742,16 @@
 ackage)%0A
+
         
@@ -3261,32 +3261,24 @@
 red = true)%0A
-        
             
@@ -3310,16 +3310,16 @@
 g path)%0A
+
     %7B%0A  
@@ -4273,63 +4273,8 @@
 ion(
-%0A                                                      
 @Api
@@ -4366,39 +4366,24 @@
 red = true)%0A
-               
             
@@ -4492,16 +4492,21 @@
 on(is);%0A
-
     %7D%0A
+    %0A
 %7D%0A

Update LoggingManagementRestlet.java