diff --git a/zendserver-deployment-eclipse/org.zend.php.zendserver.deployment.ui/src/org/zend/php/zendserver/deployment/ui/LocalZendServerStartup.java b/zendserver-deployment-eclipse/org.zend.php.zendserver.deployment.ui/src/org/zend/php/zendserver/deployment/ui/LocalZendServerStartup.java index 09393b9d..ebdc21aa 100644 --- a/zendserver-deployment-eclipse/org.zend.php.zendserver.deployment.ui/src/org/zend/php/zendserver/deployment/ui/LocalZendServerStartup.java +++ b/zendserver-deployment-eclipse/org.zend.php.zendserver.deployment.ui/src/org/zend/php/zendserver/deployment/ui/LocalZendServerStartup.java @@ -136,44 +136,47 @@ protected IStatus run(IProgressMonitor monitor) { } monitor.subTask(Messages.LocalZendServerStartup_UpdatingServerProperties); - try { - if (!isUnique(server.getName())) { - server.setName(getNewName(server.getName())); - } + if (!isUnique(server.getName())) { + server.setName(getNewName(server.getName())); + } - VhostInfo defaultVHostInfo = null; - WebApiCredentials credentials = new BasicCredentials(zendTarget.getKey(), - zendTarget.getSecretKey()); - WebApiClient apiClient = new WebApiClient(credentials, zendTarget.getHost().toString()); - apiClient.setServerType(zendTarget.getServerType()); - VhostsList vhostsList = apiClient.vhostGetStatus(); - for (VhostInfo vhostInfo : vhostsList.getVhosts()) { - if (!vhostInfo.isDefaultVhost()) - continue; - - defaultVHostInfo = vhostInfo; - } - - if(server.getBaseURL() == "" && defaultVHostInfo != null) { //$NON-NLS-1$ - // server base URL has not been read from - // the configuration - String baseUrl = "http://localhost:" + Integer.toString(defaultVHostInfo.getPort()); //$NON-NLS-1$ - server.setBaseURL(baseUrl); + if (server.getBaseURL() == "" || server.getDocumentRoot() == "") { //$NON-NLS-1$ //$NON-NLS-2$ + try { + VhostInfo defaultVHostInfo = null; + WebApiCredentials credentials = new BasicCredentials(zendTarget.getKey(), + zendTarget.getSecretKey()); + WebApiClient apiClient = new WebApiClient(credentials, zendTarget.getHost().toString()); + apiClient.setServerType(zendTarget.getServerType()); + VhostsList vhostsList = apiClient.vhostGetStatus(); + for (VhostInfo vhostInfo : vhostsList.getVhosts()) { + if (!vhostInfo.isDefaultVhost()) + continue; + + defaultVHostInfo = vhostInfo; + } + + if (server.getBaseURL() == "" && defaultVHostInfo != null) { //$NON-NLS-1$ + // server base URL has not been read from + // the configuration + String baseUrl = "http://localhost:" + Integer.toString(defaultVHostInfo.getPort()); //$NON-NLS-1$ + server.setBaseURL(baseUrl); + } + + if (server.getDocumentRoot() == "" && defaultVHostInfo != null) { //$NON-NLS-1$ + // server document root folder has not been read + // from + // the configuration + VhostDetails vhostDetails = apiClient.vhostGetDetails(defaultVHostInfo.getId()); + String documentRoot = vhostDetails.getExtendedInfo().getDocRoot(); + server.setDocumentRoot(documentRoot); + } + } catch (MalformedURLException | WebApiException ex) { + Activator.logError(Messages.LocalZendServerStartup_UpdatingServerProperties_Error, ex); + NotificationManager.showWarningWithHelp(Messages.LocalZendServerStartup_NotFoundTitle, + Messages.LocalZendServerStartup_CouldNotObtainAllProperties, + IHelpContextIds.ZEND_SERVER, 5000, MESSAGE_ID); + return Status.CANCEL_STATUS; } - - if(server.getDocumentRoot() == "" && defaultVHostInfo != null) { //$NON-NLS-1$ - // server document root folder has not been read from - // the configuration - VhostDetails vhostDetails = apiClient.vhostGetDetails(defaultVHostInfo.getId()); - String documentRoot = vhostDetails.getExtendedInfo().getDocRoot(); - server.setDocumentRoot(documentRoot); - } - } catch (MalformedURLException | WebApiException ex) { - Activator.logError(Messages.LocalZendServerStartup_UpdatingServerProperties_Error, ex); - NotificationManager.showWarningWithHelp(Messages.LocalZendServerStartup_NotFoundTitle, - Messages.LocalZendServerStartup_CouldNotObtainAllProperties, IHelpContextIds.ZEND_SERVER, - 5000, MESSAGE_ID); - return Status.CANCEL_STATUS; } monitor.subTask(Messages.LocalZendServerStartup_DetectingDebuggerSettings); diff --git a/zendserver-deployment-eclipse/org.zend.php.zendserver.deployment.ui/src/org/zend/php/zendserver/deployment/ui/zendserver/LocalZendServerWizardFragment.java b/zendserver-deployment-eclipse/org.zend.php.zendserver.deployment.ui/src/org/zend/php/zendserver/deployment/ui/zendserver/LocalZendServerWizardFragment.java index c2e26a64..7eb6ffaa 100644 --- a/zendserver-deployment-eclipse/org.zend.php.zendserver.deployment.ui/src/org/zend/php/zendserver/deployment/ui/zendserver/LocalZendServerWizardFragment.java +++ b/zendserver-deployment-eclipse/org.zend.php.zendserver.deployment.ui/src/org/zend/php/zendserver/deployment/ui/zendserver/LocalZendServerWizardFragment.java @@ -87,38 +87,41 @@ public boolean performFinish(IProgressMonitor monitor) throws CoreException { return composite.isComplete(); } - try { - VhostInfo defaultVHostInfo = null; - WebApiCredentials credentials = new BasicCredentials(zendTarget.getKey(), - zendTarget.getSecretKey()); - WebApiClient apiClient = new WebApiClient(credentials, zendTarget.getHost().toString()); - apiClient.setServerType(zendTarget.getServerType()); - VhostsList vhostsList = apiClient.vhostGetStatus(); - for (VhostInfo vhostInfo : vhostsList.getVhosts()) { - if (!vhostInfo.isDefaultVhost()) - continue; - - defaultVHostInfo = vhostInfo; - } - - if(server.getBaseURL() == "" && defaultVHostInfo != null) { //$NON-NLS-1$ - // server base URL has not been read from - // the configuration - String baseUrl = "http://localhost:" + Integer.toString(defaultVHostInfo.getPort()); //$NON-NLS-1$ - server.setBaseURL(baseUrl); - } - - if(server.getDocumentRoot() == "" && defaultVHostInfo != null) { //$NON-NLS-1$ - // server document root folder has not been read from - // the configuration - VhostDetails vhostDetails = apiClient.vhostGetDetails(defaultVHostInfo.getId()); - String documentRoot = vhostDetails.getExtendedInfo().getDocRoot(); - server.setDocumentRoot(documentRoot); + if (server.getBaseURL() == "" || server.getDocumentRoot() == "") { //$NON-NLS-1$ //$NON-NLS-2$ + try { + VhostInfo defaultVHostInfo = null; + WebApiCredentials credentials = new BasicCredentials(zendTarget.getKey(), + zendTarget.getSecretKey()); + WebApiClient apiClient = new WebApiClient(credentials, zendTarget.getHost().toString()); + apiClient.setServerType(zendTarget.getServerType()); + VhostsList vhostsList = apiClient.vhostGetStatus(); + for (VhostInfo vhostInfo : vhostsList.getVhosts()) { + if (!vhostInfo.isDefaultVhost()) + continue; + + defaultVHostInfo = vhostInfo; + } + + if (server.getBaseURL() == "" && defaultVHostInfo != null) { //$NON-NLS-1$ + // server base URL has not been read from + // the configuration + String baseUrl = "http://localhost:" + Integer.toString(defaultVHostInfo.getPort()); //$NON-NLS-1$ + server.setBaseURL(baseUrl); + } + + if (server.getDocumentRoot() == "" && defaultVHostInfo != null) { //$NON-NLS-1$ + // server document root folder has not been read from + // the configuration + VhostDetails vhostDetails = apiClient.vhostGetDetails(defaultVHostInfo.getId()); + String documentRoot = vhostDetails.getExtendedInfo().getDocRoot(); + server.setDocumentRoot(documentRoot); + } + } catch (MalformedURLException | WebApiException ex) { + Activator.logError(Messages.LocalZendServerWizardFragment_UpdatingServerProperties_Error, ex); + setMessage(Messages.LocalZendServerWizardFragment_UpdatingServerProperties_Error, + IMessageProvider.ERROR); + return composite.isComplete(); } - } catch (MalformedURLException | WebApiException ex) { - Activator.logError(Messages.LocalZendServerWizardFragment_UpdatingServerProperties_Error, ex); - setMessage(Messages.LocalZendServerWizardFragment_UpdatingServerProperties_Error, IMessageProvider.ERROR); - return composite.isComplete(); } monitor.subTask(Messages.LocalZendServerWizardFragment_DetectingDebuggerSettings);