rename BlamePagingResult to BlameResult

This commit is contained in:
Sebastian Sdorra
2011-09-16 09:05:06 +02:00
parent 0e82fc1ffe
commit 668600b65d
8 changed files with 65 additions and 41 deletions

View File

@@ -52,14 +52,26 @@ import javax.xml.bind.annotation.XmlRootElement;
*/
@XmlRootElement(name = "blame-paging")
@XmlAccessorType(XmlAccessType.FIELD)
public class BlamePagingResult
public class BlameResult
{
/**
* Constructs ...
*
*/
public BlamePagingResult() {}
public BlameResult() {}
/**
* Constructs ...
*
*
* @param blameLines
*/
public BlameResult(List<BlameLine> blameLines)
{
this.blameLines = blameLines;
this.total = blameLines.size();
}
/**
* Constructs ...
@@ -68,7 +80,7 @@ public class BlamePagingResult
* @param total
* @param blameLines
*/
public BlamePagingResult(int total, List<BlameLine> blameLines)
public BlameResult(int total, List<BlameLine> blameLines)
{
this.total = total;
this.blameLines = blameLines;
@@ -87,6 +99,19 @@ public class BlamePagingResult
return blameLines;
}
/**
* Method description
*
*
* @param i
*
* @return
*/
public BlameLine getLine(int i)
{
return blameLines.get(i);
}
/**
* Method description
*

View File

@@ -59,6 +59,6 @@ public interface BlameViewer
* @throws IOException
* @throws RepositoryException
*/
public BlamePagingResult getBlame(String revision, String path)
public BlameResult getBlame(String revision, String path)
throws IOException, RepositoryException;
}

View File

