Skip to content

Commit

Permalink
Avoid duplicate constants.
Browse files Browse the repository at this point in the history
  • Loading branch information
mnlipp committed Feb 24, 2025
1 parent c45c452 commit bc33640
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ public class Constants {
/** The Constant APP_NAME. */
public static final String APP_NAME = "vm-runner";

/** The Constant COMP_DISPLAY_SECRETS. */
public static final String COMP_DISPLAY_SECRET = "display-secret";

/** The Constant VM_OP_NAME. */
public static final String VM_OP_NAME = "vm-operator";

Expand All @@ -41,4 +38,20 @@ public class Constants {

/** The Constant VM_OP_KIND_VM_POOL. */
public static final String VM_OP_KIND_VM_POOL = "VmPool";

/** The Constant COMP_DISPLAY_SECRETS. */
public static final String COMP_DISPLAY_SECRET = "display-secret";

/** The Constant DATA_DISPLAY_PASSWORD. */
public static final String DATA_DISPLAY_PASSWORD = "display-password";

/** The Constant DATA_PASSWORD_EXPIRY. */
public static final String DATA_PASSWORD_EXPIRY = "password-expiry";

/** The Constant DATA_DISPLAY_USER. */
public static final String DATA_DISPLAY_USER = "display-user";

/** The Constant DATA_DISPLAY_LOGIN. */
public static final String DATA_DISPLAY_LOGIN = "login-user";

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,12 @@

package org.jdrupes.vmoperator.manager;

// TODO: Auto-generated Javadoc
/**
* Some constants.
*/
@SuppressWarnings("PMD.DataClass")
public class Constants extends org.jdrupes.vmoperator.common.Constants {

/** The Constant COMP_DISPLAY_SECRET. */
public static final String COMP_DISPLAY_SECRET = "display-secret";

/** The Constant DATA_DISPLAY_PASSWORD. */
public static final String DATA_DISPLAY_PASSWORD = "display-password";

/** The Constant DATA_PASSWORD_EXPIRY. */
public static final String DATA_PASSWORD_EXPIRY = "password-expiry";

/** The Constant DATA_DISPLAY_USER. */
public static final String DATA_DISPLAY_USER = "display-user";

/** The Constant DATA_DISPLAY_LOGIN. */
public static final String DATA_DISPLAY_LOGIN = "login-user";

/** The Constant STATE_RUNNING. */
public static final String STATE_RUNNING = "Running";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import java.nio.file.Path;
import java.util.Objects;
import java.util.logging.Level;
import static org.jdrupes.vmoperator.common.Constants.DATA_DISPLAY_PASSWORD;
import static org.jdrupes.vmoperator.common.Constants.DATA_PASSWORD_EXPIRY;
import org.jdrupes.vmoperator.runner.qemu.commands.QmpSetDisplayPassword;
import org.jdrupes.vmoperator.runner.qemu.commands.QmpSetPasswordExpiry;
import org.jdrupes.vmoperator.runner.qemu.events.ConfigureQemu;
Expand All @@ -40,8 +42,6 @@
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class DisplayController extends Component {

public static final String DISPLAY_PASSWORD_FILE = "display-password";
public static final String PASSWORD_EXPIRY_FILE = "password-expiry";
private String currentPassword;
private String protocol;
private final Path configDir;
Expand All @@ -57,7 +57,7 @@ public class DisplayController extends Component {
public DisplayController(Channel componentChannel, Path configDir) {
super(componentChannel);
this.configDir = configDir;
fire(new WatchFile(configDir.resolve(DISPLAY_PASSWORD_FILE)));
fire(new WatchFile(configDir.resolve(DATA_DISPLAY_PASSWORD)));
}

/**
Expand All @@ -83,7 +83,7 @@ public void onConfigureQemu(ConfigureQemu event) {
@Handler
@SuppressWarnings("PMD.EmptyCatchBlock")
public void onFileChanged(FileChanged event) {
if (event.path().equals(configDir.resolve(DISPLAY_PASSWORD_FILE))) {
if (event.path().equals(configDir.resolve(DATA_DISPLAY_PASSWORD))) {
updatePassword();
}
}
Expand All @@ -100,7 +100,7 @@ private void updatePassword() {

private boolean setDisplayPassword() {
String password;
Path dpPath = configDir.resolve(DISPLAY_PASSWORD_FILE);
Path dpPath = configDir.resolve(DATA_DISPLAY_PASSWORD);
if (dpPath.toFile().canRead()) {
logger.finer(() -> "Found display password");
try {
Expand All @@ -125,7 +125,7 @@ private boolean setDisplayPassword() {
}

private void setPasswordExpiry() {
Path pePath = configDir.resolve(PASSWORD_EXPIRY_FILE);
Path pePath = configDir.resolve(DATA_PASSWORD_EXPIRY);
if (!pePath.toFile().canRead()) {
return;
}
Expand Down

0 comments on commit bc33640

Please sign in to comment.