Skip to content

Commit 1dc2b84

Browse files
Miguel Pellicerern
Miguel Pellicer
authored andcommitted
SAK-31796 - Clean up instances of e.printStackTrace in the rest of Sakai (sakaiproject#5113)
* Search - Clean up instances of e.printStackTrace * Sections - Clean up instances of printStackTrace * Shortened - Clean up instances of e.printStackTrace * SimpleRSS - Clean up instances of e.printStackTrace * Site - Clean up instances of e.printStackTrace * sitedescription - Clean up instances of e.printStackTrace * Taggable - Clean up instances of e.printStackTrace * Signup - Clean up instances of e.printStackTrace * Sitemanage - Clean up instances of e.printStackTrace * Access - Clean up instances of e.printStackTrace * Admin-tools - Clean up instances of e.printStackTrace * Announcement - Clean up instances of e.printStackTrace * Archive - Clean up instances of e.printStackTrace * Assignment - Clean up instances of e.printStackTrace * Basiclti - Clean up instances of e.printStackTrace * Calendar - Clean up instances of e.printStackTrace * Chat - Clean up instances of e.printStackTrace * Citations - Clean up instances of e.printStackTrace * Cloud-content - Clean up instances of e.printStackTrace * Cmprovider - Clean up instances of e.printStackTrace * Common - Clean up instances of e.printStackTrace * Sitestats - Clean up instances of e.printStackTrace * Commons - Clean up instances of e.printStackTrace * Content - Clean up instances of e.printStackTrace * Courier - Clean up instances of e.printStackTrace * Dav - Clean up instances of e.printStackTrace * Delegatedaccess - Clean up instances of e.printStackTrace * Edu-services - Clean up instances of e.printStackTrace * Content-review - Clean up instances of e.printStackTrace * Citations - Clean up instances of e.printStackTrace * Emailtemplateservice - Clean up instances of e.printStackTrace * Endorsed - Clean up instances of e.printStackTrace * Entitybroker - Clean up instances of e.printStackTrace * External-calendaring-service - Clean up instances of e.printStackTrace * External-calendaring-service - Clean up instances of e.printStackTrace * Feedback - Clean up instances of e.printStackTrace * Syllabus - Clean up instances of e.printStackTrace * Tags - Clean up instances of e.printStackTrace * Gradebook - Clean up instances of printStackTrace * Textarea - Clean up printStackTrace * Tool - Clean up printStackTrace * Gradebookng - Clean up instances of e.printStackTrace * Help - Clean up instances of e.printStackTrace * Hierarchy - Clean up instances of e.printStackTrace * Jobsscheduler - Clean up instances of e.printStackTrace * Jsf - Clean up instances of e.printStackTrace * User - Clean up instances of printStackTrace * useraudit - Clean up instances of printStack * usermembership - Clean up instances of printStackTrace * Velocity - Clean up instances of printStackTrace * Web - Clean up instances of printStackTrace * Webservices - Clean up instances of printStackTrace * Rwiki - Clean up instances of printStackTrace * rubrics - Clean up instances of printStackTrace * rsf - Clean up instances of printStackTrace * roster2 - Clean up instances of printStackTrace * reset-pass - Clean up instances of printStackTrace * providers - Clean up instances of printStackTrace * Profile2 - Clean up instances of printStackTrace * Kernel - Clean up instances of printStackTrace * Presence - Clean up instances of printStackTrace * Postem - Clean up instances of printStackTrace * Portal - Clean up instances of printStackTrace * polls - Clean up instances of printStackTrace * Podcasts - Clean up instances of printStackTrace * Pasystem - Clean up instances of printStackTrace * oauth - Clean up instances of printStackTrace * Lessonbuilder - Clean up instances of printStackTrace * Login - Clean up instances of printStackTrace * Mailarchive - Clean up instances of printStackTrace * Mailsender - Clean up instances of printStackTrace * Message - Clean up instances of printStackTrace * MSGCNTR - Clean up instances of printStackTrace * Extra cases - Clean up instances of printStackTrace * Extra cases - Clean up instances of System.out.println * Extra cases - Use Slf4j Annotation
1 parent d0d6f06 commit 1dc2b84

File tree

1,310 files changed

+15763
-19119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,310 files changed

+15763
-19119
lines changed

access/access-impl/impl/src/java/org/sakaiproject/access/tool/AccessServlet.java

+12-14
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
import javax.servlet.http.HttpServletRequest;
3333
import javax.servlet.http.HttpServletResponse;
3434

35-
import org.slf4j.Logger;
36-
import org.slf4j.LoggerFactory;
35+
import lombok.extern.slf4j.Slf4j;
36+
3737
import org.sakaiproject.authz.api.SecurityAdvisor;
3838
import org.sakaiproject.authz.api.SecurityService;
3939
import org.sakaiproject.cheftool.VmServlet;
@@ -71,11 +71,9 @@
7171
*
7272
* @author Sakai Software Development Team
7373
*/
74+
@Slf4j
7475
public class AccessServlet extends VmServlet
7576
{
76-
/** Our log (commons). */
77-
private static Logger M_log = LoggerFactory.getLogger(AccessServlet.class);
78-
7977
/** Resource bundle using current language locale */
8078
protected static ResourceLoader rb = new ResourceLoader("access");
8179

@@ -350,7 +348,7 @@ public SecurityAdvice isAllowed(String userId, String function, String reference
350348
catch (EntityNotDefinedException e)
351349
{
352350
// the request was not valid in some way
353-
M_log.debug("dispatch(): ref: " + ref.getReference(), e);
351+
log.debug("dispatch(): ref: " + ref.getReference(), e);
354352
sendError(res, HttpServletResponse.SC_NOT_FOUND);
355353
return;
356354
}
@@ -368,13 +366,13 @@ public SecurityAdvice isAllowed(String userId, String function, String reference
368366
}
369367

370368
// otherwise reject the request
371-
M_log.debug("dispatch(): ref: " + ref.getReference(), e);
369+
log.debug("dispatch(): ref: " + ref.getReference(), e);
372370
sendError(res, HttpServletResponse.SC_FORBIDDEN);
373371
}
374372

375373
catch (EntityAccessOverloadException e)
376374
{
377-
M_log.info("dispatch(): ref: " + ref.getReference(), e);
375+
log.info("dispatch(): ref: " + ref.getReference(), e);
378376
sendError(res, HttpServletResponse.SC_SERVICE_UNAVAILABLE);
379377
}
380378

@@ -397,15 +395,15 @@ public SecurityAdvice isAllowed(String userId, String function, String reference
397395

398396
catch (Throwable e)
399397
{
400-
M_log.warn("dispatch(): exception: ", e);
398+
log.warn("dispatch(): exception: ", e);
401399
sendError(res, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
402400
}
403401

404402
finally
405403
{
406404
// log
407-
if (M_log.isDebugEnabled())
408-
M_log.debug("from:" + req.getRemoteAddr() + " path:" + params.getPath() + " options: " + info.optionsString()
405+
if (log.isDebugEnabled())
406+
log.debug("from:" + req.getRemoteAddr() + " path:" + params.getPath() + " options: " + info.optionsString()
409407
+ " time: " + info.getElapsedTime());
410408
}
411409
}
@@ -458,7 +456,7 @@ protected void doLogin(HttpServletRequest req, HttpServletResponse res, String p
458456
{
459457
// if basic auth is valid do that
460458
if ( basicAuth.doAuth(req,res) ) {
461-
//System.err.println("BASIC Auth Request Sent to the Browser ");
459+
log.info("BASIC Auth Request Sent to the Browser ");
462460
return;
463461
}
464462

@@ -482,7 +480,7 @@ protected void doLogin(HttpServletRequest req, HttpServletResponse res, String p
482480
// check that we have a return path set; might have been done earlier
483481
if (session.getAttribute(Tool.HELPER_DONE_URL) == null)
484482
{
485-
M_log.warn("doLogin - proceeding with null HELPER_DONE_URL");
483+
log.warn("doLogin - proceeding with null HELPER_DONE_URL");
486484
}
487485

488486
// map the request to the helper, leaving the path after ".../options" for the helper
@@ -505,7 +503,7 @@ protected void sendError(HttpServletResponse res, int code)
505503
}
506504
catch (Throwable t)
507505
{
508-
M_log.warn("sendError: " + t);
506+
log.warn("sendError: " + t);
509507
}
510508
}
511509

access/access-impl/impl/src/java/org/sakaiproject/access/tool/WebServlet.java

+17-20
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
import javax.servlet.http.HttpServletRequest;
3131
import javax.servlet.http.HttpServletResponse;
3232

33+
import lombok.extern.slf4j.Slf4j;
3334
import org.apache.commons.fileupload.FileItem;
3435
import org.apache.commons.fileupload.FileUpload;
35-
import org.slf4j.Logger;
36-
import org.slf4j.LoggerFactory;
36+
3737
import org.sakaiproject.component.cover.ComponentManager;
3838
import org.sakaiproject.content.api.ContentCollection;
3939
import org.sakaiproject.content.api.ContentHostingService;
@@ -60,16 +60,13 @@
6060
*
6161
* @author Sakai Software Development Team
6262
*/
63+
@Slf4j
6364
public class WebServlet extends AccessServlet
6465
{
65-
/** Our log (commons). */
66-
private static Logger M_log = LoggerFactory.getLogger(WebServlet.class);
6766
protected ContentHostingService contentHostingService;
6867
protected UserDirectoryService userDirectoryService;
6968
protected TimeService timeService;
7069

71-
72-
7370
/* (non-Javadoc)
7471
* @see org.sakaiproject.access.tool.AccessServlet#init(javax.servlet.ServletConfig)
7572
*/
@@ -181,15 +178,15 @@ protected String preProcessPath(String path, HttpServletRequest req)
181178
protected void postUpload(HttpServletRequest req, HttpServletResponse res)
182179
{
183180
String path = req.getPathInfo();
184-
// System.out.println("path " + path);
181+
log.debug("path {}", path);
185182
if (path == null) path = "";
186183
// assume caller has verified that it is a request for content and that it's multipart
187184
// loop over attributes in request, picking out the ones
188185
// that are file uploads and doing them
189186
for (Enumeration e = req.getAttributeNames(); e.hasMoreElements();)
190187
{
191188
String iname = (String) e.nextElement();
192-
// System.out.println("Item " + iname);
189+
log.debug("Item {}", iname);
193190
Object o = req.getAttribute(iname);
194191
// NOTE: Fileitem is from
195192
// org.apache.commons.fileupload.FileItem, not
@@ -201,7 +198,7 @@ protected void postUpload(HttpServletRequest req, HttpServletResponse res)
201198
{
202199
if (!writeFile(fi.getName(), fi.getContentType(), inputStream, path, req, res, true)) return;
203200
} catch (IOException ioe) {
204-
M_log.warn("Problem getting InputStream", ioe);
201+
log.warn("Problem getting InputStream", ioe);
205202
}
206203
}
207204
}
@@ -217,7 +214,7 @@ protected boolean writeFile(String name, String type, InputStream inputStream, S
217214
if (i >= 0) name = name.substring(i + 1);
218215
if (name.length() < 1)
219216
{
220-
// System.out.println("no name left / removal");
217+
log.debug("no name left / removal");
221218
resp.sendError(HttpServletResponse.SC_FORBIDDEN);
222219
return false;
223220
}
@@ -241,14 +238,14 @@ protected boolean writeFile(String name, String type, InputStream inputStream, S
241238
// Try to delete the resource
242239
try
243240
{
244-
// System.out.println("Trying Del " + path);
241+
log.debug("Trying Del {}", path);
245242
// The existing document may be a collection or a file.
246243
boolean isCollection = contentHostingService.getProperties(path).getBooleanProperty(
247244
ResourceProperties.PROP_IS_COLLECTION);
248245

249246
if (isCollection)
250247
{
251-
// System.out.println("Can't del, iscoll");
248+
log.debug("Can't del, iscoll");
252249
resp.sendError(HttpServletResponse.SC_FORBIDDEN);
253250
return false;
254251
}
@@ -258,7 +255,7 @@ protected boolean writeFile(String name, String type, InputStream inputStream, S
258255
// work for my workspace
259256
ContentResourceEdit edit = contentHostingService.editResource(path);
260257
// if (edit != null)
261-
// System.out.println("Got edit");
258+
log.debug("Got edit");
262259
contentHostingService.removeResource(edit);
263260
}
264261
}
@@ -268,7 +265,7 @@ protected boolean writeFile(String name, String type, InputStream inputStream, S
268265
}
269266
catch (Exception e)
270267
{
271-
// System.out.println("Can't del, exception " + e.getClass() + ": " + e.getMessage());
268+
log.debug("Can't del, exception {}: {}", e.getClass(), e.getMessage());
272269
resp.sendError(HttpServletResponse.SC_FORBIDDEN);
273270
return false;
274271
}
@@ -287,7 +284,7 @@ protected boolean writeFile(String name, String type, InputStream inputStream, S
287284

288285
resourceProperties.addProperty(ResourceProperties.PROP_DISPLAY_NAME, name);
289286

290-
// System.out.println("Trying Add " + path);
287+
log.debug("Trying Add {}", path);
291288
ContentResource resource = contentHostingService.addResource(path, type, inputStream, resourceProperties,
292289
NotificationService.NOTI_NONE);
293290

@@ -306,29 +303,29 @@ protected boolean writeFile(String name, String type, InputStream inputStream, S
306303
{
307304
}
308305
}
309-
// System.out.println("Add fail, inconsistent");
306+
log.debug("Add fail, inconsistent");
310307
resp.sendError(HttpServletResponse.SC_CONFLICT);
311308
return false;
312309
}
313310
catch (IdUsedException e)
314311
{
315312
// Should not happen because we deleted above (unless tawo requests at same time)
316-
// System.out.println("Add fail, in use");
317-
M_log.warn("access post IdUsedException:" + e.getMessage());
313+
log.debug("Add fail, in use");
314+
log.warn("access post IdUsedException:" + e.getMessage());
318315

319316
resp.sendError(HttpServletResponse.SC_CONFLICT);
320317
return false;
321318
}
322319
catch (Exception e)
323320
{
324-
// System.out.println("Add failed, exception " + e.getClass() + ": " + e.getMessage());
321+
log.debug("Add failed, exception {}: {}", e.getClass(), e.getMessage());
325322
resp.sendError(HttpServletResponse.SC_FORBIDDEN);
326323
return false;
327324
}
328325
}
329326
catch (IOException e)
330327
{
331-
// System.out.println("overall fail IOException " + e);
328+
log.debug("overall fail IOException {}", e);
332329
}
333330
return true;
334331
}

admin-tools/src/java/org/sakaiproject/archive/tool/ArchiveAction.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
import org.apache.commons.io.FileUtils;
2525
import org.apache.commons.io.filefilter.SuffixFileFilter;
2626
import org.apache.commons.lang3.StringUtils;
27-
import org.slf4j.Logger;
28-
import org.slf4j.LoggerFactory;
2927
import org.sakaiproject.archive.api.ArchiveService;
3028
import org.sakaiproject.archive.tool.model.SparseFile;
3129
import org.sakaiproject.archive.tool.model.SparseSite;
@@ -65,9 +63,12 @@
6563
import java.text.SimpleDateFormat;
6664
import java.util.*;
6765

66+
import lombok.extern.slf4j.Slf4j;
67+
6868
/**
6969
* <p>ArchiveAction is the Sakai archive tool.</p>
7070
*/
71+
@Slf4j
7172
public class ArchiveAction
7273
extends VelocityPortletPaneledAction
7374
{
@@ -93,8 +94,6 @@ public class ArchiveAction
9394
private SecurityService securityService;
9495
private IdManager idManager;
9596

96-
private static final Logger log = LoggerFactory.getLogger(ArchiveAction.class);
97-
9897
// for batch archive
9998
private long batchArchiveStarted = 0;
10099
private long maxJobTime;
@@ -603,7 +602,7 @@ private void archiveSites(List<SparseSite> sites, String selectedTerm, Session c
603602
try {
604603
archiveService.archiveAndZip(s.getId());
605604
} catch (IOException e) {
606-
e.printStackTrace();
605+
log.error("Failed to archive and compress it the site with id {}", s.getId(), e);
607606
}
608607

609608
archiveCount++;

0 commit comments

Comments
 (0)