summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/tickets
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/gitblit/tickets')
-rw-r--r--src/main/java/com/gitblit/tickets/BranchTicketService.java23
-rw-r--r--src/main/java/com/gitblit/tickets/FileTicketService.java7
-rw-r--r--src/main/java/com/gitblit/tickets/ITicketService.java26
-rw-r--r--src/main/java/com/gitblit/tickets/RedisTicketService.java24
-rw-r--r--src/main/java/com/gitblit/tickets/TicketIndexer.java15
-rw-r--r--src/main/java/com/gitblit/tickets/TicketNotifier.java16
6 files changed, 49 insertions, 62 deletions
diff --git a/src/main/java/com/gitblit/tickets/BranchTicketService.java b/src/main/java/com/gitblit/tickets/BranchTicketService.java
index 8430c546..3add609d 100644
--- a/src/main/java/com/gitblit/tickets/BranchTicketService.java
+++ b/src/main/java/com/gitblit/tickets/BranchTicketService.java
@@ -16,7 +16,6 @@
package com.gitblit.tickets;
import java.io.IOException;
-import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -169,20 +168,19 @@ public class BranchTicketService extends ITicketService implements RefsChangedLi
if (!ids.contains(ticketId)) {
ids.add(ticketId);
TicketModel ticket = getTicket(repository, ticketId);
- log.info(MessageFormat.format("indexing ticket #{0,number,0}: {1}",
- ticketId, ticket.title));
+ log.info("indexing ticket #{}: {}", ticketId, ticket.title);
indexer.index(ticket);
}
}
long end = System.nanoTime();
- log.info("incremental indexing of {0} ticket(s) completed in {1} msecs",
+ log.info("incremental indexing of {} ticket(s) completed in {} msecs",
ids.size(), TimeUnit.NANOSECONDS.toMillis(end - start));
} finally {
db.close();
}
break;
default:
- log.warn("Unexpected receive type {} in BranchTicketService.onRefsChanged" + cmd.getType());
+ log.warn("Unexpected receive type {} in BranchTicketService.onRefsChanged", cmd.getType());
break;
}
} catch (Exception e) {
@@ -216,10 +214,10 @@ public class BranchTicketService extends ITicketService implements RefsChangedLi
Result res = cmd.rename();
switch (res) {
case RENAMED:
- log.info(db.getDirectory() + " " + cmd.getRefLogMessage());
+ log.info("{} {}", db.getDirectory(), cmd.getRefLogMessage());
return getTicketsBranch(db);
default:
- log.error("failed to rename " + oldRef.getName() + " => " + BRANCH + " (" + res.name() + ")");
+ log.error("failed to rename {} => {} ({})", oldRef.getName(), BRANCH, res.name());
}
} catch (IOException e) {
log.error("failed to rename tickets branch", e);
@@ -288,7 +286,7 @@ public class BranchTicketService extends ITicketService implements RefsChangedLi
return JGitUtils.getStringContent(db, tree, file, Constants.ENCODING);
}
} catch (IOException e) {
- log.error("failed to read " + file, e);
+ log.error("failed to read {}", file, e);
} finally {
if (rw != null) {
rw.close();
@@ -506,8 +504,7 @@ public class BranchTicketService extends ITicketService implements RefsChangedLi
}
}
} catch (Exception e) {
- log.error("failed to deserialize {}/{}\n{}",
- new Object [] { repository, path.path, e.getMessage()});
+ log.error("failed to deserialize {}/{}\n{}", repository, path.path, e.getMessage());
log.error(null, e);
}
}
@@ -701,8 +698,7 @@ public class BranchTicketService extends ITicketService implements RefsChangedLi
success = commitIndex(db, index, deletedBy, "- " + ticket.number);
} catch (Throwable t) {
- log.error(MessageFormat.format("Failed to delete ticket {0,number,0} from {1}",
- ticket.number, db.getDirectory()), t);
+ log.error("Failed to delete ticket {} from {}", ticket.number, db.getDirectory(), t);
} finally {
// release the treewalk
if (treeWalk != null) {
@@ -733,8 +729,7 @@ public class BranchTicketService extends ITicketService implements RefsChangedLi
success = commitIndex(db, index, change.author, "#" + ticketId);
} catch (Throwable t) {
- log.error(MessageFormat.format("Failed to commit ticket {0,number,0} to {1}",
- ticketId, db.getDirectory()), t);
+ log.error("Failed to commit ticket {} to {}", ticketId, db.getDirectory(), t);
} finally {
db.close();
}
diff --git a/src/main/java/com/gitblit/tickets/FileTicketService.java b/src/main/java/com/gitblit/tickets/FileTicketService.java
index 05670468..5b45547d 100644
--- a/src/main/java/com/gitblit/tickets/FileTicketService.java
+++ b/src/main/java/com/gitblit/tickets/FileTicketService.java
@@ -17,7 +17,6 @@ package com.gitblit.tickets;
import java.io.File;
import java.io.IOException;
-import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -274,8 +273,7 @@ public class FileTicketService extends ITicketService {
}
}
} catch (Exception e) {
- log.error("failed to deserialize {}/{}\n{}",
- new Object [] { repository, journal, e.getMessage()});
+ log.error("failed to deserialize {}/{}\n{}", repository, journal, e.getMessage());
log.error(null, e);
}
}
@@ -481,8 +479,7 @@ public class FileTicketService extends ITicketService {
FileUtils.writeContent(file, journal);
success = true;
} catch (Throwable t) {
- log.error(MessageFormat.format("Failed to commit ticket {0,number,0} to {1}",
- ticketId, db.getDirectory()), t);
+ log.error("Failed to commit ticket {} to {}", ticketId, db.getDirectory(), t);
} finally {
db.close();
}
diff --git a/src/main/java/com/gitblit/tickets/ITicketService.java b/src/main/java/com/gitblit/tickets/ITicketService.java
index 3252a603..6ab87aeb 100644
--- a/src/main/java/com/gitblit/tickets/ITicketService.java
+++ b/src/main/java/com/gitblit/tickets/ITicketService.java
@@ -363,7 +363,7 @@ public abstract class ITicketService implements IManager {
}
labelsCache.put(key, Collections.unmodifiableList(list));
} catch (Exception e) {
- log.error("invalid tickets settings for " + repository, e);
+ log.error("invalid tickets settings for {}", repository, e);
} finally {
db.close();
}
@@ -408,7 +408,7 @@ public abstract class ITicketService implements IManager {
config.setString(LABEL, label, COLOR, lb.color);
config.save();
} catch (IOException e) {
- log.error("failed to create label " + label + " in " + repository, e);
+ log.error("failed to create label {} in {}", label, repository, e);
} finally {
if (db != null) {
db.close();
@@ -436,7 +436,7 @@ public abstract class ITicketService implements IManager {
return true;
} catch (IOException e) {
- log.error("failed to update label " + label + " in " + repository, e);
+ log.error("failed to update label {} in {}", label, repository, e);
} finally {
if (db != null) {
db.close();
@@ -477,7 +477,7 @@ public abstract class ITicketService implements IManager {
return true;
} catch (IOException e) {
- log.error("failed to rename label " + oldName + " in " + repository, e);
+ log.error("failed to rename label {} in {}", oldName, repository, e);
} finally {
if (db != null) {
db.close();
@@ -508,7 +508,7 @@ public abstract class ITicketService implements IManager {
return true;
} catch (IOException e) {
- log.error("failed to delete label " + label + " in " + repository, e);
+ log.error("failed to delete label {} in {}", label, repository, e);
} finally {
if (db != null) {
db.close();
@@ -543,15 +543,14 @@ public abstract class ITicketService implements IManager {
try {
milestone.due = new SimpleDateFormat(DUE_DATE_PATTERN).parse(due);
} catch (ParseException e) {
- log.error("failed to parse {} milestone {} due date \"{}\"",
- new Object [] { repository, name, due });
+ log.error("failed to parse {} milestone {} due date \"{}\"", repository, name, due, e);
}
}
list.add(milestone);
}
milestonesCache.put(key, Collections.unmodifiableList(list));
} catch (Exception e) {
- log.error("invalid tickets settings for " + repository, e);
+ log.error("invalid tickets settings for {}", repository, e);
} finally {
db.close();
}
@@ -617,7 +616,7 @@ public abstract class ITicketService implements IManager {
milestonesCache.remove(repository.name);
} catch (IOException e) {
- log.error("failed to create milestone " + milestone + " in " + repository, e);
+ log.error("failed to create milestone {} in {}", milestone, repository, e);
} finally {
if (db != null) {
db.close();
@@ -651,7 +650,7 @@ public abstract class ITicketService implements IManager {
milestonesCache.remove(repository.name);
return true;
} catch (IOException e) {
- log.error("failed to update milestone " + milestone + " in " + repository, e);
+ log.error("failed to update milestone {} in {}", milestone, repository, e);
} finally {
if (db != null) {
db.close();
@@ -724,7 +723,7 @@ public abstract class ITicketService implements IManager {
return true;
} catch (IOException e) {
- log.error("failed to rename milestone " + oldName + " in " + repository, e);
+ log.error("failed to rename milestone {} in {}", oldName, repository, e);
} finally {
if (db != null) {
db.close();
@@ -788,7 +787,7 @@ public abstract class ITicketService implements IManager {
}
return true;
} catch (IOException e) {
- log.error("failed to delete milestone " + milestone + " in " + repository, e);
+ log.error("failed to delete milestone {} in {}", milestone, repository, e);
} finally {
if (db != null) {
db.close();
@@ -1219,8 +1218,7 @@ public abstract class ITicketService implements IManager {
TicketModel ticket = getTicket(repository, ticketId);
boolean success = deleteTicketImpl(repository, ticket, deletedBy);
if (success) {
- log.info(MessageFormat.format("Deleted {0} ticket #{1,number,0}: {2}",
- repository.name, ticketId, ticket.title));
+ log.info("Deleted {} ticket #{}: {}", repository.name, ticketId, ticket.title);
ticketsCache.invalidate(new TicketKey(repository, ticketId));
indexer.delete(ticket);
return true;
diff --git a/src/main/java/com/gitblit/tickets/RedisTicketService.java b/src/main/java/com/gitblit/tickets/RedisTicketService.java
index 4e632317..ae4fffef 100644
--- a/src/main/java/com/gitblit/tickets/RedisTicketService.java
+++ b/src/main/java/com/gitblit/tickets/RedisTicketService.java
@@ -181,7 +181,7 @@ public class RedisTicketService extends ITicketService {
Boolean exists = jedis.exists(key(repository, KeyType.journal, ticketId));
return exists != null && exists;
} catch (JedisException e) {
- log.error("failed to check hasTicket from Redis @ " + getUrl(), e);
+ log.error("failed to check hasTicket from Redis @ {}", getUrl(), e);
pool.returnBrokenResource(jedis);
jedis = null;
} finally {
@@ -205,7 +205,7 @@ public class RedisTicketService extends ITicketService {
ids.add(ticketId);
}
} catch (JedisException e) {
- log.error("failed to assign new ticket id in Redis @ " + getUrl(), e);
+ log.error("failed to assign new ticket id in Redis @ {}", getUrl(), e);
pool.returnBrokenResource(jedis);
jedis = null;
} finally {
@@ -241,7 +241,7 @@ public class RedisTicketService extends ITicketService {
long ticketNumber = jedis.incr(key);
return ticketNumber;
} catch (JedisException e) {
- log.error("failed to assign new ticket id in Redis @ " + getUrl(), e);
+ log.error("failed to assign new ticket id in Redis @ {}", getUrl(), e);
pool.returnBrokenResource(jedis);
jedis = null;
} finally {
@@ -300,7 +300,7 @@ public class RedisTicketService extends ITicketService {
// sort the tickets by creation
Collections.sort(list);
} catch (JedisException e) {
- log.error("failed to retrieve tickets from Redis @ " + getUrl(), e);
+ log.error("failed to retrieve tickets from Redis @ {}", getUrl(), e);
pool.returnBrokenResource(jedis);
jedis = null;
} finally {
@@ -338,7 +338,7 @@ public class RedisTicketService extends ITicketService {
log.debug("rebuilt ticket {} from Redis @ {}", ticketId, getUrl());
return ticket;
} catch (JedisException e) {
- log.error("failed to retrieve ticket from Redis @ " + getUrl(), e);
+ log.error("failed to retrieve ticket from Redis @ {}", getUrl(), e);
pool.returnBrokenResource(jedis);
jedis = null;
} finally {
@@ -371,7 +371,7 @@ public class RedisTicketService extends ITicketService {
}
return changes;
} catch (JedisException e) {
- log.error("failed to retrieve journal from Redis @ " + getUrl(), e);
+ log.error("failed to retrieve journal from Redis @ {}", getUrl(), e);
pool.returnBrokenResource(jedis);
jedis = null;
} finally {
@@ -454,9 +454,9 @@ public class RedisTicketService extends ITicketService {
t.exec();
success = true;
- log.debug("deleted ticket {} from Redis @ {}", "" + ticket.number, getUrl());
+ log.debug("deleted ticket {} from Redis @ {}", ticket.number, getUrl());
} catch (JedisException e) {
- log.error("failed to delete ticket from Redis @ " + getUrl(), e);
+ log.error("failed to delete ticket from Redis @ {}", getUrl(), e);
pool.returnBrokenResource(jedis);
jedis = null;
} finally {
@@ -497,10 +497,10 @@ public class RedisTicketService extends ITicketService {
t.rpush(key(repository, KeyType.journal, ticketId), journal);
t.exec();
- log.debug("updated ticket {} in Redis @ {}", "" + ticketId, getUrl());
+ log.debug("updated ticket {} in Redis @ {}", ticketId, getUrl());
return true;
} catch (JedisException e) {
- log.error("failed to update ticket cache in Redis @ " + getUrl(), e);
+ log.error("failed to update ticket cache in Redis @ {}", getUrl(), e);
pool.returnBrokenResource(jedis);
jedis = null;
} finally {
@@ -532,7 +532,7 @@ public class RedisTicketService extends ITicketService {
}
success = true;
} catch (JedisException e) {
- log.error("failed to delete all tickets in Redis @ " + getUrl(), e);
+ log.error("failed to delete all tickets in Redis @ {}", getUrl(), e);
pool.returnBrokenResource(jedis);
jedis = null;
} finally {
@@ -561,7 +561,7 @@ public class RedisTicketService extends ITicketService {
t.exec();
success = true;
} catch (JedisException e) {
- log.error("failed to rename tickets in Redis @ " + getUrl(), e);
+ log.error("failed to rename tickets in Redis @ {}", getUrl(), e);
pool.returnBrokenResource(jedis);
jedis = null;
} finally {
diff --git a/src/main/java/com/gitblit/tickets/TicketIndexer.java b/src/main/java/com/gitblit/tickets/TicketIndexer.java
index 7c164487..09da1177 100644
--- a/src/main/java/com/gitblit/tickets/TicketIndexer.java
+++ b/src/main/java/com/gitblit/tickets/TicketIndexer.java
@@ -17,7 +17,6 @@ package com.gitblit.tickets;
import java.io.File;
import java.io.IOException;
-import java.text.MessageFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collections;
@@ -214,10 +213,10 @@ public class TicketIndexer {
closeSearcher();
int numDocsAfter = writer.numDocs();
if (numDocsBefore == numDocsAfter) {
- log.debug(MessageFormat.format("no records found to delete in {0}", repository));
+ log.debug("no records found to delete in {}", repository);
return false;
} else {
- log.debug(MessageFormat.format("deleted {0} records in {1}", numDocsBefore - numDocsAfter, repository));
+ log.debug("deleted {} records in {}", numDocsBefore - numDocsAfter, repository);
return true;
}
} catch (Exception e) {
@@ -287,7 +286,7 @@ public class TicketIndexer {
IndexWriter writer = getWriter();
return delete(ticket.repository, ticket.number, writer);
} catch (Exception e) {
- log.error("Failed to delete ticket " + ticket.number, e);
+ log.error("Failed to delete ticket {}", ticket.number, e);
}
return false;
}
@@ -311,10 +310,10 @@ public class TicketIndexer {
closeSearcher();
int numDocsAfter = writer.numDocs();
if (numDocsBefore == numDocsAfter) {
- log.debug(MessageFormat.format("no records found to delete in {0}", repository));
+ log.debug("no records found to delete in {}", repository);
return false;
} else {
- log.debug(MessageFormat.format("deleted {0} records in {1}", numDocsBefore - numDocsAfter, repository));
+ log.debug("deleted {} records in {}", numDocsBefore - numDocsAfter, repository);
return true;
}
}
@@ -383,7 +382,7 @@ public class TicketIndexer {
results.add(result);
}
} catch (Exception e) {
- log.error(MessageFormat.format("Exception while searching for {0}", text), e);
+ log.error("Exception while searching for {}", text, e);
}
return new ArrayList<QueryResult>(results);
}
@@ -435,7 +434,7 @@ public class TicketIndexer {
results.add(result);
}
} catch (Exception e) {
- log.error(MessageFormat.format("Exception while searching for {0}", queryText), e);
+ log.error("Exception while searching for {}", queryText, e);
}
return new ArrayList<QueryResult>(results);
}
diff --git a/src/main/java/com/gitblit/tickets/TicketNotifier.java b/src/main/java/com/gitblit/tickets/TicketNotifier.java
index b913db25..f284e7be 100644
--- a/src/main/java/com/gitblit/tickets/TicketNotifier.java
+++ b/src/main/java/com/gitblit/tickets/TicketNotifier.java
@@ -34,10 +34,10 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.io.IOUtils;
-import org.apache.log4j.Logger;
import org.eclipse.jgit.diff.DiffEntry.ChangeType;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
+import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.gitblit.Constants;
@@ -96,6 +96,8 @@ public class TicketNotifier {
private final String addPattern = "<span style=\"color:darkgreen;\">+{0}</span>";
private final String delPattern = "<span style=\"color:darkred;\">-{0}</span>";
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
public TicketNotifier(
IRuntimeManager runtimeManager,
INotificationManager notificationManager,
@@ -152,7 +154,7 @@ public class TicketNotifier {
return mailing;
} catch (Exception e) {
- Logger.getLogger(getClass()).error("failed to queue mailing for #" + ticket.number, e);
+ log.error("failed to queue mailing for #{}", ticket.number, e);
}
return null;
}
@@ -203,7 +205,7 @@ public class TicketNotifier {
diffstat = DiffUtils.getDiffStat(repo, base, patchset.tip);
commits = JGitUtils.getRevLog(repo, base, patchset.tip);
} catch (Exception e) {
- Logger.getLogger(getClass()).error("failed to get changed paths", e);
+ log.error("failed to get changed paths", e);
} finally {
if (repo != null) {
repo.close();
@@ -552,9 +554,7 @@ public class TicketNotifier {
if (user.canView(repository)) {
toAddresses.add(user.emailAddress);
} else {
- LoggerFactory.getLogger(getClass()).warn(
- MessageFormat.format("ticket {0}-{1,number,0}: {2} can not receive notification",
- repository.name, ticket.number, user.username));
+ log.warn("ticket {}-{}: {} can not receive notification", repository.name, ticket.number, user.username);
}
}
}
@@ -594,9 +594,7 @@ public class TicketNotifier {
if (user.canView(repository)) {
ccAddresses.add(user.emailAddress);
} else {
- LoggerFactory.getLogger(getClass()).warn(
- MessageFormat.format("ticket {0}-{1,number,0}: {2} can not receive notification",
- repository.name, ticket.number, user.username));
+ log.warn("ticket {}-{}: {} can not receive notification", repository.name, ticket.number, user.username);
}
}
}