Просмотр исходного кода

Rename DisabledRepositoryException to MissingRepositoryException

Michael Walker 8 лет назад
Родитель
Сommit
6ae6acd826

+ 5 - 5
services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/Bridge.java

@@ -35,7 +35,7 @@ import uk.ac.ic.wlgitbridge.git.handler.hook.WriteLatexPutHook;
 import uk.ac.ic.wlgitbridge.server.FileHandler;
 import uk.ac.ic.wlgitbridge.server.FileHandler;
 import uk.ac.ic.wlgitbridge.server.PostbackContents;
 import uk.ac.ic.wlgitbridge.server.PostbackContents;
 import uk.ac.ic.wlgitbridge.server.PostbackHandler;
 import uk.ac.ic.wlgitbridge.server.PostbackHandler;
-import uk.ac.ic.wlgitbridge.snapshot.base.DisabledRepositoryException;
+import uk.ac.ic.wlgitbridge.snapshot.base.MissingRepositoryException;
 import uk.ac.ic.wlgitbridge.snapshot.base.ForbiddenException;
 import uk.ac.ic.wlgitbridge.snapshot.base.ForbiddenException;
 import uk.ac.ic.wlgitbridge.snapshot.getforversion.SnapshotAttachment;
 import uk.ac.ic.wlgitbridge.snapshot.getforversion.SnapshotAttachment;
 import uk.ac.ic.wlgitbridge.snapshot.push.PostbackManager;
 import uk.ac.ic.wlgitbridge.snapshot.push.PostbackManager;