@@ -83,7 +83,7 @@ public class BlameViewerUtil extends CacheClearHook
{
this.repositoryManager = repositoryManager;
this.cache = cacheManager.getCache(BlameViewerCacheKey.class,
BlamePagingResult.class, CACHE_NAME);
BlameResult.class, CACHE_NAME);
init(repositoryManager, cache);
}
@@ -104,7 +104,7 @@ public class BlameViewerUtil extends CacheClearHook
* @throws NotSupportedFeatuerException
* @throws RepositoryException
*/
public BlamePagingResult getBlame(String repositoryId, String revision,
public BlameResult getBlame(String repositoryId, String revision,
String path)
throws RepositoryException, NotSupportedFeatuerException, IOException
{
@@ -136,7 +136,7 @@ public class BlameViewerUtil extends CacheClearHook
* @throws NotSupportedFeatuerException
* @throws RepositoryException
*/
public BlamePagingResult getBlame(Repository repository, String revision,
public BlameResult getBlame(Repository repository, String revision,
String path)
throws RepositoryException, NotSupportedFeatuerException, IOException
{
@@ -153,7 +153,7 @@ public class BlameViewerUtil extends CacheClearHook
BlameViewerCacheKey key = new BlameViewerCacheKey(repository.getId(),
revision, path);
BlamePagingResult result = cache.get(key);
BlameResult result = cache.get(key);
if (result == null)
{
@@ -285,7 +285,7 @@ public class BlameViewerUtil extends CacheClearHook
//~--- fields ---------------------------------------------------------------
/** Field description */
private Cache<BlameViewerCacheKey, BlamePagingResult> cache;
private Cache<BlameViewerCacheKey, BlameResult> cache;
/** Field description */
private RepositoryManager repositoryManager;

View File

@@ -38,6 +38,7 @@ package sonia.scm.repository;
import org.eclipse.jgit.api.BlameCommand;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.blame.BlameResult;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -53,8 +54,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jgit.lib.ObjectId;
import sonia.scm.util.Util;
/**
* Class description
@@ -96,12 +95,12 @@ public class GitBlameViewer implements BlameViewer
* @return
*/
@Override
public BlamePagingResult getBlame(String revision, String path)
public sonia.scm.repository.BlameResult getBlame(String revision, String path)
{
AssertUtil.assertIsNotEmpty(path);
BlameResult blameResult = null;
BlamePagingResult blamePagingResult = null;
BlameResult gitBlameResult = null;
sonia.scm.repository.BlameResult blameResult = null;
org.eclipse.jgit.lib.Repository gr = null;
File directory = handler.getDirectory(repository);
Git git = null;
@@ -112,28 +111,28 @@ public class GitBlameViewer implements BlameViewer
git = new Git(gr);
BlameCommand blame = git.blame();
blame.setFilePath(path);
ObjectId revId = GitUtil.getRevisionId(gr, revision);
blame.setStartCommit(revId);
blameResult = blame.call();
AssertUtil.assertIsNotNull(blameResult);
gitBlameResult = blame.call();
AssertUtil.assertIsNotNull(gitBlameResult);
List<BlameLine> blameLines = new ArrayList<BlameLine>();
int total = blameResult.getResultContents().size();
int total = gitBlameResult.getResultContents().size();
for (int i = 0; i < total; i++)
{
PersonIdent author = blameResult.getSourceAuthor(i);
PersonIdent author = gitBlameResult.getSourceAuthor(i);
BlameLine blameLine = new BlameLine();
blameLine.setLineNumber(i + 1);
blameLine.setAuthor(new Person(author.getName(),
author.getEmailAddress()));
RevCommit commit = blameResult.getSourceCommit(i);
RevCommit commit = gitBlameResult.getSourceCommit(i);
long when = GitUtil.getCommitTime(commit);
blameLine.setWhen(when);
@@ -142,20 +141,20 @@ public class GitBlameViewer implements BlameViewer
blameLine.setRevision(rev);
String content = blameResult.getResultContents().getString(i);
String content = gitBlameResult.getResultContents().getString(i);
blameLine.setCode(content);
blameLines.add(blameLine);
}
blamePagingResult = new BlamePagingResult(total, blameLines);
blameResult = new sonia.scm.repository.BlameResult(total, blameLines);
}
catch (IOException ex)
{
logger.error("could not open repository", ex);
}
return blamePagingResult;
return blameResult;
}
//~--- fields ---------------------------------------------------------------

View File

@@ -118,7 +118,7 @@ public class HgBlameViewer implements BlameViewer
* @throws IOException
*/
@Override
public BlamePagingResult getBlame(String revision, String path)
public BlameResult getBlame(String revision, String path)
throws IOException
{
AssertUtil.assertIsNotEmpty(path);
@@ -146,7 +146,7 @@ public class HgBlameViewer implements BlameViewer
Process p = builder.directory(repositoryDirectory).start();
BufferedReader reader = null;
BlamePagingResult result = null;
BlameResult result = null;
try
{
@@ -173,7 +173,7 @@ public class HgBlameViewer implements BlameViewer
*
* @throws IOException
*/
private BlamePagingResult parseBlameInput(BufferedReader reader)
private BlameResult parseBlameInput(BufferedReader reader)
throws IOException
{
List<BlameLine> blameLines = new ArrayList<BlameLine>();
@@ -191,7 +191,7 @@ public class HgBlameViewer implements BlameViewer
line = reader.readLine();
}
return new BlamePagingResult(blameLines.size(), blameLines);
return new BlameResult(blameLines.size(), blameLines);
}
/**

View File

@@ -95,7 +95,7 @@ public class SvnBlameViewer implements BlameViewer
* @return
*/
@Override
public BlamePagingResult getBlame(String revision, String path)
public BlameResult getBlame(String revision, String path)
{
List<BlameLine> blameLines = new ArrayList<BlameLine>();
File directory = handler.getDirectory(repository);
@@ -130,7 +130,7 @@ public class SvnBlameViewer implements BlameViewer
logger.error("could not create blame view", ex);
}
return new BlamePagingResult(blameLines.size(), blameLines);
return new BlameResult(blameLines.size(), blameLines);
}
//~--- fields ---------------------------------------------------------------

View File

@@ -36,7 +36,7 @@ package sonia.scm.api.rest;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.BlameLine;
import sonia.scm.repository.BlamePagingResult;
import sonia.scm.repository.BlameResult;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
@@ -62,7 +62,7 @@ import javax.ws.rs.ext.Provider;
*/
@Provider
public class PlainBlameProvider
extends AbstractMessageReaderWriterProvider<BlamePagingResult>
extends AbstractMessageReaderWriterProvider<BlameResult>
{
/**
@@ -82,7 +82,7 @@ public class PlainBlameProvider
* @throws WebApplicationException
*/
@Override
public BlamePagingResult readFrom(Class<BlamePagingResult> type,
public BlameResult readFrom(Class<BlameResult> type,
Type genericType, Annotation[] annotations,
MediaType mediaType,
MultivaluedMap<String, String> httpHeaders,
@@ -108,7 +108,7 @@ public class PlainBlameProvider
* @throws WebApplicationException
*/
@Override
public void writeTo(BlamePagingResult bpr, Class<?> type, Type genericType,
public void writeTo(BlameResult bpr, Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
OutputStream entityStream)
@@ -166,7 +166,7 @@ public class PlainBlameProvider
public boolean isWriteable(Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType)
{
return (type == BlamePagingResult.class)
return (type == BlameResult.class)
&& mediaType.equals(MediaType.TEXT_PLAIN_TYPE);
}
}

View File

@@ -44,7 +44,7 @@ import org.slf4j.LoggerFactory;
import sonia.scm.NotSupportedFeatuerException;
import sonia.scm.config.ScmConfiguration;
import sonia.scm.repository.BlamePagingResult;
import sonia.scm.repository.BlameResult;
import sonia.scm.repository.BlameViewerUtil;
import sonia.scm.repository.BrowserResult;
import sonia.scm.repository.ChangesetPagingResult;
@@ -161,7 +161,7 @@ public class RepositoryResource
{
AssertUtil.assertIsNotNull(path);
BlamePagingResult blamePagingResult = blameViewerUtil.getBlame(id,
BlameResult blamePagingResult = blameViewerUtil.getBlame(id,
revision, path);
if (blamePagingResult != null)