[hg] main-silver: wrong return type in RepositoryQueryImplementa...

  • From: Tomas Stupka < >
  • To:
  • Subject: [hg] main-silver: wrong return type in RepositoryQueryImplementa...
  • Date: Fri, 11 Oct 2013 11:22:38 -0700

changeset 51764b3e5449 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/51764b3e5449
description:
        wrong return type in RepositoryQueryImplementation

diffstat:

 
bugtracking/src/org/netbeans/modules/bugtracking/BugtrackingRepositoryOwnerImpl.java
    |  26 ---------
 bugtracking/src/org/netbeans/modules/bugtracking/api/RepositoryQuery.java    
           |  27 ++++++++-
 
bugtracking/src/org/netbeans/modules/bugtracking/spi/RepositoryQueryImplementation.java
 |  11 +--
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/RepositoryQueryTest.java
 |   6 +-
 4 files changed, 29 insertions(+), 41 deletions(-)

diffs (135 lines):

diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/BugtrackingRepositoryOwnerImpl.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/BugtrackingRepositoryOwnerImpl.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/BugtrackingRepositoryOwnerImpl.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/BugtrackingRepositoryOwnerImpl.java
@@ -41,29 +41,3 @@
  */
 package org.netbeans.modules.bugtracking;
 
-import java.io.File;
-import org.netbeans.modules.bugtracking.api.Repository;
-import org.netbeans.modules.bugtracking.spi.RepositoryQueryImplementation;
-import org.netbeans.modules.bugtracking.util.BugtrackingOwnerSupport;
-import org.openide.filesystems.FileObject;
-import org.openide.filesystems.FileUtil;
-import org.openide.util.lookup.ServiceProvider;
-
-/**
- *
- * @author tomas
- */
-@org.openide.util.lookup.ServiceProviders({@ServiceProvider(service=org.netbeans.modules.bugtracking.spi.RepositoryQueryImplementation.class)})
-public class BugtrackingRepositoryOwnerImpl implements 
RepositoryQueryImplementation {
-
-    @Override
-    public Repository getRepository(FileObject fileObject, boolean 
askIfUnknown) {
-        File file = FileUtil.toFile(fileObject);
-        if(file == null) {
-            return null;
-        }
-        RepositoryImpl impl = 
BugtrackingOwnerSupport.getInstance().getRepository(file, askIfUnknown);
-        return impl != null ? impl.getRepository() : null;
-    }
-
-}
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/api/RepositoryQuery.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/api/RepositoryQuery.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/api/RepositoryQuery.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/api/RepositoryQuery.java
@@ -41,9 +41,14 @@
  */
 package org.netbeans.modules.bugtracking.api;
 
+import java.io.File;
 import java.util.Collection;
+import org.netbeans.modules.bugtracking.RepositoryImpl;
+import org.netbeans.modules.bugtracking.RepositoryRegistry;
 import org.netbeans.modules.bugtracking.spi.RepositoryQueryImplementation;
+import org.netbeans.modules.bugtracking.BugtrackingOwnerSupport;
 import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
 import org.openide.util.Lookup;
 
 
@@ -69,12 +74,17 @@
         }
         Collection<? extends RepositoryQueryImplementation> impls = 
getImplementations();
         for (RepositoryQueryImplementation repositoryOwnerQuery : impls) {
-            Repository repo = repositoryOwnerQuery.getRepository(fileObject, 
askIfUnknown);
-            if(repo != null) {
-                return repo;
+            String url = repositoryOwnerQuery.getRepositoryUrl(fileObject);
+            if(url != null) {
+                Collection<RepositoryImpl> repos = 
RepositoryRegistry.getInstance().getKnownRepositories(false);
+                for (RepositoryImpl r : repos) {
+                    if(r.getUrl().equals(url)) {
+                        return r.getRepository();
             }
         }
-        return null;
+            }
+        }
+        return getRepositoryIntern(fileObject, askIfUnknown);
     }
 
     private Collection<? extends RepositoryQueryImplementation> 
getImplementations() {
@@ -82,4 +92,13 @@
         return result;
     }
     
+    private Repository getRepositoryIntern(FileObject fileObject, boolean 
askIfUnknown) {
+        File file = FileUtil.toFile(fileObject);
+        if(file == null) {
+            return null;
 }
+        RepositoryImpl impl = 
BugtrackingOwnerSupport.getInstance().getRepository(file, askIfUnknown);
+        return impl != null ? impl.getRepository() : null;
+    }
+    
+}
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/spi/RepositoryQueryImplementation.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/spi/RepositoryQueryImplementation.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/spi/RepositoryQueryImplementation.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/spi/RepositoryQueryImplementation.java
@@ -55,15 +55,10 @@
 public interface RepositoryQueryImplementation {
     
     /**
-     * Determines the remote bugtracking repository. 
+     * Determines the remote bugtracking repository url. 
      * 
      * @param fileObject
-     * @param askIfUnknown
-     * @return 
-     * 
-     * XXX change return type to url and get rid of askifunknown as that is 
-     * interesting only for the default impl and RepositoryQuery in the API 
...
-     * 
+     * @return the remote repository url or null if not available
      */
-    public Repository getRepository(FileObject fileObject, boolean 
askIfUnknown);
+    public String getRepositoryUrl(FileObject fileObject);
 }
diff --git 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/RepositoryQueryTest.java
 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/RepositoryQueryTest.java
--- 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/RepositoryQueryTest.java
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/RepositoryQueryTest.java
@@ -47,7 +47,7 @@
 import java.util.logging.Level;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.modules.bugtracking.spi.RepositoryQueryImplementation;
-import org.netbeans.modules.bugtracking.util.BugtrackingOwnerSupport;
+import org.netbeans.modules.bugtracking.BugtrackingOwnerSupport;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileUtil;
 import org.openide.util.test.MockLookup;
@@ -118,11 +118,11 @@
     @org.openide.util.lookup.ServiceProvider(service = 
org.netbeans.modules.bugtracking.spi.RepositoryQueryImplementation.class)
     public static class RepositoryQImpl implements 
RepositoryQueryImplementation {
         @Override
-        public Repository getRepository(FileObject fileObject, boolean 
askIfUnknown) {
+        public String getRepositoryUrl(FileObject fileObject) {
             if(fileObject.getName().endsWith("norepo")) {
                 return null;
             }
-            return APITestKit.getRepo(APITestRepository.ID);
+            return APITestKit.getRepo(APITestRepository.ID).getUrl();
         }
     }
     

[hg] main-silver: wrong return type in RepositoryQueryImplementa...

Tomas Stupka 10/11/2013

Project Features

About this Project

ConnectedDeveloper was started in November 2009, is owned by tpavek, and has 66 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close