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.getLocalAddr());
System.out.println(request.getLocalName());
System.out.println("method: " + request.getMethod());
System.out.println("pathInfo: " + request.getPathInfo());
System.out.println("contextPath: " + request.getContextPath());

View file

@ -15,7 +15,7 @@ public interface WriteLatexDataSource {
/* Called by request thread. */
public boolean repositoryExists(String projectName) throws FailedConnectionException;
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);
/* Called by postback thread. */

View file

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

View file

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

View file

@ -20,10 +20,10 @@ public class WLDirectoryNodeSnapshot implements CandidateSnapshot {
private final WLDirectoryNode directoryNode;
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();
projectName = project.getName();
projectURL = "http://" + remoteAddr + "/" + projectName;
projectURL = "http://" + hostname + "/" + projectName;
this.directoryNode = directoryNode;
this.callback = callback;
System.out.println(getJsonRepresentation());

View file

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

View file

@ -43,11 +43,11 @@ public class WLDataModel implements CandidateSnapshotCallback {
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),
fileStore.createNextDirectoryNodeInProjectFromContents(getProjectWithName(projectName),
directoryContents),
remoteAddr,
hostname,
this);
}