Corrected remoteAddr to localName.

This commit is contained in:
Winston Li 2014-11-16 21:00:57 +00:00
parent db2bf43aa7
commit 06a7ee6614
7 changed files with 13 additions and 13 deletions

View file

@ -25,7 +25,7 @@ public class SnapshotPushPostbackHandler extends AbstractHandler {
} }
System.out.println(request.getRemoteAddr()); System.out.println(request.getRemoteAddr());
System.out.println(request.getLocalAddr()); System.out.println(request.getLocalName());
System.out.println("method: " + request.getMethod()); System.out.println("method: " + request.getMethod());
System.out.println("pathInfo: " + request.getPathInfo()); System.out.println("pathInfo: " + request.getPathInfo());
System.out.println("contextPath: " + request.getContextPath()); System.out.println("contextPath: " + request.getContextPath());

View file

@ -15,7 +15,7 @@ public interface WriteLatexDataSource {
/* Called by request thread. */ /* Called by request thread. */
public boolean repositoryExists(String projectName) throws FailedConnectionException; public boolean repositoryExists(String projectName) throws FailedConnectionException;
public List<WritableRepositoryContents> getWritableRepositories(String projectName) throws FailedConnectionException, InvalidProjectException; public List<WritableRepositoryContents> getWritableRepositories(String projectName) throws FailedConnectionException, InvalidProjectException;
public void putDirectoryContentsToProjectWithName(String projectName, RawDirectoryContents directoryContents, String remoteAddr) throws SnapshotPostException, IOException, FailedConnectionException; public void putDirectoryContentsToProjectWithName(String projectName, RawDirectoryContents directoryContents, String hostname) throws SnapshotPostException, IOException, FailedConnectionException;
public void expectPostback(String projectName); public void expectPostback(String projectName);
/* Called by postback thread. */ /* Called by postback thread. */

View file

@ -25,7 +25,7 @@ public class WLReceivePackFactory implements ReceivePackFactory<HttpServletReque
@Override @Override
public ReceivePack create(HttpServletRequest httpServletRequest, Repository repository) throws ServiceNotEnabledException, ServiceNotAuthorizedException { public ReceivePack create(HttpServletRequest httpServletRequest, Repository repository) throws ServiceNotEnabledException, ServiceNotAuthorizedException {
ReceivePack receivePack = new ReceivePack(repository); ReceivePack receivePack = new ReceivePack(repository);
receivePack.setPreReceiveHook(new WriteLatexPutHook(writeLatexDataSource, httpServletRequest.getRemoteAddr())); receivePack.setPreReceiveHook(new WriteLatexPutHook(writeLatexDataSource, httpServletRequest.getLocalName()));
return receivePack; return receivePack;
} }

View file

@ -22,11 +22,11 @@ import java.util.Collection;
public class WriteLatexPutHook implements PreReceiveHook { public class WriteLatexPutHook implements PreReceiveHook {
private final WriteLatexDataSource writeLatexDataSource; private final WriteLatexDataSource writeLatexDataSource;
private final String remoteAddr; private final String hostname;
public WriteLatexPutHook(WriteLatexDataSource writeLatexDataSource, String remoteAddr) { public WriteLatexPutHook(WriteLatexDataSource writeLatexDataSource, String hostname) {
this.writeLatexDataSource = writeLatexDataSource; this.writeLatexDataSource = writeLatexDataSource;
this.remoteAddr = remoteAddr; this.hostname = hostname;
} }
@Override @Override
@ -58,7 +58,7 @@ public class WriteLatexPutHook implements PreReceiveHook {
writeLatexDataSource.putDirectoryContentsToProjectWithName(repository.getWorkTree().getName(), writeLatexDataSource.putDirectoryContentsToProjectWithName(repository.getWorkTree().getName(),
getPushedDirectoryContents(repository, getPushedDirectoryContents(repository,
receiveCommand), receiveCommand),
remoteAddr); hostname);
} }
private void checkForcedPush(ReceiveCommand receiveCommand) throws ForcedPushException { private void checkForcedPush(ReceiveCommand receiveCommand) throws ForcedPushException {

View file

@ -20,10 +20,10 @@ public class WLDirectoryNodeSnapshot implements CandidateSnapshot {
private final WLDirectoryNode directoryNode; private final WLDirectoryNode directoryNode;
private final CandidateSnapshotCallback callback; private final CandidateSnapshotCallback callback;
public WLDirectoryNodeSnapshot(WLProject project, WLDirectoryNode directoryNode, String remoteAddr, CandidateSnapshotCallback callback) { public WLDirectoryNodeSnapshot(WLProject project, WLDirectoryNode directoryNode, String hostname, CandidateSnapshotCallback callback) {
previousVersionID = project.getLatestSnapshot().getVersionID(); previousVersionID = project.getLatestSnapshot().getVersionID();
projectName = project.getName(); projectName = project.getName();
projectURL = "http://" + remoteAddr + "/" + projectName; projectURL = "http://" + hostname + "/" + projectName;
this.directoryNode = directoryNode; this.directoryNode = directoryNode;
this.callback = callback; this.callback = callback;
System.out.println(getJsonRepresentation()); System.out.println(getJsonRepresentation());

View file

@ -43,8 +43,8 @@ public class WriteLatexAPI implements WriteLatexDataSource {
} }
@Override @Override
public void putDirectoryContentsToProjectWithName(String projectName, RawDirectoryContents directoryContents, String remoteAddr) throws SnapshotPostException, IOException, FailedConnectionException { public void putDirectoryContentsToProjectWithName(String projectName, RawDirectoryContents directoryContents, String hostname) throws SnapshotPostException, IOException, FailedConnectionException {
CandidateSnapshot candidate = dataModel.createCandidateSnapshotFromProjectWithContents(projectName, directoryContents, remoteAddr); CandidateSnapshot candidate = dataModel.createCandidateSnapshotFromProjectWithContents(projectName, directoryContents, hostname);
new SnapshotPushRequest(candidate).request(); new SnapshotPushRequest(candidate).request();
throw new SnapshotPostException() { throw new SnapshotPostException() {

View file

@ -43,11 +43,11 @@ public class WLDataModel implements CandidateSnapshotCallback {
return project; return project;
} }
public CandidateSnapshot createCandidateSnapshotFromProjectWithContents(String projectName, RawDirectoryContents directoryContents, String remoteAddr) throws SnapshotPostException, IOException, FailedConnectionException { public CandidateSnapshot createCandidateSnapshotFromProjectWithContents(String projectName, RawDirectoryContents directoryContents, String hostname) throws SnapshotPostException, IOException, FailedConnectionException {
return new WLDirectoryNodeSnapshot(getProjectWithName(projectName), return new WLDirectoryNodeSnapshot(getProjectWithName(projectName),
fileStore.createNextDirectoryNodeInProjectFromContents(getProjectWithName(projectName), fileStore.createNextDirectoryNodeInProjectFromContents(getProjectWithName(projectName),
directoryContents), directoryContents),
remoteAddr, hostname,
this); this);
} }