Skip to content

Commit

Permalink
SAK-31796 - Clean up instances of e.printStackTrace in the rest of Sa…
Browse files Browse the repository at this point in the history
…kai (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
  • Loading branch information
Miguel Pellicer authored and ern committed Dec 12, 2017
1 parent d0d6f06 commit 1dc2b84
Show file tree
Hide file tree
Showing 1,310 changed files with 15,763 additions and 19,119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;

import org.sakaiproject.authz.api.SecurityAdvisor;
import org.sakaiproject.authz.api.SecurityService;
import org.sakaiproject.cheftool.VmServlet;
Expand Down Expand Up @@ -71,11 +71,9 @@
*
* @author Sakai Software Development Team
*/
@Slf4j
public class AccessServlet extends VmServlet
{
/** Our log (commons). */
private static Logger M_log = LoggerFactory.getLogger(AccessServlet.class);

/** Resource bundle using current language locale */
protected static ResourceLoader rb = new ResourceLoader("access");

Expand Down Expand Up @@ -350,7 +348,7 @@ public SecurityAdvice isAllowed(String userId, String function, String reference
catch (EntityNotDefinedException e)
{
// the request was not valid in some way
M_log.debug("dispatch(): ref: " + ref.getReference(), e);
log.debug("dispatch(): ref: " + ref.getReference(), e);
sendError(res, HttpServletResponse.SC_NOT_FOUND);
return;
}
Expand All @@ -368,13 +366,13 @@ public SecurityAdvice isAllowed(String userId, String function, String reference
}

// otherwise reject the request
M_log.debug("dispatch(): ref: " + ref.getReference(), e);
log.debug("dispatch(): ref: " + ref.getReference(), e);
sendError(res, HttpServletResponse.SC_FORBIDDEN);
}

catch (EntityAccessOverloadException e)
{
M_log.info("dispatch(): ref: " + ref.getReference(), e);
log.info("dispatch(): ref: " + ref.getReference(), e);
sendError(res, HttpServletResponse.SC_SERVICE_UNAVAILABLE);
}

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

catch (Throwable e)
{
M_log.warn("dispatch(): exception: ", e);
log.warn("dispatch(): exception: ", e);
sendError(res, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}

finally
{
// log
if (M_log.isDebugEnabled())
M_log.debug("from:" + req.getRemoteAddr() + " path:" + params.getPath() + " options: " + info.optionsString()
if (log.isDebugEnabled())
log.debug("from:" + req.getRemoteAddr() + " path:" + params.getPath() + " options: " + info.optionsString()
+ " time: " + info.getElapsedTime());
}
}
Expand Down Expand Up @@ -458,7 +456,7 @@ protected void doLogin(HttpServletRequest req, HttpServletResponse res, String p
{
// if basic auth is valid do that
if ( basicAuth.doAuth(req,res) ) {
//System.err.println("BASIC Auth Request Sent to the Browser ");
log.info("BASIC Auth Request Sent to the Browser ");
return;
}

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

// map the request to the helper, leaving the path after ".../options" for the helper
Expand All @@ -505,7 +503,7 @@ protected void sendError(HttpServletResponse res, int code)
}
catch (Throwable t)
{
M_log.warn("sendError: " + t);
log.warn("sendError: " + t);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUpload;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.sakaiproject.component.cover.ComponentManager;
import org.sakaiproject.content.api.ContentCollection;
import org.sakaiproject.content.api.ContentHostingService;
Expand All @@ -60,16 +60,13 @@
*
* @author Sakai Software Development Team
*/
@Slf4j
public class WebServlet extends AccessServlet
{
/** Our log (commons). */
private static Logger M_log = LoggerFactory.getLogger(WebServlet.class);
protected ContentHostingService contentHostingService;
protected UserDirectoryService userDirectoryService;
protected TimeService timeService;



/* (non-Javadoc)
* @see org.sakaiproject.access.tool.AccessServlet#init(javax.servlet.ServletConfig)
*/
Expand Down Expand Up @@ -181,15 +178,15 @@ protected String preProcessPath(String path, HttpServletRequest req)
protected void postUpload(HttpServletRequest req, HttpServletResponse res)
{
String path = req.getPathInfo();
// System.out.println("path " + path);
log.debug("path {}", path);
if (path == null) path = "";
// assume caller has verified that it is a request for content and that it's multipart
// loop over attributes in request, picking out the ones
// that are file uploads and doing them
for (Enumeration e = req.getAttributeNames(); e.hasMoreElements();)
{
String iname = (String) e.nextElement();
// System.out.println("Item " + iname);
log.debug("Item {}", iname);
Object o = req.getAttribute(iname);
// NOTE: Fileitem is from
// org.apache.commons.fileupload.FileItem, not
Expand All @@ -201,7 +198,7 @@ protected void postUpload(HttpServletRequest req, HttpServletResponse res)
{
if (!writeFile(fi.getName(), fi.getContentType(), inputStream, path, req, res, true)) return;
} catch (IOException ioe) {
M_log.warn("Problem getting InputStream", ioe);
log.warn("Problem getting InputStream", ioe);
}
}
}
Expand All @@ -217,7 +214,7 @@ protected boolean writeFile(String name, String type, InputStream inputStream, S
if (i >= 0) name = name.substring(i + 1);
if (name.length() < 1)
{
// System.out.println("no name left / removal");
log.debug("no name left / removal");
resp.sendError(HttpServletResponse.SC_FORBIDDEN);
return false;
}
Expand All @@ -241,14 +238,14 @@ protected boolean writeFile(String name, String type, InputStream inputStream, S
// Try to delete the resource
try
{
// System.out.println("Trying Del " + path);
log.debug("Trying Del {}", path);
// The existing document may be a collection or a file.
boolean isCollection = contentHostingService.getProperties(path).getBooleanProperty(
ResourceProperties.PROP_IS_COLLECTION);

if (isCollection)
{
// System.out.println("Can't del, iscoll");
log.debug("Can't del, iscoll");
resp.sendError(HttpServletResponse.SC_FORBIDDEN);
return false;
}
Expand All @@ -258,7 +255,7 @@ protected boolean writeFile(String name, String type, InputStream inputStream, S
// work for my workspace
ContentResourceEdit edit = contentHostingService.editResource(path);
// if (edit != null)
// System.out.println("Got edit");
log.debug("Got edit");
contentHostingService.removeResource(edit);
}
}
Expand All @@ -268,7 +265,7 @@ protected boolean writeFile(String name, String type, InputStream inputStream, S
}
catch (Exception e)
{
// System.out.println("Can't del, exception " + e.getClass() + ": " + e.getMessage());
log.debug("Can't del, exception {}: {}", e.getClass(), e.getMessage());
resp.sendError(HttpServletResponse.SC_FORBIDDEN);
return false;
}
Expand All @@ -287,7 +284,7 @@ protected boolean writeFile(String name, String type, InputStream inputStream, S

resourceProperties.addProperty(ResourceProperties.PROP_DISPLAY_NAME, name);

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

Expand All @@ -306,29 +303,29 @@ protected boolean writeFile(String name, String type, InputStream inputStream, S
{
}
}
// System.out.println("Add fail, inconsistent");
log.debug("Add fail, inconsistent");
resp.sendError(HttpServletResponse.SC_CONFLICT);
return false;
}
catch (IdUsedException e)
{
// Should not happen because we deleted above (unless tawo requests at same time)
// System.out.println("Add fail, in use");
M_log.warn("access post IdUsedException:" + e.getMessage());
log.debug("Add fail, in use");
log.warn("access post IdUsedException:" + e.getMessage());

resp.sendError(HttpServletResponse.SC_CONFLICT);
return false;
}
catch (Exception e)
{
// System.out.println("Add failed, exception " + e.getClass() + ": " + e.getMessage());
log.debug("Add failed, exception {}: {}", e.getClass(), e.getMessage());
resp.sendError(HttpServletResponse.SC_FORBIDDEN);
return false;
}
}
catch (IOException e)
{
// System.out.println("overall fail IOException " + e);
log.debug("overall fail IOException {}", e);
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.SuffixFileFilter;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sakaiproject.archive.api.ArchiveService;
import org.sakaiproject.archive.tool.model.SparseFile;
import org.sakaiproject.archive.tool.model.SparseSite;
Expand Down Expand Up @@ -65,9 +63,12 @@
import java.text.SimpleDateFormat;
import java.util.*;

import lombok.extern.slf4j.Slf4j;

/**
* <p>ArchiveAction is the Sakai archive tool.</p>
*/
@Slf4j
public class ArchiveAction
extends VelocityPortletPaneledAction
{
Expand All @@ -93,8 +94,6 @@ public class ArchiveAction
private SecurityService securityService;
private IdManager idManager;

private static final Logger log = LoggerFactory.getLogger(ArchiveAction.class);

// for batch archive
private long batchArchiveStarted = 0;
private long maxJobTime;
Expand Down Expand Up @@ -603,7 +602,7 @@ private void archiveSites(List<SparseSite> sites, String selectedTerm, Session c
try {
archiveService.archiveAndZip(s.getId());
} catch (IOException e) {
e.printStackTrace();
log.error("Failed to archive and compress it the site with id {}", s.getId(), e);
}

archiveCount++;
Expand Down
Loading

0 comments on commit 1dc2b84

Please sign in to comment.