[hg] main-silver: moved owner support from public package

  • From: Tomas Stupka < >
  • To:
  • Subject: [hg] main-silver: moved owner support from public package
  • Date: Fri, 11 Oct 2013 11:22:38 -0700

changeset f55a01cd8f42 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/f55a01cd8f42
description:
        moved owner support from public package

diffstat:

 
bugtracking/src/org/netbeans/modules/bugtracking/BugtrackingOwnerSupport.java 
                       |  462 ++++++++++
 
bugtracking/src/org/netbeans/modules/bugtracking/FileToRepoMappingStorage.java
                       |  220 ++++
 bugtracking/src/org/netbeans/modules/bugtracking/ui/issue/IssueAction.java   
                        |    2 +-
 
bugtracking/src/org/netbeans/modules/bugtracking/util/BugtrackingOwnerSupport.java
                   |  460 ---------
 
bugtracking/src/org/netbeans/modules/bugtracking/util/FileToRepoMappingStorage.java
                  |  220 ----
 bugtracking/src/org/netbeans/modules/bugtracking/util/OwnerUtils.java        
                        |    1 +
 
bugtracking/src/org/netbeans/modules/bugtracking/util/RepositoryComboSupport.java
                    |    4 +-
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyBugtrackingOwnerSupport.java
 |    2 +-
 8 files changed, 686 insertions(+), 685 deletions(-)

diffs (1441 lines):

diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/BugtrackingOwnerSupport.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/BugtrackingOwnerSupport.java
new file mode 100644
--- /dev/null
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/BugtrackingOwnerSupport.java
@@ -0,0 +1,462 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2009 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.modules.bugtracking;
+
+import org.netbeans.modules.bugtracking.team.spi.TeamUtil;
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.netbeans.api.queries.VersioningQuery;
+import org.netbeans.modules.bugtracking.APIAccessor;
+import org.netbeans.modules.bugtracking.BugtrackingManager;
+import org.netbeans.modules.bugtracking.DelegatingConnector;
+import org.netbeans.modules.bugtracking.RepositoryImpl;
+import org.netbeans.modules.bugtracking.RepositoryRegistry;
+import org.netbeans.modules.team.ide.spi.ProjectServices;
+import org.netbeans.modules.bugtracking.team.spi.OwnerInfo;
+import 
org.netbeans.modules.bugtracking.ui.selectors.RepositorySelectorBuilder;
+import org.netbeans.modules.bugtracking.util.BugtrackingUtil;
+import org.netbeans.modules.bugtracking.util.NBBugzillaUtils;
+import org.openide.DialogDescriptor;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.loaders.DataObject;
+import org.openide.util.Lookup;
+import org.openide.util.NbBundle;
+import org.openide.windows.TopComponent;
+
+/**
+ *
+ * @author Tomas Stupka
+ * @author Marian Petras
+ */
+public class BugtrackingOwnerSupport {
+
+    private static final Logger LOG = 
Logger.getLogger("org.netbeans.modules.bugtracking.bridge.BugtrackingOwnerSupport");
   // NOI18N
+    
+    private static BugtrackingOwnerSupport instance;
+
+    protected BugtrackingOwnerSupport() { }
+
+    public static BugtrackingOwnerSupport getInstance() {
+        if(instance == null) {
+            instance = 
Lookup.getDefault().lookup(BugtrackingOwnerSupport.class);
+            if (instance == null) {
+                instance = new BugtrackingOwnerSupport();
+            }
+        }
+        return instance;
+    }
+
+    public enum ContextType {
+        MAIN_PROJECT_ONLY,
+        SELECTED_FILE_AND_ALL_PROJECTS,
+    }
+
+    public RepositoryImpl getRepository(FileObject... files) {
+        if (files == null) {
+            return null;
+        }
+        if (files.length == 0) {
+            return null;
+        }
+
+        RepositoryImpl chosenRepo = null;
+        for (FileObject fo : files) {
+            RepositoryImpl repo = getRepository(fo);
+            
+            if (repo == null) {
+                continue;
+            }
+            if (chosenRepo == null) {
+                chosenRepo = repo;
+            } else if (repo != chosenRepo) {    //various repositories 
assigned
+                return null;
+            }
+        }
+        return chosenRepo;
+    }
+
+    public RepositoryImpl getRepository(FileObject fileObject) {
+        RepositoryImpl repo;
+
+        try {
+            repo = getRepositoryIntern(fileObject);
+            if (repo != null) {
+                return repo;
+            }
+        } catch (IOException ex) {
+            return null;
+        }
+
+        File context = getLargerContext(fileObject);
+        if (context != null) {
+            return getRepositoryForContext(context, false);
+        } else {
+            return askUserToSpecifyRepository(null);
+        }
+    }
+
+    public RepositoryImpl getRepository(File file, boolean askIfUnknown) {
+        if(file == null) {
+            if(askIfUnknown) {
+                return askUserToSpecifyRepository(null);
+            } else {
+                return null;
+            }
+        }
+        //TODO - synchronization/threading
+        FileObject fileObject = FileUtil.toFileObject(file);
+        if (fileObject == null) {
+            LOG.log(Level.WARNING, " did not find a FileObject for file 
{0}", new Object[] {file}); //NOI18N
+        } else {
+            try {
+                RepositoryImpl repo = getRepositoryIntern(fileObject);
+                if (repo != null) {
+                    return repo;
+                }
+            } catch (IOException ex) {
+                LOG.log(Level.INFO,
+                      " communication with Team Server failed while loading 
" //NOI18N
+                          + "information about bugtracking repository", 
//NOI18N
+                      ex);
+                return null;
+            }
+        }
+
+        File context = getLargerContext(file, fileObject);
+        if (context == null) {
+            context = file;
+        }
+
+        return getRepositoryForContext(context, askIfUnknown);
+    }
+
+    public void setFirmAssociations(File[] files, RepositoryImpl repository) 
{
+        if (files == null) {
+            throw new IllegalArgumentException("files is null");        
//NOI18N
+        }
+        if (files.length == 0) {
+            return;
+        }
+
+        FileToRepoMappingStorage.getInstance().setFirmAssociation(
+                getLargerContext(files[0]),
+                repository);
+    }
+
+    public void setFirmAssociation(File file, RepositoryImpl repository) {
+        FileToRepoMappingStorage.getInstance().setFirmAssociation(
+                getLargerContext(file),
+                repository);
+    }
+
+    public void setLooseAssociation(ContextType contextType, RepositoryImpl 
repository) {
+        File context = null;
+
+        switch (contextType) {
+            case MAIN_PROJECT_ONLY:
+                FileObject fo = getMainProjectDirectory();
+                if (fo != null) {
+                    context = getLargerContext(fo);
+                }
+                break;
+            case SELECTED_FILE_AND_ALL_PROJECTS:
+                context = getLargerContext();
+                break;
+            default:
+                assert false;
+                break;
+        }
+
+        if (context != null) {
+            FileToRepoMappingStorage.getInstance().setLooseAssociation(
+                    context,
+                    repository);
+        }
+    }
+
+    /**
+     * Returns all repository urls that appear in a <strong>firm</strong> 
association.
+     * @return
+     */
+    public final Collection<String> getAllAssociatedUrls() {
+        return 
FileToRepoMappingStorage.getInstance().getAllFirmlyAssociatedUrls();
+    }
+
+    protected RepositoryImpl getRepositoryForContext(File context, boolean 
askIfUnknown) {
+        RepositoryImpl repo = FileToRepoMappingStorage.getInstance()
+                          .getFirmlyAssociatedRepository(context);
+        if (repo != null) {
+            LOG.log(Level.FINER, 
+                    " found stored repository [{0}] for directory {1}",     
//NOI18N
+                    new Object[]{repo, context});
+            return repo;
+        }
+
+        RepositoryImpl suggestedRepository = 
FileToRepoMappingStorage.getInstance()
+                                         
.getLooselyAssociatedRepository(context);
+        if (!askIfUnknown) {
+            return suggestedRepository;
+        }
+
+        repo = askUserToSpecifyRepository(suggestedRepository);
+        if (repo != null) {
+            return repo;
+        }
+
+        return null;
+    }
+    
+    private static File getLargerContext() {
+        FileObject openFile = getOpenFileObj();
+        if (openFile != null) {
+            File largerContext = getLargerContext(openFile);
+            if (largerContext != null) {
+                return largerContext;
+            }
+        }
+
+        return getContextFromProjects();
+    }
+
+    private static File getContextFromProjects() {
+        FileObject fo = getMainProjectDirectory();
+        if (fo != null) {
+            return FileUtil.toFile(fo);
+        }
+
+        FileObject[] fos = getOpenProjectsDirectories();
+        if ((fos != null) && (fos.length == 1)) {
+            return getLargerContext(fos[0]);
+        }
+
+        return null;
+    }
+
+    private static File getLargerContext(File file) {
+        return getLargerContext(file, null);
+    }
+
+    private static File getLargerContext(FileObject fileObj) {
+        return getLargerContext(null, fileObj);
+    }
+
+    private static File getLargerContext(File file, FileObject fileObj) {
+        if ((file == null) && (fileObj == null)) {
+            throw new IllegalArgumentException(
+                    "both File and FileObject are null");               
//NOI18N
+        }
+
+        assert (file == null)
+               || (fileObj == null)
+               || FileUtil.toFileObject(file).equals(fileObj);
+
+        if (fileObj == null) {
+            fileObj = getFileObjForFileOrParent(file);
+        } else if (file == null) {
+            file = FileUtil.toFile(fileObj);
+        }
+
+        if (fileObj == null) {
+            return null;
+        }
+        if (!fileObj.isValid()) {
+            return null;
+        }
+
+        FileObject parentProjectFolder = 
BugtrackingUtil.getFileOwnerDirectory(fileObj);
+        if (parentProjectFolder != null) {
+            if (parentProjectFolder.equals(fileObj) && (file != null)) {
+                return file;
+            }
+            File folder = FileUtil.toFile(parentProjectFolder);
+            if (folder != null) {
+                return folder;
+            }
+        }
+
+        if (fileObj.isFolder()) {
+            return file;                        //whether it is null or 
non-null
+        } else {
+            fileObj = fileObj.getParent();
+            assert fileObj != null;      //every non-folder should have a 
parent
+            return FileUtil.toFile(fileObj);    //whether it is null or 
non-null
+        }
+    }
+
+
+    private static FileObject getFileObjForFileOrParent(File file) {
+        FileObject fileObj = FileUtil.toFileObject(file);
+        if (fileObj != null) {
+            return fileObj;
+        }
+
+        File closestParentFile = file.getParentFile();
+        while (closestParentFile != null) {
+            fileObj = FileUtil.toFileObject(closestParentFile);
+            if (fileObj != null) {
+                return fileObj;
+            }
+            closestParentFile = closestParentFile.getParentFile();
+        }
+
+        return null;
+    }
+
+    private static FileObject getOpenFileObj() {
+        TopComponent activatedTopComponent = TopComponent.getRegistry()
+                                             .getActivated();
+        if (activatedTopComponent == null) {
+            return null;
+        }
+
+        DataObject dataObj = activatedTopComponent.getLookup()
+                             .lookup(DataObject.class);
+        if ((dataObj == null) || !dataObj.isValid()) {
+            return null;
+        }
+
+        return dataObj.getPrimaryFile();
+    }
+
+    /**
+     *
+     * @param fileObject
+     * @return
+     * @throws IOException
+     */
+    private static RepositoryImpl getRepositoryIntern(FileObject fileObject) 
throws IOException {
+        String url = VersioningQuery.getRemoteLocation(fileObject.toURI());
+        
+        if (url != null) {
+            RepositoryImpl repository = null;
+            if(NBBugzillaUtils.isNbRepository(url)) {
+                File file = FileUtil.toFile(fileObject);
+                if(file != null) {
+                    OwnerInfo ownerInfo = TeamUtil.getOwnerInfo(file);
+                    if(ownerInfo != null) {
+                        repository = 
APIAccessor.IMPL.getImpl(TeamUtil.getRepository(url, ownerInfo.getOwner()));
+                    }
+                    if(repository == null) {
+                        repository = 
APIAccessor.IMPL.getImpl(TeamUtil.findNBRepository());
+                    }
+                }
+            }
+            if(repository != null) {
+                return repository;
+            }
+            try {
+                repository = 
APIAccessor.IMPL.getImpl(TeamUtil.getRepository(url));
+                if (repository != null) {
+                    return repository;
+                }
+            } catch (IOException ex) {
+                /* the remote location (URL) denotes a Team project */
+                if ("Not Found".equals(ex.getMessage())) {              // 
NOI18N
+                    BugtrackingManager.LOG.log(
+                            Level.INFO,
+                            "Team project corresponding to URL {0} does not 
exist.",  // NOI18N
+                            url);
+                } else {
+                    BugtrackingManager.LOG.throwing(
+                            BugtrackingOwnerSupport.class.getName(),    
//class name
+                            "getRepository(String)",    //method name       
// NOI18N
+                            ex);
+                }
+                throw ex;
+            }
+        }
+        return null;
+    }
+
+    private RepositoryImpl askUserToSpecifyRepository(RepositoryImpl 
suggestedRepo) {
+        Collection<RepositoryImpl> repos = 
RepositoryRegistry.getInstance().getKnownRepositories(true);
+        DelegatingConnector[] connectors = 
BugtrackingManager.getInstance().getConnectors();
+
+        final RepositorySelectorBuilder selectorBuilder = new 
RepositorySelectorBuilder();
+        selectorBuilder.setDisplayFormForExistingRepositories(true);
+        selectorBuilder.setExistingRepositories(repos.toArray(new 
RepositoryImpl[repos.size()]));
+        selectorBuilder.setBugtrackingConnectors(connectors);
+        selectorBuilder.setPreselectedRepository(suggestedRepo);
+        selectorBuilder.setLabelAboveComboBox();
+
+        final String dialogTitle = 
getMessage("LBL_BugtrackerSelectorTitle"); //NOI18N
+
+        DialogDescriptor dialogDescriptor
+                = selectorBuilder.createDialogDescriptor(dialogTitle);
+
+        Object selectedOption = 
DialogDisplayer.getDefault().notify(dialogDescriptor);
+        if (selectedOption == NotifyDescriptor.OK_OPTION) {
+            RepositoryImpl repository = 
selectorBuilder.getSelectedRepository();
+            try {
+                repository.applyChanges();
+            } catch (IOException ex) {
+                LOG.log(Level.SEVERE, null, ex);
+                repository = null;
+            }
+            return repository;
+        } else {
+            return null;
+        }
+    }
+
+    private String getMessage(String msgKey) {
+        return NbBundle.getMessage(BugtrackingOwnerSupport.class, msgKey);
+    }
+
+    private static FileObject getMainProjectDirectory() {
+        ProjectServices projectServices = 
BugtrackingManager.getInstance().getProjectServices();
+        return projectServices != null ? 
projectServices.getMainProjectDirectory() : null;
+    }
+    
+    private static FileObject[] getOpenProjectsDirectories() {
+        ProjectServices projectServices = 
BugtrackingManager.getInstance().getProjectServices();
+        return projectServices != null ? 
projectServices.getOpenProjectsDirectories(): null;
+    }
+    
+}
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/FileToRepoMappingStorage.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/FileToRepoMappingStorage.java
new file mode 100644
--- /dev/null
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/FileToRepoMappingStorage.java
@@ -0,0 +1,220 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2009 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.modules.bugtracking;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.prefs.BackingStoreException;
+import java.util.prefs.Preferences;
+import org.openide.util.NbPreferences;
+import static java.lang.Boolean.FALSE;
+import static java.lang.Boolean.TRUE;
+import static java.util.logging.Level.WARNING;
+import org.netbeans.modules.bugtracking.RepositoryRegistry;
+import org.netbeans.modules.bugtracking.RepositoryImpl;
+
+/**
+ * Stores mappings between {@code File}s and bugtracking repositories.
+ *
+ * @author Marian Petras
+ */
+class FileToRepoMappingStorage {
+
+    private static Logger LOG = 
Logger.getLogger("org.netbeans.modules.bugtracking.util.FileToRepoMappingStorage");
 //NOI18N
+
+    private static final String REPOSITORY_FOR_FILE_PREFIX = "repository for 
"; //NOI18N
+    private static final Boolean FIRM_ASSOCIATION = TRUE;
+    private static final Boolean LOOSE_ASSOCIATION = FALSE;
+
+    private static FileToRepoMappingStorage instance;
+
+    public synchronized static FileToRepoMappingStorage getInstance() {
+        if (instance == null) {
+            instance = new FileToRepoMappingStorage();
+        }
+        return instance;
+    }
+
+    public void setFirmAssociation(File file, RepositoryImpl repository) {
+        setAssociation(file, repository, true);
+    }
+
+    public boolean setLooseAssociation(File file, RepositoryImpl repository) 
{
+        RepositoryImpl firmlyAssociated = 
getFirmlyAssociatedRepository(file);
+        if (firmlyAssociated == null) {
+            setAssociation(file, repository, false);
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public RepositoryImpl getRepository(File file) {
+        return getAssociatedRepository(file, null);
+    }
+
+    public RepositoryImpl getFirmlyAssociatedRepository(File file) {
+        return getAssociatedRepository(file, FIRM_ASSOCIATION);
+    }
+
+    public RepositoryImpl getLooselyAssociatedRepository(File file) {
+        return getAssociatedRepository(file, LOOSE_ASSOCIATION);
+    }
+
+    public Collection<String> getAllFirmlyAssociatedUrls() {
+        HashSet<String> associatedUrls = new HashSet<String>(10);
+        try {
+            Preferences prefs = getPreferences();
+            String[] keys = prefs.keys();
+            for (String key : keys) {
+                if (key.startsWith(REPOSITORY_FOR_FILE_PREFIX)) { // found 
an association
+                    String value = prefs.get(key, null);
+                    if (value != null && value.length() > 0 && 
value.charAt(0) == '!') { // found a firm association
+                        associatedUrls.add(value.substring(1));
+                    }
+                }
+            }
+        } catch (BackingStoreException ex) {
+            LOG.log(Level.INFO, null, ex);
+        }
+        return associatedUrls;
+    }
+
+    private RepositoryImpl getAssociatedRepository(File file, Boolean 
reqAssociationType) {
+        String key = getPath(file);
+        if (key == null) {
+            return null;
+        }
+
+        String value = getValueForKey(key);
+        if ((value == null) || (value.length() == 0)) {
+            return null;
+        }
+
+        boolean matches;
+        final char firstChar = value.charAt(0);
+        switch (firstChar) {
+            case '!':
+                matches = (reqAssociationType != LOOSE_ASSOCIATION);
+                break;
+            case '?':
+                matches = (reqAssociationType != FIRM_ASSOCIATION);
+                break;
+            default:
+                if (LOG.isLoggable(WARNING)) {
+                    LOG.warning("unexpected first char of value in mapping: 
" //NOI18N
+                                + key + '=' + value
+                                + " (expected: '?' or '!')");           
//NOI18N
+                }
+                matches = false;
+        }
+
+        return matches ? getRepositoryByUrl(value.substring(1))
+                       : null;
+    }
+
+    private RepositoryImpl getRepositoryByUrl(String requestedUrl) {
+        Collection<RepositoryImpl> repositories = 
RepositoryRegistry.getInstance().getRepositories();
+        for (RepositoryImpl repository : repositories) {
+            String repositoryUrl = cutTrailingSlashes(repository.getUrl());
+            if (repositoryUrl.equals(requestedUrl)) {
+                return repository;
+            }
+        }
+
+        return null;
+    }
+
+    private void setAssociation(File file, RepositoryImpl repository, 
boolean firm) {
+        String key = getPath(file);
+        if (key == null) {
+            return;
+        }
+
+        String repositoryUrl = cutTrailingSlashes(repository.getUrl());
+        String value = new StringBuilder(1 + repositoryUrl.length())
+                .append(firm ? '!' : '?')
+                .append(repositoryUrl)
+                .toString();
+
+        storeKeyValuePair(key, value);
+    }
+
+    private static String getPath(File file) {
+        try {
+            return file.getCanonicalPath();
+        } catch (IOException ex) {
+            LOG.throwing(FileToRepoMappingStorage.class.getCanonicalName(),
+                         "storeMappingToPrefs",                         
//NOI18N
+                         ex);
+            return null;
+        }
+    }
+
+    private void storeKeyValuePair(String key, String value) {
+        getPreferences().put(REPOSITORY_FOR_FILE_PREFIX + key, value);
+    }
+
+    private String getValueForKey(String key) {
+        return getPreferences().get(REPOSITORY_FOR_FILE_PREFIX + key, null);
+    }
+
+    private Preferences getPreferences() {
+        return NbPreferences.forModule(FileToRepoMappingStorage.class);
+    }
+
+    private static String cutTrailingSlashes(String url) {
+        int endIndex = url.length();
+        while ((endIndex > 1) && url.charAt(endIndex - 1) == '/') {
+            endIndex--;
+        }
+
+        return (endIndex == url.length()) ? url
+                                          : url.substring(0, endIndex);
+    }
+
+}
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/issue/IssueAction.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/ui/issue/IssueAction.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/issue/IssueAction.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/ui/issue/IssueAction.java
@@ -55,7 +55,7 @@
 import org.netbeans.modules.bugtracking.BugtrackingManager;
 import org.netbeans.modules.bugtracking.IssueImpl;
 import org.netbeans.modules.bugtracking.RepositoryImpl;
-import org.netbeans.modules.bugtracking.util.BugtrackingOwnerSupport;
+import org.netbeans.modules.bugtracking.BugtrackingOwnerSupport;
 import org.netbeans.modules.bugtracking.util.BugtrackingUtil;
 import org.netbeans.modules.bugtracking.util.UIUtils;
 import org.openide.awt.ActionID;
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/BugtrackingOwnerSupport.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/BugtrackingOwnerSupport.java
deleted file mode 100644
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/BugtrackingOwnerSupport.java
+++ /dev/null
@@ -1,460 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
- *
- * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
- * Other names may be trademarks of their respective owners.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html
- * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
- * specific language governing permissions and limitations under the
- * License.  When distributing the software, include this License Header
- * Notice in each file and include the License file at
- * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- *
- * Contributor(s):
- *
- * Portions Copyrighted 2009 Sun Microsystems, Inc.
- */
-
-package org.netbeans.modules.bugtracking.util;
-
-import org.netbeans.modules.bugtracking.team.spi.TeamUtil;
-import java.io.File;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.netbeans.api.queries.VersioningQuery;
-import org.netbeans.modules.bugtracking.APIAccessor;
-import org.netbeans.modules.bugtracking.BugtrackingManager;
-import org.netbeans.modules.bugtracking.DelegatingConnector;
-import org.netbeans.modules.bugtracking.RepositoryImpl;
-import org.netbeans.modules.bugtracking.RepositoryRegistry;
-import org.netbeans.modules.team.ide.spi.ProjectServices;
-import org.netbeans.modules.bugtracking.team.spi.OwnerInfo;
-import 
org.netbeans.modules.bugtracking.ui.selectors.RepositorySelectorBuilder;
-import org.openide.DialogDescriptor;
-import org.openide.DialogDisplayer;
-import org.openide.NotifyDescriptor;
-import org.openide.filesystems.FileObject;
-import org.openide.filesystems.FileUtil;
-import org.openide.loaders.DataObject;
-import org.openide.util.Lookup;
-import org.openide.util.NbBundle;
-import org.openide.windows.TopComponent;
-
-/**
- *
- * @author Tomas Stupka
- * @author Marian Petras
- */
-public class BugtrackingOwnerSupport {
-
-    private static final Logger LOG = 
Logger.getLogger("org.netbeans.modules.bugtracking.bridge.BugtrackingOwnerSupport");
   // NOI18N
-    
-    private static BugtrackingOwnerSupport instance;
-
-    protected BugtrackingOwnerSupport() { }
-
-    public static BugtrackingOwnerSupport getInstance() {
-        if(instance == null) {
-            instance = 
Lookup.getDefault().lookup(BugtrackingOwnerSupport.class);
-            if (instance == null) {
-                instance = new BugtrackingOwnerSupport();
-            }
-        }
-        return instance;
-    }
-
-    public enum ContextType {
-        MAIN_PROJECT_ONLY,
-        SELECTED_FILE_AND_ALL_PROJECTS,
-    }
-
-    public RepositoryImpl getRepository(FileObject... files) {
-        if (files == null) {
-            return null;
-        }
-        if (files.length == 0) {
-            return null;
-        }
-
-        RepositoryImpl chosenRepo = null;
-        for (FileObject fo : files) {
-            RepositoryImpl repo = getRepository(fo);
-            
-            if (repo == null) {
-                continue;
-            }
-            if (chosenRepo == null) {
-                chosenRepo = repo;
-            } else if (repo != chosenRepo) {    //various repositories 
assigned
-                return null;
-            }
-        }
-        return chosenRepo;
-    }
-
-    public RepositoryImpl getRepository(FileObject fileObject) {
-        RepositoryImpl repo;
-
-        try {
-            repo = getRepositoryIntern(fileObject);
-            if (repo != null) {
-                return repo;
-            }
-        } catch (IOException ex) {
-            return null;
-        }
-
-        File context = getLargerContext(fileObject);
-        if (context != null) {
-            return getRepositoryForContext(context, false);
-        } else {
-            return askUserToSpecifyRepository(null);
-        }
-    }
-
-    public RepositoryImpl getRepository(File file, boolean askIfUnknown) {
-        if(file == null) {
-            if(askIfUnknown) {
-                return askUserToSpecifyRepository(null);
-            } else {
-                return null;
-            }
-        }
-        //TODO - synchronization/threading
-        FileObject fileObject = FileUtil.toFileObject(file);
-        if (fileObject == null) {
-            LOG.log(Level.WARNING, " did not find a FileObject for file 
{0}", new Object[] {file}); //NOI18N
-        } else {
-            try {
-                RepositoryImpl repo = getRepositoryIntern(fileObject);
-                if (repo != null) {
-                    return repo;
-                }
-            } catch (IOException ex) {
-                LOG.log(Level.INFO,
-                      " communication with Team Server failed while loading 
" //NOI18N
-                          + "information about bugtracking repository", 
//NOI18N
-                      ex);
-                return null;
-            }
-        }
-
-        File context = getLargerContext(file, fileObject);
-        if (context == null) {
-            context = file;
-        }
-
-        return getRepositoryForContext(context, askIfUnknown);
-    }
-
-    public void setFirmAssociations(File[] files, RepositoryImpl repository) 
{
-        if (files == null) {
-            throw new IllegalArgumentException("files is null");        
//NOI18N
-        }
-        if (files.length == 0) {
-            return;
-        }
-
-        FileToRepoMappingStorage.getInstance().setFirmAssociation(
-                getLargerContext(files[0]),
-                repository);
-    }
-
-    public void setFirmAssociation(File file, RepositoryImpl repository) {
-        FileToRepoMappingStorage.getInstance().setFirmAssociation(
-                getLargerContext(file),
-                repository);
-    }
-
-    public void setLooseAssociation(ContextType contextType, RepositoryImpl 
repository) {
-        File context = null;
-
-        switch (contextType) {
-            case MAIN_PROJECT_ONLY:
-                FileObject fo = getMainProjectDirectory();
-                if (fo != null) {
-                    context = getLargerContext(fo);
-                }
-                break;
-            case SELECTED_FILE_AND_ALL_PROJECTS:
-                context = getLargerContext();
-                break;
-            default:
-                assert false;
-                break;
-        }
-
-        if (context != null) {
-            FileToRepoMappingStorage.getInstance().setLooseAssociation(
-                    context,
-                    repository);
-        }
-    }
-
-    /**
-     * Returns all repository urls that appear in a <strong>firm</strong> 
association.
-     * @return
-     */
-    public final Collection<String> getAllAssociatedUrls() {
-        return 
FileToRepoMappingStorage.getInstance().getAllFirmlyAssociatedUrls();
-    }
-
-    protected RepositoryImpl getRepositoryForContext(File context, boolean 
askIfUnknown) {
-        RepositoryImpl repo = FileToRepoMappingStorage.getInstance()
-                          .getFirmlyAssociatedRepository(context);
-        if (repo != null) {
-            LOG.log(Level.FINER, 
-                    " found stored repository [{0}] for directory {1}",     
//NOI18N
-                    new Object[]{repo, context});
-            return repo;
-        }
-
-        RepositoryImpl suggestedRepository = 
FileToRepoMappingStorage.getInstance()
-                                         
.getLooselyAssociatedRepository(context);
-        if (!askIfUnknown) {
-            return suggestedRepository;
-        }
-
-        repo = askUserToSpecifyRepository(suggestedRepository);
-        if (repo != null) {
-            return repo;
-        }
-
-        return null;
-    }
-    
-    private static File getLargerContext() {
-        FileObject openFile = getOpenFileObj();
-        if (openFile != null) {
-            File largerContext = getLargerContext(openFile);
-            if (largerContext != null) {
-                return largerContext;
-            }
-        }
-
-        return getContextFromProjects();
-    }
-
-    private static File getContextFromProjects() {
-        FileObject fo = getMainProjectDirectory();
-        if (fo != null) {
-            return FileUtil.toFile(fo);
-        }
-
-        FileObject[] fos = getOpenProjectsDirectories();
-        if ((fos != null) && (fos.length == 1)) {
-            return getLargerContext(fos[0]);
-        }
-
-        return null;
-    }
-
-    private static File getLargerContext(File file) {
-        return getLargerContext(file, null);
-    }
-
-    private static File getLargerContext(FileObject fileObj) {
-        return getLargerContext(null, fileObj);
-    }
-
-    private static File getLargerContext(File file, FileObject fileObj) {
-        if ((file == null) && (fileObj == null)) {
-            throw new IllegalArgumentException(
-                    "both File and FileObject are null");               
//NOI18N
-        }
-
-        assert (file == null)
-               || (fileObj == null)
-               || FileUtil.toFileObject(file).equals(fileObj);
-
-        if (fileObj == null) {
-            fileObj = getFileObjForFileOrParent(file);
-        } else if (file == null) {
-            file = FileUtil.toFile(fileObj);
-        }
-
-        if (fileObj == null) {
-            return null;
-        }
-        if (!fileObj.isValid()) {
-            return null;
-        }
-
-        FileObject parentProjectFolder = 
BugtrackingUtil.getFileOwnerDirectory(fileObj);
-        if (parentProjectFolder != null) {
-            if (parentProjectFolder.equals(fileObj) && (file != null)) {
-                return file;
-            }
-            File folder = FileUtil.toFile(parentProjectFolder);
-            if (folder != null) {
-                return folder;
-            }
-        }
-
-        if (fileObj.isFolder()) {
-            return file;                        //whether it is null or 
non-null
-        } else {
-            fileObj = fileObj.getParent();
-            assert fileObj != null;      //every non-folder should have a 
parent
-            return FileUtil.toFile(fileObj);    //whether it is null or 
non-null
-        }
-    }
-
-
-    private static FileObject getFileObjForFileOrParent(File file) {
-        FileObject fileObj = FileUtil.toFileObject(file);
-        if (fileObj != null) {
-            return fileObj;
-        }
-
-        File closestParentFile = file.getParentFile();
-        while (closestParentFile != null) {
-            fileObj = FileUtil.toFileObject(closestParentFile);
-            if (fileObj != null) {
-                return fileObj;
-            }
-            closestParentFile = closestParentFile.getParentFile();
-        }
-
-        return null;
-    }
-
-    private static FileObject getOpenFileObj() {
-        TopComponent activatedTopComponent = TopComponent.getRegistry()
-                                             .getActivated();
-        if (activatedTopComponent == null) {
-            return null;
-        }
-
-        DataObject dataObj = activatedTopComponent.getLookup()
-                             .lookup(DataObject.class);
-        if ((dataObj == null) || !dataObj.isValid()) {
-            return null;
-        }
-
-        return dataObj.getPrimaryFile();
-    }
-
-    /**
-     *
-     * @param fileObject
-     * @return
-     * @throws IOException
-     */
-    private static RepositoryImpl getRepositoryIntern(FileObject fileObject) 
throws IOException {
-        String url = VersioningQuery.getRemoteLocation(fileObject.toURI());
-        
-        if (url != null) {
-            RepositoryImpl repository = null;
-            if(NBBugzillaUtils.isNbRepository(url)) {
-                File file = FileUtil.toFile(fileObject);
-                if(file != null) {
-                    OwnerInfo ownerInfo = TeamUtil.getOwnerInfo(file);
-                    if(ownerInfo != null) {
-                        repository = 
APIAccessor.IMPL.getImpl(TeamUtil.getRepository(url, ownerInfo.getOwner()));
-                    }
-                    if(repository == null) {
-                        repository = 
APIAccessor.IMPL.getImpl(TeamUtil.findNBRepository());
-                    }
-                }
-            }
-            if(repository != null) {
-                return repository;
-            }
-            try {
-                repository = 
APIAccessor.IMPL.getImpl(TeamUtil.getRepository(url));
-                if (repository != null) {
-                    return repository;
-                }
-            } catch (IOException ex) {
-                /* the remote location (URL) denotes a Team project */
-                if ("Not Found".equals(ex.getMessage())) {              // 
NOI18N
-                    BugtrackingManager.LOG.log(
-                            Level.INFO,
-                            "Team project corresponding to URL {0} does not 
exist.",  // NOI18N
-                            url);
-                } else {
-                    BugtrackingManager.LOG.throwing(
-                            BugtrackingOwnerSupport.class.getName(),    
//class name
-                            "getRepository(String)",    //method name       
// NOI18N
-                            ex);
-                }
-                throw ex;
-            }
-        }
-        return null;
-    }
-
-    private RepositoryImpl askUserToSpecifyRepository(RepositoryImpl 
suggestedRepo) {
-        Collection<RepositoryImpl> repos = 
RepositoryRegistry.getInstance().getKnownRepositories(true);
-        DelegatingConnector[] connectors = 
BugtrackingManager.getInstance().getConnectors();
-
-        final RepositorySelectorBuilder selectorBuilder = new 
RepositorySelectorBuilder();
-        selectorBuilder.setDisplayFormForExistingRepositories(true);
-        selectorBuilder.setExistingRepositories(repos.toArray(new 
RepositoryImpl[repos.size()]));
-        selectorBuilder.setBugtrackingConnectors(connectors);
-        selectorBuilder.setPreselectedRepository(suggestedRepo);
-        selectorBuilder.setLabelAboveComboBox();
-
-        final String dialogTitle = 
getMessage("LBL_BugtrackerSelectorTitle"); //NOI18N
-
-        DialogDescriptor dialogDescriptor
-                = selectorBuilder.createDialogDescriptor(dialogTitle);
-
-        Object selectedOption = 
DialogDisplayer.getDefault().notify(dialogDescriptor);
-        if (selectedOption == NotifyDescriptor.OK_OPTION) {
-            RepositoryImpl repository = 
selectorBuilder.getSelectedRepository();
-            try {
-                repository.applyChanges();
-            } catch (IOException ex) {
-                LOG.log(Level.SEVERE, null, ex);
-                repository = null;
-            }
-            return repository;
-        } else {
-            return null;
-        }
-    }
-
-    private String getMessage(String msgKey) {
-        return NbBundle.getMessage(BugtrackingOwnerSupport.class, msgKey);
-    }
-
-    private static FileObject getMainProjectDirectory() {
-        ProjectServices projectServices = 
BugtrackingManager.getInstance().getProjectServices();
-        return projectServices != null ? 
projectServices.getMainProjectDirectory() : null;
-    }
-    
-    private static FileObject[] getOpenProjectsDirectories() {
-        ProjectServices projectServices = 
BugtrackingManager.getInstance().getProjectServices();
-        return projectServices != null ? 
projectServices.getOpenProjectsDirectories(): null;
-    }
-    
-}
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/FileToRepoMappingStorage.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/FileToRepoMappingStorage.java
deleted file mode 100644
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/FileToRepoMappingStorage.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
- *
- * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
- * Other names may be trademarks of their respective owners.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html
- * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
- * specific language governing permissions and limitations under the
- * License.  When distributing the software, include this License Header
- * Notice in each file and include the License file at
- * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- *
- * Contributor(s):
- *
- * Portions Copyrighted 2009 Sun Microsystems, Inc.
- */
-
-package org.netbeans.modules.bugtracking.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.prefs.BackingStoreException;
-import java.util.prefs.Preferences;
-import org.openide.util.NbPreferences;
-import static java.lang.Boolean.FALSE;
-import static java.lang.Boolean.TRUE;
-import static java.util.logging.Level.WARNING;
-import org.netbeans.modules.bugtracking.RepositoryRegistry;
-import org.netbeans.modules.bugtracking.RepositoryImpl;
-
-/**
- * Stores mappings between {@code File}s and bugtracking repositories.
- *
- * @author Marian Petras
- */
-class FileToRepoMappingStorage {
-
-    private static Logger LOG = 
Logger.getLogger("org.netbeans.modules.bugtracking.util.FileToRepoMappingStorage");
 //NOI18N
-
-    private static final String REPOSITORY_FOR_FILE_PREFIX = "repository for 
"; //NOI18N
-    private static final Boolean FIRM_ASSOCIATION = TRUE;
-    private static final Boolean LOOSE_ASSOCIATION = FALSE;
-
-    private static FileToRepoMappingStorage instance;
-
-    public synchronized static FileToRepoMappingStorage getInstance() {
-        if (instance == null) {
-            instance = new FileToRepoMappingStorage();
-        }
-        return instance;
-    }
-
-    public void setFirmAssociation(File file, RepositoryImpl repository) {
-        setAssociation(file, repository, true);
-    }
-
-    public boolean setLooseAssociation(File file, RepositoryImpl repository) 
{
-        RepositoryImpl firmlyAssociated = 
getFirmlyAssociatedRepository(file);
-        if (firmlyAssociated == null) {
-            setAssociation(file, repository, false);
-            return true;
-        } else {
-            return false;
-        }
-    }
-
-    public RepositoryImpl getRepository(File file) {
-        return getAssociatedRepository(file, null);
-    }
-
-    public RepositoryImpl getFirmlyAssociatedRepository(File file) {
-        return getAssociatedRepository(file, FIRM_ASSOCIATION);
-    }
-
-    public RepositoryImpl getLooselyAssociatedRepository(File file) {
-        return getAssociatedRepository(file, LOOSE_ASSOCIATION);
-    }
-
-    public Collection<String> getAllFirmlyAssociatedUrls() {
-        HashSet<String> associatedUrls = new HashSet<String>(10);
-        try {
-            Preferences prefs = getPreferences();
-            String[] keys = prefs.keys();
-            for (String key : keys) {
-                if (key.startsWith(REPOSITORY_FOR_FILE_PREFIX)) { // found 
an association
-                    String value = prefs.get(key, null);
-                    if (value != null && value.length() > 0 && 
value.charAt(0) == '!') { // found a firm association
-                        associatedUrls.add(value.substring(1));
-                    }
-                }
-            }
-        } catch (BackingStoreException ex) {
-            LOG.log(Level.INFO, null, ex);
-        }
-        return associatedUrls;
-    }
-
-    private RepositoryImpl getAssociatedRepository(File file, Boolean 
reqAssociationType) {
-        String key = getPath(file);
-        if (key == null) {
-            return null;
-        }
-
-        String value = getValueForKey(key);
-        if ((value == null) || (value.length() == 0)) {
-            return null;
-        }
-
-        boolean matches;
-        final char firstChar = value.charAt(0);
-        switch (firstChar) {
-            case '!':
-                matches = (reqAssociationType != LOOSE_ASSOCIATION);
-                break;
-            case '?':
-                matches = (reqAssociationType != FIRM_ASSOCIATION);
-                break;
-            default:
-                if (LOG.isLoggable(WARNING)) {
-                    LOG.warning("unexpected first char of value in mapping: 
" //NOI18N
-                                + key + '=' + value
-                                + " (expected: '?' or '!')");           
//NOI18N
-                }
-                matches = false;
-        }
-
-        return matches ? getRepositoryByUrl(value.substring(1))
-                       : null;
-    }
-
-    private RepositoryImpl getRepositoryByUrl(String requestedUrl) {
-        Collection<RepositoryImpl> repositories = 
RepositoryRegistry.getInstance().getRepositories();
-        for (RepositoryImpl repository : repositories) {
-            String repositoryUrl = cutTrailingSlashes(repository.getUrl());
-            if (repositoryUrl.equals(requestedUrl)) {
-                return repository;
-            }
-        }
-
-        return null;
-    }
-
-    private void setAssociation(File file, RepositoryImpl repository, 
boolean firm) {
-        String key = getPath(file);
-        if (key == null) {
-            return;
-        }
-
-        String repositoryUrl = cutTrailingSlashes(repository.getUrl());
-        String value = new StringBuilder(1 + repositoryUrl.length())
-                .append(firm ? '!' : '?')
-                .append(repositoryUrl)
-                .toString();
-
-        storeKeyValuePair(key, value);
-    }
-
-    private static String getPath(File file) {
-        try {
-            return file.getCanonicalPath();
-        } catch (IOException ex) {
-            LOG.throwing(FileToRepoMappingStorage.class.getCanonicalName(),
-                         "storeMappingToPrefs",                         
//NOI18N
-                         ex);
-            return null;
-        }
-    }
-
-    private void storeKeyValuePair(String key, String value) {
-        getPreferences().put(REPOSITORY_FOR_FILE_PREFIX + key, value);
-    }
-
-    private String getValueForKey(String key) {
-        return getPreferences().get(REPOSITORY_FOR_FILE_PREFIX + key, null);
-    }
-
-    private Preferences getPreferences() {
-        return NbPreferences.forModule(FileToRepoMappingStorage.class);
-    }
-
-    private static String cutTrailingSlashes(String url) {
-        int endIndex = url.length();
-        while ((endIndex > 1) && url.charAt(endIndex - 1) == '/') {
-            endIndex--;
-        }
-
-        return (endIndex == url.length()) ? url
-                                          : url.substring(0, endIndex);
-    }
-
-}
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/OwnerUtils.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/OwnerUtils.java
--- a/bugtracking/src/org/netbeans/modules/bugtracking/util/OwnerUtils.java
+++ b/bugtracking/src/org/netbeans/modules/bugtracking/util/OwnerUtils.java
@@ -41,6 +41,7 @@
  */
 package org.netbeans.modules.bugtracking.util;
 
+import org.netbeans.modules.bugtracking.BugtrackingOwnerSupport;
 import java.io.File;
 import org.netbeans.modules.bugtracking.APIAccessor;
 import org.netbeans.modules.bugtracking.RepositoryImpl;
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/RepositoryComboSupport.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/RepositoryComboSupport.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/RepositoryComboSupport.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/RepositoryComboSupport.java
@@ -42,9 +42,9 @@
 
 package org.netbeans.modules.bugtracking.util;
 
+import org.netbeans.modules.bugtracking.BugtrackingOwnerSupport;
 import org.netbeans.modules.bugtracking.team.spi.TeamUtil;
 import org.openide.filesystems.FileObject;
-import org.openide.filesystems.FileUtil;
 import java.awt.Component;
 import java.awt.EventQueue;
 import java.awt.event.HierarchyEvent;
@@ -62,9 +62,7 @@
 import javax.swing.event.PopupMenuEvent;
 import javax.swing.event.PopupMenuListener;
 import org.netbeans.modules.bugtracking.BugtrackingManager;
-import org.openide.nodes.Node;
 import org.openide.util.RequestProcessor;
-import org.openide.windows.TopComponent;
 import static java.awt.event.HierarchyEvent.DISPLAYABILITY_CHANGED;
 import java.util.ArrayList;
 import java.util.Arrays;
diff --git 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyBugtrackingOwnerSupport.java
 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyBugtrackingOwnerSupport.java
--- 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyBugtrackingOwnerSupport.java
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyBugtrackingOwnerSupport.java
@@ -49,7 +49,7 @@
 import org.netbeans.modules.bugtracking.APIAccessor;
 import org.netbeans.modules.bugtracking.RepositoryImpl;
 import org.netbeans.modules.bugtracking.api.Repository;
-import org.netbeans.modules.bugtracking.util.BugtrackingOwnerSupport;
+import org.netbeans.modules.bugtracking.BugtrackingOwnerSupport;
 import org.openide.filesystems.FileObject;
 
 /**

[hg] main-silver: moved owner support from public package

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 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close