39
39
import org .apache .sling .models .factory .ModelFactory ;
40
40
import org .osgi .service .component .annotations .Component ;
41
41
import org .osgi .service .component .annotations .Reference ;
42
+ import org .slf4j .Logger ;
43
+ import org .slf4j .LoggerFactory ;
42
44
43
45
@ Component (
44
46
service = Servlet .class ,
51
53
)
52
54
public class ScriptUploadServlet extends SlingAllMethodsServlet {
53
55
56
+ private static final Logger LOGGER = LoggerFactory .getLogger (ScriptUploadServlet .class );
57
+
54
58
@ Reference
55
59
private ScriptStorage scriptStorage ;
56
60
@@ -66,12 +70,15 @@ protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse
66
70
try {
67
71
Script script = scriptStorage .save (form , resourceResolver );
68
72
scriptManager .process (script , ExecutionMode .VALIDATION , resourceResolver );
69
- return ResponseEntity .ok ("File successfully saved" )
73
+ LOGGER .info ("Script {} successfully saved" , script .getPath ());
74
+ return ResponseEntity .ok ("Script successfully saved" )
70
75
.addEntry ("uploadedScript" , new ScriptDto (script ));
71
76
} catch (ScriptStorageException e ) {
77
+ LOGGER .error ("Errors while saving script" , e );
72
78
return ResponseEntity .badRequest (StringUtils .defaultString (e .getMessage (), "Errors while saving script" ))
73
79
.addEntry ("errors" , e .getErrors ());
74
80
} catch (PersistenceException | RepositoryException e ) {
81
+ LOGGER .error ("Errors while saving script" , e );
75
82
throw new RuntimeException (e );
76
83
}
77
84
});
0 commit comments