nbproject/project.xml
(inside <configuration>
).
+ */
+ public static final String PROJECT_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/clientside-project/1"; // NOI18N
+
+ public static final Charset DEFAULT_PROJECT_CHARSET = getDefaultProjectCharset();
+
+ // #217970
+ private static Charset getDefaultProjectCharset() {
+ try {
+ return Charset.forName("UTF-8"); // NOI18N
+ } catch (IllegalCharsetNameException exception) {
+ // fallback
+ LOGGER.log(Level.INFO, "UTF-8 charset not supported, falling back to the default charset.", exception);
+ } catch (UnsupportedCharsetException exception) {
+ // fallback
+ LOGGER.log(Level.INFO, "UTF-8 charset not supported, falling back to the default charset.", exception);
+ }
+ return Charset.defaultCharset();
+ }
}
diff --git a/web.clientproject.api/src/org/netbeans/modules/web/clientproject/api/project/ClientSideProjectGenerator.java b/web.clientproject.api/src/org/netbeans/modules/web/clientproject/api/project/ClientSideProjectGenerator.java
new file mode 100644
--- /dev/null
+++ b/web.clientproject.api/src/org/netbeans/modules/web/clientproject/api/project/ClientSideProjectGenerator.java
@@ -0,0 +1,370 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013 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 2013 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.web.clientproject.api.project;
+
+import java.awt.EventQueue;
+import java.io.File;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.netbeans.api.annotations.common.CheckForNull;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.project.FileOwnerQuery;
+import org.netbeans.api.project.Project;
+import org.netbeans.api.project.ProjectManager;
+import org.netbeans.modules.web.clientproject.api.WebClientProjectConstants;
+import org.netbeans.spi.project.support.ant.AntProjectHelper;
+import org.netbeans.spi.project.support.ant.EditableProperties;
+import org.netbeans.spi.project.support.ant.ProjectGenerator;
+import org.netbeans.spi.project.support.ant.PropertyUtils;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.Mutex;
+import org.openide.util.MutexException;
+import org.openide.util.Parameters;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * Creates a Web Client Side project from scratch according to some initial configuration.
+ *
+ * @since 1.34
+ * @author Martin Janicek
+ */
+public final class ClientSideProjectGenerator {
+
+ private static final Logger LOGGER = Logger.getLogger(ClientSideProjectGenerator.class.getName());
+
+
+ private ClientSideProjectGenerator() {
+ }
+
+ /**
+ * Creates a new empty Web Client Side project according to the given {@link ProjectProperties}.
+ *
+ * @param properties used for project setup
+ * @return the helper object permitting it to be further customized
+ * @throws IOException in case something went wrong
+ */
+ public static AntProjectHelper createProject(@NonNull CreateProjectProperties properties) throws IOException {
+ FileObject projectDir = properties.getProjectDir();
+
+ AntProjectHelper helper = ProjectGenerator.createProject(projectDir, WebClientProjectConstants.WEB_CLIENT_PROJECT_TYPE);
+ Project project = FileOwnerQuery.getOwner(projectDir);
+
+ ensureDirectoriesExists(FileUtil.toFile(projectDir), properties);
+
+ setProjectName(helper, properties.getProjectName());
+ save(helper, project, properties);
+
+ return helper;
+ }
+
+ private static void ensureDirectoriesExists(@NonNull File projectDir, @NonNull CreateProjectProperties properties) throws IOException {
+ ensureDirectoryExists(PropertyUtils.resolveFile(projectDir, properties.getSiteRootFolder()));
+
+ String test = properties.getTestFolder();
+ if (test != null) {
+ ensureDirectoryExists(PropertyUtils.resolveFile(projectDir, test));
+ }
+
+ String config = properties.getConfigFolder();
+ if (config != null) {
+ ensureDirectoryExists(PropertyUtils.resolveFile(projectDir, config));
+ }
+ }
+
+ private static void ensureDirectoryExists(File folder) throws IOException {
+ if (!folder.isDirectory()) {
+ if (!folder.mkdirs()) {
+ throw new IOException("Cannot create folder " + folder);
+ }
+ }
+ }
+
+ private static void setProjectName(final AntProjectHelper projectHelper, final String name) {
+ ProjectManager.mutex().writeAccess(new Runnable() {
+ @Override
+ public void run() {
+ Element data = projectHelper.getPrimaryConfigurationData(true);
+ Document document = data.getOwnerDocument();
+ NodeList nameList = data.getElementsByTagNameNS(WebClientProjectConstants.PROJECT_CONFIGURATION_NAMESPACE, "name"); // NOI18N
+ Element nameElement;
+ if (nameList.getLength() == 1) {
+ nameElement = (Element) nameList.item(0);
+ NodeList deadKids = nameElement.getChildNodes();
+ while (deadKids.getLength() > 0) {
+ nameElement.removeChild(deadKids.item(0));
+ }
+ } else {
+ nameElement = document.createElementNS(WebClientProjectConstants.PROJECT_CONFIGURATION_NAMESPACE, "name"); // NOI18N
+ data.insertBefore(nameElement, data.getChildNodes().item(0));
+ }
+ nameElement.appendChild(document.createTextNode(name));
+ projectHelper.putPrimaryConfigurationData(data, true);
+ }
+ });
+ }
+
+ private static void save(
+ final AntProjectHelper helper,
+ final Project project,
+ final CreateProjectProperties properties) {
+
+ assert !EventQueue.isDispatchThread();
+ try {
+ // store properties
+ ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction
+ * This class is not thread-safe.
+ */
+ public static final class CreateProjectProperties {
+
+ private FileObject projectDir;
+ private String projectName;
+ private String startFile;
+ private String siteRootFolder;
+ private String testFolder;
+ private String configFolder;
+ private String encoding;
+
+
+ /**
+ * Get project directory, usually relative path.
+ *
+ * @return project directory, usually relative path; never returns {@code null} or empty string
+ */
+ @NonNull
+ public FileObject getProjectDir() {
+ return projectDir;
+ }
+
+ /**
+ * Set project directory, never {@code null} or empty string.
+ *
+ * @param projectDir project directory, never {@code null} or empty string
+ * @return itself
+ */
+ public CreateProjectProperties setProjectDir(FileObject projectDir) {
+ this.projectDir = projectDir;
+ return this;
+ }
+
+ /**
+ * Get project name.
+ *
+ * @return project name; never returns {@code null} or empty string
+ */
+ @NonNull
+ public String getProjectName() {
+ return projectName;
+ }
+
+ /**
+ * Set project name, never {@code null} or empty string.
+ *
+ * @param projectName project name, never {@code null} or empty string
+ * @return itself
+ */
+ public CreateProjectProperties setProjectName(String projectName) {
+ this.projectName = projectName;
+ return this;
+ }
+
+ /**
+ * Get start file.
+ *
+ * @return start file; never returns {@code null} or empty string
+ */
+ @NonNull
+ public String getStartFile() {
+ return startFile;
+ }
+
+ /**
+ * Set start file, never {@code null} or empty string.
+ *
+ * @param startFile start file, never {@code null} or empty string
+ * @return itself
+ */
+ public CreateProjectProperties setStartFile(String startFile) {
+ this.startFile = startFile;
+ return this;
+ }
+
+ /**
+ * Get Site Root folder, usually relative path.
+ *
+ * @return Site Root folder, usually relative path; never returns
+ * {@code null} or empty string
+ */
+ @NonNull
+ public String getSiteRootFolder() {
+ return siteRootFolder;
+ }
+
+ /**
+ * Set Site Root folder, never {@code null} or empty string.
+ *
+ * @param siteRootFolder Site Root folder, never {@code null} or empty
+ * string
+ * @return itself
+ */
+ public CreateProjectProperties setSiteRootFolder(@NonNull String siteRootFolder) {
+ Parameters.notEmpty("siteRootFolder", siteRootFolder);
+ this.siteRootFolder = siteRootFolder;
+ return this;
+ }
+
+ /**
+ * Get Test folder, usually relative path.
+ *
+ * @return Test folder, usually relative path; can be {@code null} if no
+ * Test folder is present
+ */
+ @CheckForNull
+ public String getTestFolder() {
+ return testFolder;
+ }
+
+ /**
+ * Set Test folder, can be {@code null} if there are no tests available.
+ *
+ * @param testFolder Test folder, can be {@code null} if there are no
+ * tests available
+ * @return itself
+ */
+ public CreateProjectProperties setTestFolder(String testFolder) {
+ this.testFolder = testFolder;
+ return this;
+ }
+
+ /**
+ * Get Config folder, usually relative path.
+ *
+ * @return Config folder, usually relative path; can be {@code null} if
+ * no Config folder is present
+ */
+ @CheckForNull
+ public String getConfigFolder() {
+ return configFolder;
+ }
+
+ /**
+ * Set Config folder, can be {@code null} if there is no config
+ * available.
+ *
+ * @param configFolder Config folder, can be {@code null} if there is no
+ * config available
+ * @return itself
+ */
+ public CreateProjectProperties setConfigFolder(String configFolder) {
+ this.configFolder = configFolder;
+ return this;
+ }
+
+ /**
+ * Get encoding.
+ *
+ * @return Encoding; can be {@code null} if no encoding is present
+ */
+ @NonNull
+ public String getEncoding() {
+ return encoding;
+ }
+
+ /**
+ * Set encoding, can be {@code null} if there is no encoding available.
+ *
+ * @param encoding encoding, can be {@code null} if there is no encoding available
+ * @return itself
+ */
+ public CreateProjectProperties setEncoding(String encoding) {
+ this.encoding = encoding;
+ return this;
+ }
+ }
+}
diff --git a/web.clientproject.api/src/org/netbeans/modules/web/clientproject/api/project/sites/OnlineSites.java b/web.clientproject.api/src/org/netbeans/modules/web/clientproject/api/project/sites/OnlineSites.java
new file mode 100644
--- /dev/null
+++ b/web.clientproject.api/src/org/netbeans/modules/web/clientproject/api/project/sites/OnlineSites.java
@@ -0,0 +1,127 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2012 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 2012 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.web.clientproject.api.project.sites;
+
+import java.awt.EventQueue;
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.logging.Logger;
+import org.netbeans.api.progress.ProgressHandle;
+import org.netbeans.modules.web.clientproject.spi.SiteTemplateImplementation;
+import org.netbeans.modules.web.clientproject.api.util.FileUtilities;
+import org.openide.filesystems.FileObject;
+
+
+public abstract class OnlineSites implements SiteTemplateImplementation {
+
+ private static final Logger LOGGER = Logger.getLogger(OnlineSites.class.getName());
+
+ private final String name;
+ private final String url;
+ private final File libFile;
+ private final String description;
+ private final String id;
+
+
+
+ protected OnlineSites(String id, String name, String description, String url, File libFile) {
+ this.id = id;
+ this.name = name;
+ this.description = description;
+ this.url = url;
+ this.libFile = libFile;
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public boolean isPrepared() {
+ return libFile.isFile();
+ }
+
+ @Override
+ public void prepare() throws IOException {
+ assert !EventQueue.isDispatchThread();
+ assert !isPrepared();
+ SiteHelper.download(url, libFile, null);
+ }
+
+ @Override
+ public void configure(ProjectProperties projectProperties) {
+ // noop by default
+ }
+
+ @Override
+ public final void apply(FileObject projectDir, ProjectProperties projectProperties, ProgressHandle handle) throws IOException {
+ assert !EventQueue.isDispatchThread();
+ if (!isPrepared()) {
+ // not correctly prepared, user has to know about it already
+ LOGGER.info("Template not correctly prepared, nothing to be applied"); //NOI18N
+ return;
+ }
+ SiteHelper.unzipProjectTemplate(getTargetDir(projectDir, projectProperties), libFile, handle);
+ }
+
+ protected FileObject getTargetDir(FileObject projectDir, ProjectProperties projectProperties) {
+ // by default, extract template to site root
+ return projectDir.getFileObject(projectProperties.getSiteRootFolder());
+ }
+
+ @Override
+ public Collection
+ * Warning: only "/" as path separator expected.
+ *
+ * The typical usage is for file paths from a ZIP file.
+ * @param paths relative paths (with "/" as path separator) to be processed, never empty paths or {@code null}
+ * @return list of paths without possible root folder
+ */
+ public static List
+ * If any error occurs, this error is logged with INFO level and an empty list is returned.
+ * @param zipFile ZIP file to be listed
+ * @return list of JS files (filenames with relative path) from the given ZIP file.
+ * @see #listZipFiles(File, ZipEntryFilter)
+ * @see #listJsFilenamesFromZipFile(File)
+ */
+ public static List
+ * Instances of this interface may be passed to the {@link #listZipFiles(File, ZipEntryFilter)} method.
+ * @see #listZipFiles(File, ZipEntryFilter)
+ */
+ public interface ZipEntryFilter {
+
+ /**
+ * Test whether or not the specified {@link ZipEntry} should be
+ * accepted.
+ *
+ * @param zipEntry the {@link ZipEntry} to be tested
+ * @return {@ code true} if {@link ZipEntry} should be accepted, {@code false} otherwise
+ */
+ boolean accept(ZipEntry zipEntry);
+ }
+
+ /**
+ * Task for {@link ZipEntry}s, their content.
+ * @see #runOnZipEntries(File, ZipEntryTask, ZipEntryFilter)
+ */
+ public interface ZipEntryTask {
+
+ /**
+ * Run task on the given ZIP entry.
+ * @param zipEntry {@link ZipEntry} to be processed
+ */
+ void run(ZipEntry zipEntry);
+
+ /**
+ * Run task on the given content, typically read it.
+ * @param zipEntryInputStream content of the given {@link ZipEntry}
+ */
+ void run(InputStream zipEntryInputStream);
+ }
+
+}
diff --git a/web.clientproject.api/src/org/netbeans/modules/web/clientproject/api/util/ValidationUtilities.java b/web.clientproject.api/src/org/netbeans/modules/web/clientproject/api/util/ValidationUtilities.java
new file mode 100644
--- /dev/null
+++ b/web.clientproject.api/src/org/netbeans/modules/web/clientproject/api/util/ValidationUtilities.java
@@ -0,0 +1,99 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2012 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 2012 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.web.clientproject.api.util;
+
+import java.io.File;
+
+/**
+ * Miscellaneous utility methods for validation.
+ */
+public final class ValidationUtilities {
+
+ private static final char[] INVALID_FILENAME_CHARS = new char[] {'/', '\\', '|', ':', '*', '?', '"', '<', '>'}; // NOI18N
+
+
+ private ValidationUtilities() {
+ }
+
+ /**
+ * Check whether the provided filename is valid. An empty string is considered to be invalid.
+ * @param filename file name to be validated
+ * @return {@code true} if the provided filename is valid
+ */
+ public static boolean isValidFilename(String filename) {
+ assert filename != null;
+ if (filename.trim().length() == 0) {
+ return false;
+ }
+ for (char ch : INVALID_FILENAME_CHARS) {
+ if (filename.indexOf(ch) != -1) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Check whether the provided file has a valid filename. Only the non-existing filenames in the file path are checked.
+ * It means that if you pass existing directory, no check is done.
+ *
+ * For example for C:\Documents And Settings\ExistingDir\NonExistingDir\NonExistingDir2\Newdir the last free filenames
+ * are checked.
+ * @param file file to be checked
+ * @return {@code true} if the provided file has valid filename
+ * @see #isValidFilename(String)
+ */
+ public static boolean isValidFilename(File file) {
+ assert file != null;
+ File tmp = file;
+ while (tmp != null && !tmp.exists()) {
+ if (tmp.isAbsolute() && tmp.getParentFile() == null) {
+ return true;
+ } else if (!isValidFilename(tmp.getName())) {
+ return false;
+ }
+ tmp = tmp.getParentFile();
+ }
+ return true;
+ }
+
+}
diff --git a/web.clientproject/nbproject/project.xml b/web.clientproject/nbproject/project.xml
--- a/web.clientproject/nbproject/project.xml
+++ b/web.clientproject/nbproject/project.xml
@@ -142,7 +142,7 @@
nbproject/private/private.xml
(inside <project-private>
).
+ */
+ public static final String PRIVATE_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/clientside-project-private/1"; // NOI18N
}
diff --git a/web.clientproject/src/org/netbeans/modules/web/clientproject/ClientSideProjectSources.java b/web.clientproject/src/org/netbeans/modules/web/clientproject/ClientSideProjectSources.java
--- a/web.clientproject/src/org/netbeans/modules/web/clientproject/ClientSideProjectSources.java
+++ b/web.clientproject/src/org/netbeans/modules/web/clientproject/ClientSideProjectSources.java
@@ -94,15 +94,15 @@
private Sources initSources() {
SourcesHelper sourcesHelper = new SourcesHelper(project, helper, evaluator);
- sourcesHelper.sourceRoot("${" + ClientSideProjectConstants.PROJECT_SITE_ROOT_FOLDER + "}") //NOI18N
+ sourcesHelper.sourceRoot("${" + WebClientProjectConstants.PROJECT_SITE_ROOT_FOLDER + "}") //NOI18N
.displayName(org.openide.util.NbBundle.getMessage(ClientSideProjectSources.class, "SITE_ROOT"))
.add() // adding as principal root, continuing configuration
.type(WebClientProjectConstants.SOURCES_TYPE_HTML5).add(); // adding as typed root
- sourcesHelper.sourceRoot("${" + ClientSideProjectConstants.PROJECT_TEST_FOLDER + "}") //NOI18N
+ sourcesHelper.sourceRoot("${" + WebClientProjectConstants.PROJECT_TEST_FOLDER + "}") //NOI18N
.displayName(org.openide.util.NbBundle.getMessage(ClientSideProjectSources.class, "UNIT_TESTS"))
.add() // adding as principal root, continuing configuration
.type(WebClientProjectConstants.SOURCES_TYPE_HTML5_TEST).add(); // adding as typed root
- sourcesHelper.sourceRoot("${" + ClientSideProjectConstants.PROJECT_CONFIG_FOLDER + "}") //NOI18N
+ sourcesHelper.sourceRoot("${" + WebClientProjectConstants.PROJECT_CONFIG_FOLDER + "}") //NOI18N
.displayName(org.openide.util.NbBundle.getMessage(ClientSideProjectSources.class, "CONFIGURATION_FILES"))
.type(WebClientProjectConstants.SOURCES_TYPE_HTML5_CONFIG).add(); // adding as principal root
sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
diff --git a/web.clientproject/src/org/netbeans/modules/web/clientproject/ClientSideProjectType.java b/web.clientproject/src/org/netbeans/modules/web/clientproject/ClientSideProjectType.java
deleted file mode 100644
--- a/web.clientproject/src/org/netbeans/modules/web/clientproject/ClientSideProjectType.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2012 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 2012 Sun Microsystems, Inc.
- */
-package org.netbeans.modules.web.clientproject;
-
-public class ClientSideProjectType {
-
- public static final String TYPE = "org.netbeans.modules.web.clientproject"; // NOI18N
- public static final String PROJECT_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/clientside-project/1"; // NOI18N
- static final String PRIVATE_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/clientside-project-private/1"; // NOI18N
-
-}
diff --git a/web.clientproject/src/org/netbeans/modules/web/clientproject/ServerURLMappingImpl.java b/web.clientproject/src/org/netbeans/modules/web/clientproject/ServerURLMappingImpl.java
--- a/web.clientproject/src/org/netbeans/modules/web/clientproject/ServerURLMappingImpl.java
+++ b/web.clientproject/src/org/netbeans/modules/web/clientproject/ServerURLMappingImpl.java
@@ -49,6 +49,7 @@
import java.net.URLDecoder;
import org.netbeans.modules.javascript.jstestdriver.api.JsTestDriver;
import org.netbeans.modules.web.browser.api.WebBrowser;
+import org.netbeans.modules.web.clientproject.api.WebClientProjectConstants;
import org.netbeans.modules.web.common.api.ServerURLMapping;
import org.netbeans.modules.web.common.spi.ServerURLMappingImplementation;
import org.netbeans.modules.web.common.api.WebServer;
diff --git a/web.clientproject/src/org/netbeans/modules/web/clientproject/browser/ClientProjectEnhancedBrowserImpl.java b/web.clientproject/src/org/netbeans/modules/web/clientproject/browser/ClientProjectEnhancedBrowserImpl.java
--- a/web.clientproject/src/org/netbeans/modules/web/clientproject/browser/ClientProjectEnhancedBrowserImpl.java
+++ b/web.clientproject/src/org/netbeans/modules/web/clientproject/browser/ClientProjectEnhancedBrowserImpl.java
@@ -47,6 +47,7 @@
import org.netbeans.modules.web.browser.api.WebBrowser;
import org.netbeans.modules.web.clientproject.ClientSideProject;
import org.netbeans.modules.web.clientproject.ClientSideProjectConstants;
+import org.netbeans.modules.web.clientproject.api.WebClientProjectConstants;
import org.netbeans.modules.web.clientproject.spi.platform.ClientProjectEnhancedBrowserImplementation;
import org.netbeans.modules.web.clientproject.spi.platform.ProjectConfigurationCustomizer;
import org.netbeans.modules.web.clientproject.spi.platform.RefreshOnSaveListener;
diff --git a/web.clientproject/src/org/netbeans/modules/web/clientproject/problems/ProjectPropertiesProblemProvider.java b/web.clientproject/src/org/netbeans/modules/web/clientproject/problems/ProjectPropertiesProblemProvider.java
--- a/web.clientproject/src/org/netbeans/modules/web/clientproject/problems/ProjectPropertiesProblemProvider.java
+++ b/web.clientproject/src/org/netbeans/modules/web/clientproject/problems/ProjectPropertiesProblemProvider.java
@@ -50,7 +50,7 @@
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.netbeans.modules.web.clientproject.ClientSideProject;
-import org.netbeans.modules.web.clientproject.ClientSideProjectConstants;
+import org.netbeans.modules.web.clientproject.api.WebClientProjectConstants;
import org.netbeans.modules.web.clientproject.ui.customizer.CompositePanelProviderImpl;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
import org.netbeans.spi.project.ui.ProjectProblemsProvider;
@@ -71,9 +71,9 @@
// set would be better but it is fine to use a list for small number of items
static final List- * Warning: only "/" as path separator expected. - *
- * The typical usage is for file paths from a ZIP file.
- * @param paths relative paths (with "/" as path separator) to be processed, never empty paths or {@code null}
- * @return list of paths without possible root folder
- */
- public static List
- * If any error occurs, this error is logged with INFO level and an empty list is returned.
- * @param zipFile ZIP file to be listed
- * @return list of JS files (filenames with relative path) from the given ZIP file.
- * @see #listZipFiles(File, ZipEntryFilter)
- * @see #listJsFilenamesFromZipFile(File)
- */
- public static List
- * Instances of this interface may be passed to the {@link #listZipFiles(File, ZipEntryFilter)} method.
- * @see #listZipFiles(File, ZipEntryFilter)
- */
- public interface ZipEntryFilter {
-
- /**
- * Test whether or not the specified {@link ZipEntry} should be
- * accepted.
- *
- * @param zipEntry the {@link ZipEntry} to be tested
- * @return {@ code true} if {@link ZipEntry} should be accepted, {@code false} otherwise
- */
- boolean accept(ZipEntry zipEntry);
- }
-
- /**
- * Task for {@link ZipEntry}s, their content.
- * @see #runOnZipEntries(File, ZipEntryTask, ZipEntryFilter)
- */
- public interface ZipEntryTask {
-
- /**
- * Run task on the given ZIP entry.
- * @param zipEntry {@link ZipEntry} to be processed
- */
- void run(ZipEntry zipEntry);
-
- /**
- * Run task on the given content, typically read it.
- * @param zipEntryInputStream content of the given {@link ZipEntry}
- */
- void run(InputStream zipEntryInputStream);
- }
-
-}
diff --git a/web.clientproject/src/org/netbeans/modules/web/clientproject/util/ValidationUtilities.java b/web.clientproject/src/org/netbeans/modules/web/clientproject/util/ValidationUtilities.java
deleted file mode 100644
--- a/web.clientproject/src/org/netbeans/modules/web/clientproject/util/ValidationUtilities.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2012 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 2012 Sun Microsystems, Inc.
- */
-package org.netbeans.modules.web.clientproject.util;
-
-import java.io.File;
-
-/**
- * Miscellaneous utility methods for validation.
- */
-public final class ValidationUtilities {
-
- private static final char[] INVALID_FILENAME_CHARS = new char[] {'/', '\\', '|', ':', '*', '?', '"', '<', '>'}; // NOI18N
-
-
- private ValidationUtilities() {
- }
-
- /**
- * Check whether the provided filename is valid. An empty string is considered to be invalid.
- * @param filename file name to be validated
- * @return {@code true} if the provided filename is valid
- */
- public static boolean isValidFilename(String filename) {
- assert filename != null;
- if (filename.trim().length() == 0) {
- return false;
- }
- for (char ch : INVALID_FILENAME_CHARS) {
- if (filename.indexOf(ch) != -1) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Check whether the provided file has a valid filename. Only the non-existing filenames in the file path are checked.
- * It means that if you pass existing directory, no check is done.
- *
- * For example for C:\Documents And Settings\ExistingDir\NonExistingDir\NonExistingDir2\Newdir the last free filenames
- * are checked.
- * @param file file to be checked
- * @return {@code true} if the provided file has valid filename
- * @see #isValidFilename(String)
- */
- public static boolean isValidFilename(File file) {
- assert file != null;
- File tmp = file;
- while (tmp != null && !tmp.exists()) {
- if (tmp.isAbsolute() && tmp.getParentFile() == null) {
- return true;
- } else if (!isValidFilename(tmp.getName())) {
- return false;
- }
- tmp = tmp.getParentFile();
- }
- return true;
- }
-
-}
diff --git a/web.clientproject/test/unit/src/org/netbeans/modules/web/clientproject/ClientSideProjectTest.java b/web.clientproject/test/unit/src/org/netbeans/modules/web/clientproject/ClientSideProjectTest.java
--- a/web.clientproject/test/unit/src/org/netbeans/modules/web/clientproject/ClientSideProjectTest.java
+++ b/web.clientproject/test/unit/src/org/netbeans/modules/web/clientproject/ClientSideProjectTest.java
@@ -51,6 +51,7 @@
import org.netbeans.junit.NbTestCase;
import org.netbeans.modules.web.browser.api.BrowserFamilyId;
import org.netbeans.modules.web.browser.spi.EnhancedBrowserFactory;
+import org.netbeans.modules.web.clientproject.api.WebClientProjectConstants;
import org.netbeans.modules.web.clientproject.sites.SiteZip;
import org.netbeans.modules.web.clientproject.sites.SiteZipPanel;
import org.netbeans.modules.web.clientproject.spi.SiteTemplateImplementation;
@@ -106,9 +107,9 @@
AntProjectHelper projectHelper = ClientSideProjectUtilities.setupProject(wd, "Project2");
ClientSideProject project = (ClientSideProject) FileOwnerQuery.getOwner(projectHelper.getProjectDirectory());
ClientSideProjectProperties projectProperties = new ClientSideProjectProperties(project);
- projectProperties.setSiteRootFolder(ClientSideProjectConstants.DEFAULT_SITE_ROOT_FOLDER);
- projectProperties.setTestFolder(ClientSideProjectConstants.DEFAULT_TEST_FOLDER);
- projectProperties.setConfigFolder(ClientSideProjectConstants.DEFAULT_CONFIG_FOLDER);
+ projectProperties.setSiteRootFolder(WebClientProjectConstants.DEFAULT_SITE_ROOT_FOLDER);
+ projectProperties.setTestFolder(WebClientProjectConstants.DEFAULT_TEST_FOLDER);
+ projectProperties.setConfigFolder(WebClientProjectConstants.DEFAULT_CONFIG_FOLDER);
projectProperties.save();
ProjectProblemsProvider ppp = project.getLookup().lookup(ProjectProblemsProvider.class);
assertNotNull("project does have ProjectProblemsProvider", ppp);