@@ -384,7 +384,7 @@ public class Bridge {
      * @param hostname
      * @param hostname
      * @throws SnapshotPostException
      * @throws SnapshotPostException
      * @throws IOException
      * @throws IOException
-     * @throws DisabledRepositoryException
+     * @throws MissingRepositoryException
      * @throws ForbiddenException
      * @throws ForbiddenException
      */
      */
     public void push(
     public void push(
@@ -393,7 +393,7 @@ public class Bridge {
             RawDirectory directoryContents,
             RawDirectory directoryContents,
             RawDirectory oldDirectoryContents,
             RawDirectory oldDirectoryContents,
             String hostname
             String hostname
-    ) throws SnapshotPostException, IOException, DisabledRepositoryException, ForbiddenException {
+    ) throws SnapshotPostException, IOException, MissingRepositoryException, ForbiddenException {
         try (LockGuard __ = lock.lockGuard(projectName)) {
         try (LockGuard __ = lock.lockGuard(projectName)) {
             pushCritical(
             pushCritical(
                     oauth2,
                     oauth2,
@@ -462,7 +462,7 @@ public class Bridge {
      * @param directoryContents
      * @param directoryContents
      * @param oldDirectoryContents
      * @param oldDirectoryContents
      * @throws IOException
      * @throws IOException
-     * @throws DisabledRepositoryException
+     * @throws MissingRepositoryException
      * @throws ForbiddenException
      * @throws ForbiddenException
      * @throws SnapshotPostException
      * @throws SnapshotPostException
      */
      */
@@ -471,7 +471,7 @@ public class Bridge {
             String projectName,
             String projectName,
             RawDirectory directoryContents,
             RawDirectory directoryContents,
             RawDirectory oldDirectoryContents
             RawDirectory oldDirectoryContents
-    ) throws IOException, DisabledRepositoryException, ForbiddenException, SnapshotPostException {
+    ) throws IOException, MissingRepositoryException, ForbiddenException, SnapshotPostException {
         Log.info("[{}] Pushing", projectName);
         Log.info("[{}] Pushing", projectName);
         String postbackKey = postbackManager.makeKeyForProject(projectName);
         String postbackKey = postbackManager.makeKeyForProject(projectName);
         Log.info(
         Log.info(

+ 3 - 3
services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/snapshot/SnapshotApi.java

@@ -2,7 +2,7 @@ package uk.ac.ic.wlgitbridge.bridge.snapshot;
 
 
 import com.google.api.client.auth.oauth2.Credential;
 import com.google.api.client.auth.oauth2.Credential;
 import uk.ac.ic.wlgitbridge.data.CandidateSnapshot;
 import uk.ac.ic.wlgitbridge.data.CandidateSnapshot;
-import uk.ac.ic.wlgitbridge.snapshot.base.DisabledRepositoryException;
+import uk.ac.ic.wlgitbridge.snapshot.base.MissingRepositoryException;
 import uk.ac.ic.wlgitbridge.snapshot.base.ForbiddenException;
 import uk.ac.ic.wlgitbridge.snapshot.base.ForbiddenException;
 import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
 import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
 import uk.ac.ic.wlgitbridge.snapshot.getdoc.GetDocResult;
 import uk.ac.ic.wlgitbridge.snapshot.getdoc.GetDocResult;
@@ -34,13 +34,13 @@ public interface SnapshotApi {
             String postbackKey);
             String postbackKey);
 
 
     static <T> T getResult(CompletableFuture<T> result)
     static <T> T getResult(CompletableFuture<T> result)
-            throws DisabledRepositoryException, FailedConnectionException, ForbiddenException {
+            throws MissingRepositoryException, FailedConnectionException, ForbiddenException {
         try {
         try {
             return result.join();
             return result.join();
         } catch (CompletionException e) {
         } catch (CompletionException e) {
             try {
             try {
                 throw e.getCause();
                 throw e.getCause();
-            } catch (DisabledRepositoryException
+            } catch (MissingRepositoryException
                     | FailedConnectionException
                     | FailedConnectionException
                     | ForbiddenException
                     | ForbiddenException
                     | RuntimeException r) {
                     | RuntimeException r) {

+ 2 - 2
services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/snapshot/SnapshotApiFacade.java

@@ -4,7 +4,7 @@ import com.google.api.client.auth.oauth2.Credential;
 import uk.ac.ic.wlgitbridge.data.CandidateSnapshot;
 import uk.ac.ic.wlgitbridge.data.CandidateSnapshot;
 import uk.ac.ic.wlgitbridge.data.model.Snapshot;
 import uk.ac.ic.wlgitbridge.data.model.Snapshot;
 import uk.ac.ic.wlgitbridge.git.exception.GitUserException;
 import uk.ac.ic.wlgitbridge.git.exception.GitUserException;
-import uk.ac.ic.wlgitbridge.snapshot.base.DisabledRepositoryException;
+import uk.ac.ic.wlgitbridge.snapshot.base.MissingRepositoryException;
 import uk.ac.ic.wlgitbridge.snapshot.base.ForbiddenException;
 import uk.ac.ic.wlgitbridge.snapshot.base.ForbiddenException;
 import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
 import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
 import uk.ac.ic.wlgitbridge.snapshot.getdoc.GetDocResult;
 import uk.ac.ic.wlgitbridge.snapshot.getdoc.GetDocResult;
@@ -66,7 +66,7 @@ public class SnapshotApiFacade {
             Optional<Credential> oauth2,
             Optional<Credential> oauth2,
             CandidateSnapshot candidateSnapshot,
             CandidateSnapshot candidateSnapshot,
             String postbackKey
             String postbackKey
-    ) throws DisabledRepositoryException, FailedConnectionException, ForbiddenException {
+    ) throws MissingRepositoryException, FailedConnectionException, ForbiddenException {
         return SnapshotApi.getResult(api.push(
         return SnapshotApi.getResult(api.push(
                 oauth2, candidateSnapshot, postbackKey));
                 oauth2, candidateSnapshot, postbackKey));
     }
     }

+ 5 - 5
services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/Oauth2Filter.java

@@ -6,7 +6,7 @@ import org.apache.commons.codec.binary.Base64;
 import org.eclipse.jetty.server.Request;
 import org.eclipse.jetty.server.Request;
 import uk.ac.ic.wlgitbridge.application.config.Oauth2;
 import uk.ac.ic.wlgitbridge.application.config.Oauth2;
 import uk.ac.ic.wlgitbridge.bridge.snapshot.SnapshotApi;
 import uk.ac.ic.wlgitbridge.bridge.snapshot.SnapshotApi;
-import uk.ac.ic.wlgitbridge.snapshot.base.DisabledRepositoryException;
+import uk.ac.ic.wlgitbridge.snapshot.base.MissingRepositoryException;
 import uk.ac.ic.wlgitbridge.snapshot.base.ForbiddenException;
 import uk.ac.ic.wlgitbridge.snapshot.base.ForbiddenException;
 import uk.ac.ic.wlgitbridge.snapshot.getdoc.GetDocRequest;
 import uk.ac.ic.wlgitbridge.snapshot.getdoc.GetDocRequest;
 import uk.ac.ic.wlgitbridge.util.Instance;
 import uk.ac.ic.wlgitbridge.util.Instance;
@@ -77,8 +77,8 @@ public class Oauth2Filter implements Filter {
                     filterChain
                     filterChain
             );
             );
             return;
             return;
-        } catch (DisabledRepositoryException e) {
-            disabled(project, (HttpServletResponse) servletResponse);
+        } catch (MissingRepositoryException e) {
+            missing(project, (HttpServletResponse) servletResponse);
         }
         }
         Log.info("[{}] Auth not needed", project);
         Log.info("[{}] Auth not needed", project);
         filterChain.doFilter(servletRequest, servletResponse);
         filterChain.doFilter(servletRequest, servletResponse);
@@ -203,11 +203,11 @@ public class Oauth2Filter implements Filter {
         w.close();
         w.close();
     }
     }
 
 
-    private void disabled(
+    private void missing(
             String projectName,
             String projectName,
             HttpServletResponse response
             HttpServletResponse response
     ) throws IOException {
     ) throws IOException {
-        Log.info("[{}] Git access to project disabled.", projectName);
+        Log.info("[{}] Project missing.", projectName);
 
 
         response.setContentType("text/plain");
         response.setContentType("text/plain");
 
 

+ 1 - 1
services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/DisabledRepositoryException.java → services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/MissingRepositoryException.java

@@ -6,7 +6,7 @@ import uk.ac.ic.wlgitbridge.git.exception.SnapshotAPIException;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.List;
 import java.util.List;
 
 
-public class DisabledRepositoryException extends SnapshotAPIException {
+public class MissingRepositoryException extends SnapshotAPIException {
 
 
     @Override
     @Override
     public void fromJSON(JsonElement json) {}
     public void fromJSON(JsonElement json) {}

+ 2 - 2
services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/Request.java

@@ -50,7 +50,7 @@ public abstract class Request<T extends Result> {
         return ret;
         return ret;
     }
     }
 
 
-    private T getResult() throws DisabledRepositoryException, FailedConnectionException, ForbiddenException {
+    private T getResult() throws MissingRepositoryException, FailedConnectionException, ForbiddenException {
         try {
         try {
             HttpResponse response = future.get();
             HttpResponse response = future.get();
             Log.info(
             Log.info(
@@ -75,7 +75,7 @@ public abstract class Request<T extends Result> {
                     case HttpServletResponse.SC_FORBIDDEN:
                     case HttpServletResponse.SC_FORBIDDEN:
                         throw new ForbiddenException();
                         throw new ForbiddenException();
                     case HttpServletResponse.SC_GONE:
                     case HttpServletResponse.SC_GONE:
-                        throw new DisabledRepositoryException();
+                        throw new MissingRepositoryException();
                     default:
                     default:
                         break;
                         break;
                 }
                 }