Skip to content

Commit

Permalink
ECOSYS-33 fix format and copyright year
Browse files Browse the repository at this point in the history
  • Loading branch information
jGauravGupta committed May 5, 2020
1 parent 2d798fc commit eab4676
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 101 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/******************************************************************************
* Copyright (c) 2018-2019 Payara Foundation
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
* Copyright (c) 2020 Payara Foundation All rights reserved. This program and the accompanying
* materials are made available under the terms of the Eclipse Public License v2.0 which accompanies
* this distribution, and is available at http://www.eclipse.org/legal/epl-v20.html
* SPDX-License-Identifier: EPL-2.0
******************************************************************************/

Expand All @@ -29,96 +27,104 @@

public class AdminCredentialsDialog extends TitleAreaDialog {

private Text adminNameText;
private Text passwordText;

private static final String SAVE_LABEL = "Save";

private IServerWorkingCopy serverWorkingCopy;

private AdminCredentialsDialog(IServerWorkingCopy serverWorkingCopy, Shell parentShell) {
super(parentShell);
this.serverWorkingCopy = serverWorkingCopy;
}

public static void open(IServer server) {
Display display = PlatformUI.getWorkbench().getDisplay();
display.asyncExec(() -> {
IServerWorkingCopy serverWorkingCopy;
if (server instanceof IServerWorkingCopy) {
serverWorkingCopy = (IServerWorkingCopy) server;
} else {
serverWorkingCopy = server.createWorkingCopy();
}
AdminCredentialsDialog dialog = new AdminCredentialsDialog(serverWorkingCopy, display.getActiveShell());
dialog.create();
dialog.open();
});
}

@Override
public void create() {
super.create();
super.getShell().setText("Payara Administrator Credentials");
setTitle("Wrong user name or password");
setMessage("Authorization failed while checking " + serverWorkingCopy.getName()
+ " status. Please provide valid administrator credentials.", IMessageProvider.WARNING);
}

protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.OK_ID, SAVE_LABEL, true);
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}

@Override
protected Control createDialogArea(Composite parent) {
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridLayout layout = new GridLayout(2, false);
container.setLayout(layout);

createAdminNameComponent(container);
createPasswordComponent(container);

return area;
}

private void createAdminNameComponent(Composite container) {
Label adminNameLabel = new Label(container, SWT.NONE);
adminNameLabel.setText("Username");

GridData grid = new GridData();
grid.grabExcessHorizontalSpace = true;
grid.horizontalAlignment = GridData.FILL;

adminNameText = new Text(container, SWT.BORDER);
adminNameText.setText(serverWorkingCopy.getAttribute(PayaraServer.ATTR_ADMIN, "admin"));
adminNameText.setLayoutData(grid);
}

private void createPasswordComponent(Composite container) {
Label passwordLabel = new Label(container, SWT.NONE);
passwordLabel.setText("Password");

GridData grid = new GridData();
grid.grabExcessHorizontalSpace = true;
grid.horizontalAlignment = GridData.FILL;
passwordText = new Text(container, SWT.PASSWORD | SWT.BORDER);
passwordText.setText(serverWorkingCopy.getAttribute(PayaraServer.ATTR_ADMINPASS, ""));
passwordText.setLayoutData(grid);
}

@Override
protected void okPressed() {
try {
serverWorkingCopy.setAttribute(PayaraServer.ATTR_ADMIN, adminNameText.getText());
serverWorkingCopy.setAttribute(PayaraServer.ATTR_ADMINPASS, passwordText.getText());
serverWorkingCopy.save(true, null);
} catch (CoreException e) {
throw new RuntimeException(e);
}
super.okPressed();
}

}
private Text adminNameText;
private Text passwordText;

private static final String SAVE_LABEL = "Save";

private IServerWorkingCopy serverWorkingCopy;


private AdminCredentialsDialog(IServerWorkingCopy serverWorkingCopy, Shell parentShell) {
super(parentShell);
this.serverWorkingCopy = serverWorkingCopy;
}


