visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/saas/util/InstalledFileLocatorImpl.java
Tests at least should compile now.
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
6 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7 * Other names may be trademarks of their respective owners.
9 * The contents of this file are subject to the terms of either the GNU
10 * General Public License Version 2 only ("GPL") or the Common
11 * Development and Distribution License("CDDL") (collectively, the
12 * "License"). You may not use this file except in compliance with the
13 * License. You can obtain a copy of the License at
14 * http://www.netbeans.org/cddl-gplv2.html
15 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16 * specific language governing permissions and limitations under the
17 * License. When distributing the software, include this License Header
18 * Notice in each file and include the License file at
19 * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
20 * particular file as subject to the "Classpath" exception as provided
21 * by Oracle in the GPL Version 2 section of the License file that
22 * accompanied this code. If applicable, add the following below the
23 * License Header, with the fields enclosed by brackets [] replaced by
24 * your own identifying information:
25 * "Portions Copyrighted [year] [name of copyright owner]"
29 * Portions Copyrighted 2007 Sun Microsystems, Inc.
32 package org.netbeans.modules.websvc.saas.util;
35 import java.util.ArrayList;
36 import org.openide.modules.InstalledFileLocator;
39 * InstalledFileLocator implementation that searches the NB install directory
40 * (uses java.endorsed.dirs value from nbproject/project.properties)
43 public class InstalledFileLocatorImpl extends InstalledFileLocator {
45 private ArrayList<File> baseDirs;
46 private File userDirConfigRoot;
48 public InstalledFileLocatorImpl() {
50 File endorsedDir = new File(System.getProperty("java.endorsed.dirs"));
51 for (int i = 0; i < 5; i++) {
52 endorsedDir = endorsedDir.getParentFile();
55 File installRoot = endorsedDir;
56 File[] subdirs = installRoot.listFiles();
57 baseDirs = new ArrayList<File>();
59 for (int i = 0; subdirs != null && i < subdirs.length; i++) {
60 if (subdirs[i].isDirectory()) {
61 baseDirs.add(subdirs[i]);
67 public File locate(String relativePath, String codeNameBase, boolean localized) {
68 for (File baseDir : baseDirs) {
69 File f = new File(baseDir, relativePath);
78 public void setUserConfigRoot(File baseDir) {
79 if (userDirConfigRoot != null) {
80 baseDirs.remove(userDirConfigRoot);
81 userDirConfigRoot = null;
84 if (baseDir != null) {
85 baseDirs.add(baseDir);
86 userDirConfigRoot = baseDir;