Author: rombert Date: Wed Jun 17 10:07:31 2015 New Revision: 1685983 URL: http://svn.apache.org/r1685983 Log: SLING-4816 - When creating new servers ensure that local install is only selected for localhost
Added: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/SlingLaunchpadConfigurationDefaults.java sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/ApplyDefaultSlingServerValuesFragment.java - copied, changed from r1685521, sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/OverridePublishIntervalFragment.java Removed: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/OverridePublishIntervalFragment.java Modified: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/ServerUtil.java sling/trunk/tooling/ide/eclipse-ui/plugin.xml sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/SetupServerWizardPage.java Modified: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/ServerUtil.java URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/ServerUtil.java?rev=1685983&r1=1685982&r2=1685983&view=diff ============================================================================== --- sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/ServerUtil.java (original) +++ sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/ServerUtil.java Wed Jun 17 10:07:31 2015 @@ -36,6 +36,7 @@ import org.eclipse.core.runtime.NullProg import org.eclipse.core.runtime.Status; import org.eclipse.wst.server.core.IModule; import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.IServerWorkingCopy; import org.eclipse.wst.server.core.ServerCore; public abstract class ServerUtil { @@ -219,4 +220,9 @@ public abstract class ServerUtil { } } } + + public static boolean runsOnLocalhost(IServerWorkingCopy server) { + + return "localhost".equals(server.getHost()); + } } Added: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/SlingLaunchpadConfigurationDefaults.java URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/SlingLaunchpadConfigurationDefaults.java?rev=1685983&view=auto ============================================================================== --- sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/SlingLaunchpadConfigurationDefaults.java (added) +++ sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/SlingLaunchpadConfigurationDefaults.java Wed Jun 17 10:07:31 2015 @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sling.ide.eclipse.core; + +import org.eclipse.wst.server.core.IServerWorkingCopy; + +public class SlingLaunchpadConfigurationDefaults { + + /** + * Applies the default values to the specified <tt>workingCopy</tt> + * + * <p>Currently sets the <tt>auto-publish-time</tt> and + * <tt>{@code ISlingLaunchpadServer.PROP_INSTALL_LOCALLY}</tt> values. It assumes that these + * values were not previously set by the user and should only be used as a fallback when the + * user has not specified them.</p> + * + * <p>This method does not call {@link IServerWorkingCopy#save(boolean, org.eclipse.core.runtime.IProgressMonitor)}, + * it is the responsability of the caller to do so afterwards.</p> + * + * @param workingCopy working copy + */ + public static void applyDefaultValues(IServerWorkingCopy wc) { + + // auto-publish set to zero + wc.setAttribute("auto-publish-time", 0); + + // only set publishing mechanism to 'local' for localhost + wc.setAttribute(ISlingLaunchpadServer.PROP_INSTALL_LOCALLY, ServerUtil.runsOnLocalhost(wc)); + } +} Modified: sling/trunk/tooling/ide/eclipse-ui/plugin.xml URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/plugin.xml?rev=1685983&r1=1685982&r2=1685983&view=diff ============================================================================== --- sling/trunk/tooling/ide/eclipse-ui/plugin.xml (original) +++ sling/trunk/tooling/ide/eclipse-ui/plugin.xml Wed Jun 17 10:07:31 2015 @@ -76,8 +76,8 @@ <extension point="org.eclipse.wst.server.ui.wizardFragments"> <fragment - class="org.apache.sling.ide.eclipse.ui.wizards.OverridePublishIntervalFragment" - id="org.apache.sling.ide.eclipse.ui.wizards.SomeWizardFragment" + class="org.apache.sling.ide.eclipse.ui.wizards.ApplyDefaultSlingServerValuesFragment" + id="org.apache.sling.ide.eclipse.ui.wizards.ApplyDefaultSlingServerValuesFragment" typeIds="org.apache.sling.ide.launchpadServer"> </fragment> </extension> Copied: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/ApplyDefaultSlingServerValuesFragment.java (from r1685521, sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/OverridePublishIntervalFragment.java) URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/ApplyDefaultSlingServerValuesFragment.java?p2=sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/ApplyDefaultSlingServerValuesFragment.java&p1=sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/OverridePublishIntervalFragment.java&r1=1685521&r2=1685983&rev=1685983&view=diff ============================================================================== --- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/OverridePublishIntervalFragment.java (original) +++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/ApplyDefaultSlingServerValuesFragment.java Wed Jun 17 10:07:31 2015 @@ -16,6 +16,7 @@ */ package org.apache.sling.ide.eclipse.ui.wizards; +import org.apache.sling.ide.eclipse.core.SlingLaunchpadConfigurationDefaults; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.wst.server.core.IServer; @@ -24,11 +25,17 @@ import org.eclipse.wst.server.core.TaskM import org.eclipse.wst.server.ui.wizard.WizardFragment; /** - * The <tt>OverridePublishIntervalFragment</tt> ensures that the publish interval is set to 0 when creating a Sling - * Runtime + * The <tt>PostProcessDefaultSlingServerValuesFragment</tt> ensures that default values are reasonable when creating a local server + * + * Included checks are: + * + * <ol> + * <li><tt>auto-publish-time</tt> is set to 0</li> + * <li>Local deployment is only enabled for hosts named <tt>localhost</tt></li> + * </ol> * */ -public class OverridePublishIntervalFragment extends WizardFragment { +public class ApplyDefaultSlingServerValuesFragment extends WizardFragment { @Override public boolean hasComposite() { @@ -41,7 +48,9 @@ public class OverridePublishIntervalFrag IServer server = (IServer) getTaskModel().getObject(TaskModel.TASK_SERVER); if (server instanceof IServerWorkingCopy) { IServerWorkingCopy wc = (IServerWorkingCopy) server; - wc.setAttribute("auto-publish-time", 0); + + SlingLaunchpadConfigurationDefaults.applyDefaultValues(wc); + wc.save(true, monitor); } Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/SetupServerWizardPage.java URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/SetupServerWizardPage.java?rev=1685983&r1=1685982&r2=1685983&view=diff ============================================================================== --- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/SetupServerWizardPage.java (original) +++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/SetupServerWizardPage.java Wed Jun 17 10:07:31 2015 @@ -25,6 +25,7 @@ import org.apache.commons.io.IOUtils; import org.apache.sling.ide.artifacts.EmbeddedArtifactLocator; import org.apache.sling.ide.artifacts.EmbeddedArtifact; import org.apache.sling.ide.eclipse.core.ISlingLaunchpadServer; +import org.apache.sling.ide.eclipse.core.SlingLaunchpadConfigurationDefaults; import org.apache.sling.ide.eclipse.ui.internal.Activator; import org.apache.sling.ide.eclipse.ui.internal.SlingLaunchpadCombo; import org.apache.sling.ide.osgi.OsgiClient; @@ -386,10 +387,11 @@ public class SetupServerWizardPage exten wc.setName(newServerName.getText()); wc.setAttribute(ISlingLaunchpadServer.PROP_PORT, getPort()); wc.setAttribute(ISlingLaunchpadServer.PROP_DEBUG_PORT, Integer.parseInt(newServerDebugPort.getText())); - wc.setAttribute(ISlingLaunchpadServer.PROP_INSTALL_LOCALLY, installToolingSupportBundle.getSelection()); wc.setAttribute(ISlingLaunchpadServer.PROP_USERNAME, newServerUsername.getText()); wc.setAttribute(ISlingLaunchpadServer.PROP_PASSWORD, newServerPassword.getText()); - wc.setAttribute("auto-publish-time", 0); + + SlingLaunchpadConfigurationDefaults.applyDefaultValues(wc); + if (finalVersion != null) { wc.setAttribute(String.format(ISlingLaunchpadServer.PROP_BUNDLE_VERSION_FORMAT, EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME), finalVersion.toString());