public static void open(IServer server) {
Display display = PlatformUI.getWorkbench().getDisplay();
display.asyncExec(() -> {
IServerWorkingCopy serverWorkingCopy;
if (server instanceof IServerWorkingCopy) {
serverWorkingCopy = (IServerWorkingCopy) server;
} else {
serverWorkingCopy = server.createWorkingCopy();
}
AdminCredentialsDialog dialog = new AdminCredentialsDialog(serverWorkingCopy, display.getActiveShell());
dialog.create();
dialog.open();
});
}


@Override
public void create() {
super.create();
super.getShell().setText("Payara Administrator Credentials");
setTitle("Wrong user name or password");
setMessage("Authorization failed while checking " + serverWorkingCopy.getName()
+ " status. Please provide valid administrator credentials.", IMessageProvider.WARNING);
}


protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.OK_ID, SAVE_LABEL, true);
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}


@Override
protected Control createDialogArea(Composite parent) {
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridLayout layout = new GridLayout(2, false);
container.setLayout(layout);

createAdminNameComponent(container);
createPasswordComponent(container);

return area;
}


private void createAdminNameComponent(Composite container) {
Label adminNameLabel = new Label(container, SWT.NONE);
adminNameLabel.setText("Username");

GridData grid = new GridData();
grid.grabExcessHorizontalSpace = true;
grid.horizontalAlignment = GridData.FILL;

adminNameText = new Text(container, SWT.BORDER);
adminNameText.setText(serverWorkingCopy.getAttribute(PayaraServer.ATTR_ADMIN, "admin"));
adminNameText.setLayoutData(grid);
}


private void createPasswordComponent(Composite container) {
Label passwordLabel = new Label(container, SWT.NONE);
passwordLabel.setText("Password");

GridData grid = new GridData();
grid.grabExcessHorizontalSpace = true;
grid.horizontalAlignment = GridData.FILL;
passwordText = new Text(container, SWT.PASSWORD | SWT.BORDER);
passwordText.setText(serverWorkingCopy.getAttribute(PayaraServer.ATTR_ADMINPASS, ""));
passwordText.setLayoutData(grid);
}


@Override
protected void okPressed() {
try {
serverWorkingCopy.setAttribute(PayaraServer.ATTR_ADMIN, adminNameText.getText());
serverWorkingCopy.setAttribute(PayaraServer.ATTR_ADMINPASS, passwordText.getText());
serverWorkingCopy.save(true, null);
} catch (CoreException e) {
throw new RuntimeException(e);
}
super.okPressed();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ private boolean isRunning(PayaraServerBehaviour serverBehavior) throws CoreExcep
abort(canntCommunicate, new RuntimeException(abortLaunchMsg + domainNotMatch + checkVpnOrProxy));
break;
case RUNNING_CREDENTIAL_PROBLEM:
AdminCredentialsDialog.open(thisServer);
AdminCredentialsDialog.open(thisServer);
abort(canntCommunicate, new RuntimeException(abortLaunchMsg + wrongUsernamePassword));
break;
case RUNNING_DOMAIN_MATCHING:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,16 @@ public ResultProcess call() throws Exception {
startupConsole.stopLogging();
payaraProcess.destroy();

throw new PayaraLaunchException("BAD GATEWAY response code returned. Check your proxy settings. Killing startup process.", payaraProcess);
throw new PayaraLaunchException(
"BAD GATEWAY response code returned. Check your proxy settings. Killing startup process.",
payaraProcess);
case RUNNING_CREDENTIAL_PROBLEM:
startupConsole.stopLogging();
payaraProcess.destroy();
AdminCredentialsDialog.open(payaraServerBehaviour.getServer());

throw new PayaraLaunchException("Wrong user name or password. Killing startup process.", payaraProcess);
throw new PayaraLaunchException("Wrong user name or password. Killing startup process.",
payaraProcess);
case RUNNING_DOMAIN_MATCHING:
startupConsole.stopLogging();
break check_server_status;
Expand Down

0 comments on commit eab4676

Please sign in to comment.