Skip to content

Commit

Permalink
Merge pull request #81 from zendtech/dariusz
Browse files Browse the repository at this point in the history
ZSTD-5213 [Regression] Cannot detect local server
  • Loading branch information
dariusz-michura committed Sep 11, 2015
2 parents dbfce7a + caf8bd8 commit 240ecb3
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,44 +137,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.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.LocalZendServerStartup_UpdatingServerProperties_Error, ex);
NotificationManager.showWarningWithHelp(Messages.LocalZendServerStartup_NotFoundTitle,
Messages.LocalZendServerStartup_CouldNotObtainAllProperties,
IHelpContextIds.ZEND_SERVER, 5000, MESSAGE_ID);
return Status.CANCEL_STATUS;
}
} 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 240ecb3

Please sign in to comment.