| | |
| | | |
| | | package org.opends.guitools.controlpanel.datamodel; |
| | | |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | import java.io.File; |
| | | import java.net.InetAddress; |
| | | import java.util.Collection; |
| | |
| | | desc.setInstallPath(installPath); |
| | | desc.setInstancePath(Utils.getInstancePathFromInstallPath(installPath)); |
| | | boolean windowsServiceEnabled = false; |
| | | if (Utilities.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | int result = ConfigureWindowsService.serviceState(null, null); |
| | | windowsServiceEnabled = |
| | |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.opends.server.types.OperatingSystem; |
| | | import com.forgerock.opendj.util.OperatingSystem; |
| | | import org.opends.server.types.Schema; |
| | | |
| | | import static org.opends.server.types.CommonSchemaElements.*; |
| | |
| | | { |
| | | sameInstallAndInstance = instance.equals(install); |
| | | if (!sameInstallAndInstance && |
| | | (isLocal() || (isWindows() == Utilities.isWindows()))) |
| | | (isLocal() || (OperatingSystem.isWindows()))) |
| | | { |
| | | File f1 = new File(instance); |
| | | File f2 = new File(install); |
| | |
| | | } |
| | | } |
| | | |
| | | if (equals && Utilities.isWindows()) |
| | | if (equals && OperatingSystem.isWindows()) |
| | | { |
| | | equals = |
| | | desc.isWindowsServiceEnabled() == isWindowsServiceEnabled(); |
| | |
| | | boolean isWindows; |
| | | if (isLocal()) |
| | | { |
| | | isWindows = Utilities.isWindows(); |
| | | isWindows = OperatingSystem.isWindows(); |
| | | } |
| | | else |
| | | { |
| | |
| | | package org.opends.guitools.controlpanel.task; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | |
| | | protected String getCommandLinePath(String scriptBasicName) |
| | | { |
| | | String cmdLineName; |
| | | if (Utilities.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | cmdLineName = getBinaryDir()+scriptBasicName+".bat"; |
| | | } |
| | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.Dimension; |
| | |
| | | { |
| | | String path; |
| | | |
| | | if (desc.isLocal() || (desc.isWindows() == Utilities.isWindows())) |
| | | if (desc.isLocal() || (desc.isWindows() == isWindows())) |
| | | { |
| | | File f = new File(desc.getInstancePath(), |
| | | org.opends.quicksetup.Installation.BACKUPS_PATH_RELATIVE); |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isMacOS; |
| | | |
| | | import java.awt.Color; |
| | | import java.awt.Font; |
| | | |
| | |
| | | * The grey color background that is used for instance as background for the |
| | | * buttons in the dialogs (in the bottom of the dialogs). |
| | | */ |
| | | public static final Color greyBackground = Utilities.isWindows() ? |
| | | public static final Color greyBackground = isWindows() ? |
| | | UIManager.getColor("MenuBar.background") : |
| | | UIManager.getColor("Panel.background"); |
| | | |
| | |
| | | * The grid color for the table. |
| | | */ |
| | | public static final Color gridColor = |
| | | Utilities.isMacOS() ? defaultBorderColor : |
| | | isMacOS() ? defaultBorderColor : |
| | | UIManager.getColor("Table.gridColor"); |
| | | /** |
| | | * The color of the text in the table. |
| | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | |
| | | private File getJavaFile(File javaHome) |
| | | { |
| | | File javaFile = new File(javaHome, "bin"); |
| | | if (Utilities.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | javaFile = new File(javaFile, "java.exe"); |
| | | } |
| | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | |
| | | { |
| | | ArrayList<Category> categories = new ArrayList<Category>(); |
| | | LocalizableMessage[][] labels; |
| | | if (Utilities.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | labels = new LocalizableMessage[][] { |
| | | { |
| | |
| | | classes.add(ConnectionHandlerMonitoringPanel.class); |
| | | classes.add(ManageTasksPanel.class); |
| | | classes.add(JavaPropertiesPanel.class); |
| | | if (Utilities.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | classes.add(WindowsServicePanel.class); |
| | | } |
| | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isMacOS; |
| | | |
| | | import java.awt.event.ActionEvent; |
| | | import java.awt.event.ActionListener; |
| | |
| | | |
| | | addMenus(); |
| | | |
| | | if (Utilities.isMacOS()) |
| | | if (isMacOS()) |
| | | { |
| | | setMacOSQuitHandler(); |
| | | } |
| | |
| | | }); |
| | | menu.add(menuItem); |
| | | |
| | | if (!Utilities.isMacOS()) |
| | | if (!isMacOS()) |
| | | { |
| | | menuItem = Utilities.createMenuItem(INFO_CTRL_PANEL_EXIT_MENU.get()); |
| | | menuItem.addActionListener(new ActionListener() |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui.components; |
| | | |
| | | import static com.forgerock.opendj.util.OperatingSystem.isMacOS; |
| | | |
| | | import java.awt.Graphics; |
| | | import java.awt.Insets; |
| | | import java.awt.Rectangle; |
| | |
| | | import javax.swing.tree.TreePath; |
| | | |
| | | import org.opends.guitools.controlpanel.ui.renderer.TreeCellRenderer; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | |
| | | /** |
| | | * The tree that is used in different places in the Control Panel (schema |
| | |
| | | } |
| | | MouseEvent newEvent = getTranslatedEvent(ev); |
| | | |
| | | if (Utilities.isMacOS() && ev.isPopupTrigger() && |
| | | if (isMacOS() && ev.isPopupTrigger() && |
| | | (ev.getButton() != MouseEvent.BUTTON1)) |
| | | { |
| | | MouseEvent baseEvent = ev; |
| | |
| | | import java.util.Arrays; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.api.MatchingRule; |
| | | import org.opends.server.config.ConfigConstants; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | | import com.forgerock.opendj.util.OperatingSystem; |
| | | |
| | | /** |
| | | * Class used to retrieve the schema from the schema files. |
| | |
| | | { |
| | | accept = true; |
| | | } |
| | | else if (Utils.isWindows()) |
| | | else if (OperatingSystem.isWindows()) |
| | | { |
| | | accept = f.getName().toLowerCase().endsWith(".ldif"); |
| | | } |
| | |
| | | package org.opends.guitools.controlpanel.util; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isMacOS; |
| | | |
| | | import java.awt.Color; |
| | | import java.awt.Component; |
| | |
| | | INFO_CTRL_PANEL_NOT_IMPLEMENTED.get(); |
| | | |
| | | /** |
| | | * Returns <CODE>true</CODE> if we are running Mac OS and <CODE>false</CODE> |
| | | * otherwise. |
| | | * @return <CODE>true</CODE> if we are running Mac OS and <CODE>false</CODE> |
| | | * otherwise. |
| | | */ |
| | | public static boolean isMacOS() |
| | | { |
| | | String os = System.getProperty("os.name").toLowerCase(); |
| | | return os.indexOf("mac") != -1; |
| | | } |
| | | |
| | | /** |
| | | * Creates a combo box. |
| | | * @return a combo box. |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns <CODE>true</CODE> if we are running Windows and <CODE>false</CODE> |
| | | * otherwise. |
| | | * @return <CODE>true</CODE> if we are running Windows and <CODE>false</CODE> |
| | | * otherwise. |
| | | */ |
| | | public static boolean isWindows() |
| | | { |
| | | String os = System.getProperty("os.name").toLowerCase(); |
| | | return os.indexOf("windows") != -1; |
| | | } |
| | | |
| | | /** |
| | | * Derives a color by adding the specified offsets to the base color's |
| | | * hue, saturation, and brightness values. The resulting hue, saturation, |
| | | * and brightness values will be contrained to be between 0 and 1. |
| | |
| | | final JTable table = new JTable(tableModel); |
| | | table.setShowGrid(true); |
| | | table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); |
| | | boolean isMacOS = Utilities.isMacOS(); |
| | | table.setGridColor(ColorAndFontConstants.gridColor); |
| | | if (isMacOS) |
| | | if (isMacOS()) |
| | | { |
| | | table.getTableHeader().setBorder( |
| | | BorderFactory.createMatteBorder(1, 1, 0, 0, |
| | | ColorAndFontConstants.gridColor)); |
| | | } |
| | | if (Utilities.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | table.getTableHeader().setBorder( |
| | | BorderFactory.createMatteBorder(1, 1, 0, 1, |
| | |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.messages.ToolMessages.ERR_ERROR_PARSING_ARGS; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.messages.ToolMessages; |
| | |
| | | super(args); |
| | | |
| | | String scriptName; |
| | | if (Utils.isWindows()) { |
| | | if (isWindows()) { |
| | | scriptName = Installation.WINDOWS_UNINSTALL_FILE_NAME; |
| | | } else { |
| | | scriptName = Installation.UNIX_UNINSTALL_FILE_NAME; |
| | |
| | | import static org.opends.quicksetup.Step.*; |
| | | import static org.opends.quicksetup.util.Utils.*; |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | import java.io.*; |
| | | import java.net.InetAddress; |
| | |
| | | |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static org.opends.server.util.SetupUtils.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | |
| | | is = process.getInputStream(); |
| | | out = process.getOutputStream(); |
| | | final OutputStream fOut = out; |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | // In windows if there is an error we wait the user to click on |
| | | // return to continue. |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | |
| | | buf.append(Constants.LINE_SEPARATOR); |
| | | buf.append("- ").append(msg); |
| | | } |
| | | String cmd = Utils.isWindows() ? |
| | | String cmd = isWindows() ? |
| | | Installation.WINDOWS_SETUP_FILE_NAME : |
| | | Installation.UNIX_SETUP_FILE_NAME; |
| | | installationMsg = INFO_INSTALLSTATUS_INSTALLED_CLI.get(cmd, buf); |
| | |
| | | package org.opends.quicksetup; |
| | | |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isMacOS; |
| | | |
| | | |
| | | import java.io.*; |
| | | import java.util.*; |
| | |
| | | public File getBinariesDirectory() |
| | | { |
| | | File binPath; |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | binPath = new File(getRootDirectory(), WINDOWS_BINARIES_PATH_RELATIVE); |
| | | } |
| | |
| | | public File getCommandFile(String command) |
| | | { |
| | | File commandFile; |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | commandFile = new File(getBinariesDirectory(), command + ".bat"); |
| | | } |
| | |
| | | public File getServerStartCommandFile() |
| | | { |
| | | File startCommandFile; |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | startCommandFile = new File(getBinariesDirectory(), |
| | | WINDOWS_START_FILE_NAME); |
| | |
| | | public File getServerStopCommandFile() |
| | | { |
| | | File stopCommandFile; |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | stopCommandFile = new File(getBinariesDirectory(), |
| | | WINDOWS_STOP_FILE_NAME); |
| | |
| | | public File getControlPanelCommandFile() |
| | | { |
| | | File controlPanelCommandFile; |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | controlPanelCommandFile = new File(getBinariesDirectory(), |
| | | WINDOWS_CONTROLPANEL_FILE_NAME); |
| | | } |
| | | else if (Utils.isMacOS()) |
| | | else if (isMacOS()) |
| | | { |
| | | controlPanelCommandFile = new File(getRootDirectory() + File.separator |
| | | + MAC_APPLICATIONS_PATH_RELATIVE, MAC_CONTROLPANEL_FILE_NAME); |
| | |
| | | import org.opends.server.util.SetupUtils; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import com.forgerock.opendj.util.OperatingSystem; |
| | | |
| | | import static org.forgerock.util.Utils.*; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static org.opends.quicksetup.Step.*; |
| | |
| | | serverProperties.put(ADSContext.ServerProperty.ID, serverID); |
| | | |
| | | serverProperties.put(ADSContext.ServerProperty.HOST_OS, |
| | | getOSString()); |
| | | OperatingSystem.getOperatingSystem().toString()); |
| | | return serverProperties; |
| | | } |
| | | |
| | |
| | | long requiredInMb = getRequiredInstallSpace() / (1024 * 1024); |
| | | errorMsgs.add(INFO_NOT_ENOUGH_DISK_SPACE.get(serverLocation, requiredInMb)); |
| | | qs.displayFieldInvalid(FieldName.SERVER_LOCATION, true); |
| | | } else if (isWindows() && (serverLocation.contains("%"))) |
| | | } else if (OperatingSystem.isWindows() && (serverLocation.contains("%"))) |
| | | { |
| | | errorMsgs.add(INFO_INVALID_CHAR_IN_PATH.get("%")); |
| | | qs.displayFieldInvalid(FieldName.SERVER_LOCATION, true); |
| | |
| | | import org.opends.messages.ReplicationMessages; |
| | | |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | import org.opends.server.tools.ConfigureDS; |
| | | import org.opends.server.tools.ConfigureWindowsService; |
| | |
| | | |
| | | /** |
| | | * This is the only class that uses classes in org.opends.server (excluding the |
| | | * case of DynamicConstants, SetupUtils, OperatingSystem and CertificateManager |
| | | * case of DynamicConstants, SetupUtils and CertificateManager |
| | | * which are already included in quicksetup.jar). |
| | | * |
| | | * Important note: do not include references to this class until OpenDS.jar has |
| | |
| | | File installPath = new File(application.getInstallationPath()); |
| | | ArrayList<String> argList = new ArrayList<String>(); |
| | | File binPath; |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | binPath = |
| | | new File(installPath, Installation.WINDOWS_BINARIES_PATH_RELATIVE); |
| | |
| | | new File(installPath, Installation.UNIX_BINARIES_PATH_RELATIVE); |
| | | } |
| | | File importPath; |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | importPath = new File(binPath, Installation.WINDOWS_IMPORT_LDIF); |
| | | } else |
| | |
| | | { |
| | | fLib.mkdir(); |
| | | } |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | destinationFile = Utils.getPath(libDir, |
| | | Installation.SET_JAVA_PROPERTIES_FILE_WINDOWS); |
| | |
| | | |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | import java.io.File; |
| | | |
| | |
| | | public SetupLauncher(String[] args) { |
| | | super(args); |
| | | String scriptName; |
| | | if (Utils.isWindows()) { |
| | | if (isWindows()) { |
| | | scriptName = Installation.WINDOWS_SETUP_FILE_NAME; |
| | | } else { |
| | | scriptName = Installation.UNIX_SETUP_FILE_NAME; |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | |
| | | import java.io.PrintStream; |
| | |
| | | |
| | | checkAbort(); |
| | | |
| | | if (Utils.isWindows() && getUserData().getEnableWindowsService()) |
| | | if (isWindows() && getUserData().getEnableWindowsService()) |
| | | { |
| | | if (isVerbose()) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | if (Utils.isWindows() && getUserData().getEnableWindowsService()) |
| | | if (isWindows() && getUserData().getEnableWindowsService()) |
| | | { |
| | | totalTime += hmTime.get(InstallProgressStep.ENABLING_WINDOWS_SERVICE); |
| | | steps.add(InstallProgressStep.ENABLING_WINDOWS_SERVICE); |
| | |
| | | |
| | | import static org.forgerock.util.Utils.*; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | import org.opends.admin.ads.ServerDescriptor; |
| | | import org.opends.quicksetup.Constants; |
| | |
| | | gbc.weightx = 1.0; |
| | | auxPanel.add(Box.createHorizontalGlue(), gbc); |
| | | bottomComponent.add(auxPanel, gbc); |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD; |
| | | bottomComponent.add(getEnableWindowsServiceCheckBox(), gbc); |
| | |
| | | { |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | lastUserData.setEnableWindowsService( |
| | | enableWindowsServiceCheckBox.isSelected()); |
| | |
| | | import org.opends.server.util.SetupUtils; |
| | | |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | /** |
| | | * This is an implementation of the Installer class that is used to install |
| | |
| | | |
| | | checkAbort(); |
| | | |
| | | if (Utils.isWindows() && getUserData().getEnableWindowsService()) |
| | | if (isWindows() && getUserData().getEnableWindowsService()) |
| | | { |
| | | if (isVerbose()) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | if (Utils.isWindows() && getUserData().getEnableWindowsService()) |
| | | if (isWindows() && getUserData().getEnableWindowsService()) |
| | | { |
| | | totalTime += hmTime.get(InstallProgressStep.ENABLING_WINDOWS_SERVICE); |
| | | steps.add(InstallProgressStep.ENABLING_WINDOWS_SERVICE); |
| | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isMacOS; |
| | | |
| | | import javax.swing.*; |
| | | |
| | |
| | | |
| | | package org.opends.quicksetup.ui; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import org.opends.quicksetup.util.Utils; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isMacOS; |
| | | |
| | | import javax.swing.*; |
| | | import javax.swing.text.JTextComponent; |
| | |
| | | static public void setFrameIcon(JFrame frame) |
| | | { |
| | | UIFactory.IconType ic; |
| | | if (Utils.isMacOS()) { |
| | | if (isMacOS()) { |
| | | ic = UIFactory.IconType.MINIMIZED_MAC; |
| | | } else { |
| | | ic = UIFactory.IconType.MINIMIZED; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.quicksetup.util; |
| | |
| | | import java.io.File; |
| | | |
| | | import javax.swing.filechooser.FileFilter; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | /** |
| | | * This is a class used to be able to filter on certain type of files |
| | |
| | | if (f.isDirectory()) |
| | | { |
| | | accept = true; |
| | | } else if (Utils.isWindows()) |
| | | } else if (isWindows()) |
| | | { |
| | | accept = |
| | | f.getName().toLowerCase().endsWith("." + extension.toLowerCase()); |
| | |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isUnix; |
| | | |
| | | /** |
| | | * Utility class for use by applications containing methods for managing |
| | |
| | | if (destination.exists()) { |
| | | // TODO: set the file's permissions. This is made easier in |
| | | // Java 1.6 but until then use the TestUtilities methods |
| | | if (Utils.isUnix()) { |
| | | if (isUnix()) { |
| | | String permissions = |
| | | Utils.getFileSystemPermissions(objectFile); |
| | | Utils.setPermissionsUnix( |
| | |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static org.opends.quicksetup.util.Utils.*; |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | |
| | | org.opends.server.protocols.ldap. |
| | | LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR; |
| | | if ((returnValue == clientSideError) || (returnValue == 0)) { |
| | | if (Utils.isWindows()) { |
| | | if (isWindows()) { |
| | | /* |
| | | * Sometimes the server keeps some locks on the files. |
| | | * TODO: remove this code once stop-ds returns properly when |
| | |
| | | } |
| | | if (!connected) |
| | | { |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | throw new ApplicationException( |
| | | ReturnCode.START_ERROR, |
| | |
| | | import static org.forgerock.util.Utils.*; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static org.opends.server.util.DynamicConstants.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isUnix; |
| | | |
| | | import java.io.*; |
| | | import java.net.InetAddress; |
| | |
| | | String script; |
| | | String libPath = Utils.getPath(installPath, |
| | | Installation.LIBRARIES_PATH_RELATIVE); |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | script = Utils.getScriptPath(Utils.getPath(libPath, |
| | | Installation.SCRIPT_UTIL_FILE_WINDOWS)); |
| | |
| | | env.remove("OPENDJ_JAVA_BIN"); |
| | | // In windows by default the scripts ask the user to click on enter when |
| | | // they fail. Set this environment variable to avoid it. |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | env.put("DO_NOT_PAUSE", "true"); |
| | | } |
| | |
| | | logger.info(LocalizableMessage.raw("The output: "+line)); |
| | | if (line.contains("ERROR: The detected Java version")) |
| | | { |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | // If we are running windows, the process get blocked waiting for |
| | | // user input. Just wait for a certain time to print the output |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns <CODE>true</CODE> if we are running under windows and |
| | | * <CODE>false</CODE> otherwise. |
| | | * @return <CODE>true</CODE> if we are running under windows and |
| | | * <CODE>false</CODE> otherwise. |
| | | */ |
| | | public static boolean isWindows() |
| | | { |
| | | return SetupUtils.isWindows(); |
| | | } |
| | | |
| | | /** |
| | | * Returns <CODE>true</CODE> if we are running under Mac OS and |
| | | * <CODE>false</CODE> otherwise. |
| | | * @return <CODE>true</CODE> if we are running under Mac OS and |
| | | * <CODE>false</CODE> otherwise. |
| | | */ |
| | | public static boolean isMacOS() |
| | | { |
| | | return SetupUtils.isMacOS(); |
| | | } |
| | | |
| | | /** |
| | | * Returns <CODE>true</CODE> if we are running under Unix and |
| | | * <CODE>false</CODE> otherwise. |
| | | * @return <CODE>true</CODE> if we are running under Unix and |
| | | * <CODE>false</CODE> otherwise. |
| | | */ |
| | | public static boolean isUnix() |
| | | { |
| | | return SetupUtils.isUnix(); |
| | | } |
| | | |
| | | /** |
| | | * Returns a String representation of the OS we are running. |
| | | * @return a String representation of the OS we are running. |
| | | */ |
| | | public static String getOSString() |
| | | { |
| | | return SetupUtils.getOSString(); |
| | | } |
| | | |
| | | /** |
| | | * Returns <CODE>true</CODE> if the parent directory for the provided path |
| | | * exists and <CODE>false</CODE> otherwise. |
| | | * @param path the path that we are analyzing. |
| | |
| | | catch (Throwable t) |
| | | { |
| | | String setupFile; |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | setupFile = Installation.WINDOWS_SETUP_FILE_NAME; |
| | | } |
| | |
| | | int initialIndex = 1; |
| | | StringBuilder sbSeparator = new StringBuilder(); |
| | | sbSeparator.append(formatter.getSpace()); |
| | | if (!Utils.isWindows()) |
| | | if (!isWindows()) |
| | | { |
| | | sbSeparator.append("\\"); |
| | | sbSeparator.append(formatter.getLineBreak()); |
| | |
| | | public static String escapeCommandLineValue(String value) |
| | | { |
| | | StringBuilder b = new StringBuilder(); |
| | | if (Utils.isUnix()) |
| | | if (isUnix()) |
| | | { |
| | | for (int i=0 ; i<value.length(); i++) |
| | | { |
| | |
| | | { |
| | | ArrayList<String> cmdLine = new ArrayList<String>(); |
| | | String setupFile; |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | setupFile = Installation.WINDOWS_SETUP_FILE_NAME; |
| | | } |
| | |
| | | cmdLine.add("--rootUserPassword"); |
| | | cmdLine.add(OBFUSCATED_VALUE); |
| | | |
| | | if (Utils.isWindows() && userData.getEnableWindowsService()) |
| | | if (isWindows() && userData.getEnableWindowsService()) |
| | | { |
| | | cmdLine.add("--enableWindowsService"); |
| | | } |
| | |
| | | */ |
| | | |
| | | package org.opends.quicksetup.util; |
| | | |
| | | |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isMacOS; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import java.io.IOException; |
| | |
| | | { |
| | | try |
| | | { |
| | | if (Utils.isMacOS()) |
| | | if (isMacOS()) |
| | | { |
| | | Class<?> fileMgr = Class.forName("com.apple.eio.FileManager"); |
| | | Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] |
| | | { String.class }); |
| | | openURL.invoke(null, url); |
| | | |
| | | } else if (Utils.isWindows()) |
| | | } else if (isWindows()) |
| | | { |
| | | String[] cmd = {"rundll32", "url.dll,FileProtocolHandler", url}; |
| | | Runtime.getRuntime().exec(cmd); |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isUnix; |
| | | |
| | | import org.opends.quicksetup.ApplicationException; |
| | | import org.opends.quicksetup.Application; |
| | |
| | | nEntries++; |
| | | } |
| | | |
| | | if (Utils.isUnix()) { |
| | | if (isUnix()) { |
| | | // Change the permissions for UNIX systems |
| | | for (String perm : permissions.keySet()) { |
| | | ArrayList<String> paths = permissions.get(perm); |
| | |
| | | |
| | | import static org.opends.quicksetup.util.Utils.*; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | /** |
| | | * This class is used to download the files that have been marked as lazy |
| | |
| | | logger.error(LocalizableMessage.raw("Could not find service: "+ |
| | | Utils.JNLP_SERVICE_NAME, e)); |
| | | String setupFile; |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | setupFile = Installation.WINDOWS_SETUP_FILE_NAME; |
| | | } |
| | |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.NameForm; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.OperatingSystem; |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.Privilege; |
| | | import org.opends.server.types.RestoreConfig; |
| | |
| | | import com.forgerock.opendj.cli.CommonArguments; |
| | | import com.forgerock.opendj.cli.IntegerArgument; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | import com.forgerock.opendj.util.OperatingSystem; |
| | | |
| | | /** |
| | | * This class defines the core of the Directory Server. It manages the startup |
| | |
| | | public static boolean isRunningAsWindowsService() |
| | | { |
| | | boolean isRunningAsWindowsService; |
| | | if (SetupUtils.isWindows()) |
| | | if (OperatingSystem.isWindows()) |
| | | { |
| | | isRunningAsWindowsService = ConfigureWindowsService.serviceState(null, |
| | | null) == ConfigureWindowsService.SERVICE_STATE_ENABLED; |
| | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.hasUAC; |
| | | |
| | | /** |
| | | * This class is used to configure the Windows service for this instance on |
| | |
| | | |
| | | String[] cmd; |
| | | |
| | | if (SetupUtils.hasUAC()) |
| | | if (hasUAC()) |
| | | { |
| | | cmd = new String[] { |
| | | getLauncherBinaryFullPath(), |
| | |
| | | LocalizableMessage msg; |
| | | String serverRoot = getServerRoot(); |
| | | String[] cmd; |
| | | if (SetupUtils.hasUAC()) |
| | | if (hasUAC()) |
| | | { |
| | | cmd = new String[] { |
| | | getLauncherBinaryFullPath(), |
| | |
| | | int returnValue; |
| | | LocalizableMessage msg; |
| | | String[] cmd; |
| | | if (SetupUtils.hasUAC()) |
| | | if (hasUAC()) |
| | | { |
| | | cmd = new String[] { |
| | | getLauncherBinaryFullPath(), |
| | |
| | | import org.opends.server.loggers.JDKLogging; |
| | | import org.opends.server.types.FilePermission; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.opends.server.types.OperatingSystem; |
| | | import org.opends.server.util.EmbeddedUtils; |
| | | import org.opends.server.util.SetupUtils; |
| | | |
| | |
| | | import com.forgerock.opendj.cli.BooleanArgument; |
| | | import com.forgerock.opendj.cli.CommonArguments; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | import com.forgerock.opendj.util.OperatingSystem; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | |
| | | |
| | | EmbeddedUtils.initializeForClientUse(); |
| | | |
| | | OperatingSystem operatingSystem = DirectoryServer.getOperatingSystem(); |
| | | if (! OperatingSystem.isUNIXBased(operatingSystem)) |
| | | if (! OperatingSystem.isUnixBased()) |
| | | { |
| | | err.println(ERR_CREATERC_ONLY_RUNS_ON_UNIX.get()); |
| | | return 1; |
| | |
| | | import static com.forgerock.opendj.cli.Utils.CONFIRMATION_MAX_TRIES; |
| | | import static com.forgerock.opendj.cli.Utils.canWrite; |
| | | import static org.forgerock.util.Utils.joinAsString; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.File; |
| | |
| | | // Use this instead a call to Installation to avoid to launch a new JVM |
| | | // just to retrieve a path. |
| | | String root = Utils.getInstallPathFromClasspath(); |
| | | if (SetupUtils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | String binDir = Utils.getPath(root, |
| | | Installation.WINDOWS_BINARIES_PATH_RELATIVE); |
| | |
| | | { |
| | | boolean enableService = false; |
| | | // If we are in Windows ask if the server must run as a windows service. |
| | | if (SetupUtils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | if (argParser.enableWindowsServiceArg.isPresent()) |
| | | { |
| | |
| | | println(INFO_INSTALLDS_DO_NOT_START_SERVER.get()); |
| | | } |
| | | |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | if (uData.getEnableWindowsService()) |
| | | { |
| | |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.HashSet; |
| | |
| | | addArgument(cliArg); |
| | | |
| | | String defaultProgName; |
| | | if (SetupUtils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | defaultProgName = Installation.WINDOWS_SETUP_FILE_NAME; |
| | | } |
| | |
| | | "enableWindowsService", |
| | | INFO_INSTALLDS_DESCRIPTION_ENABLE_WINDOWS_SERVICE.get()); |
| | | enableWindowsServiceArg.setPropertyName("enableWindowsService"); |
| | | if (SetupUtils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | addArgument(enableWindowsServiceArg); |
| | | } |
| | |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | /** |
| | | * This class is used to update the scripts that are used to launch the command |
| | |
| | | try |
| | | { |
| | | String value; |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | value = getWindowsContents(overwriteEnvJavaHome, overwriteEnvJavaArgs, |
| | | defaultJavaHome, defaultJavaArgs, properties); |
| | |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static com.forgerock.opendj.cli.Utils.canWrite; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | import java.io.File; |
| | | import java.util.LinkedHashSet; |
| | |
| | | if (root != null) |
| | | { |
| | | String libDir = Utils.getPath(root, Installation.LIBRARIES_PATH_RELATIVE); |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | value = Utils.getPath(libDir, |
| | | Installation.SET_JAVA_PROPERTIES_FILE_WINDOWS); |
| | |
| | | { |
| | | // This can happen when we are not launched using the command-line (for |
| | | // instance from the WebInstaller). |
| | | if (Utils.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | value = Utils.getPath(Installation.LIBRARIES_PATH_RELATIVE, |
| | | Installation.SET_JAVA_PROPERTIES_FILE_WINDOWS); |
| | |
| | | |
| | | import org.opends.server.loggers.JDKLogging; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.opends.server.util.SetupUtils; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.hasUAC; |
| | | |
| | | /** |
| | | * This class is used to start the Windows service associated with this |
| | |
| | | else |
| | | { |
| | | String[] cmd; |
| | | if (SetupUtils.hasUAC()) |
| | | if (hasUAC()) |
| | | { |
| | | cmd= new String[] { |
| | | ConfigureWindowsService.getLauncherBinaryFullPath(), |
| | |
| | | |
| | | import org.opends.server.loggers.JDKLogging; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.opends.server.util.SetupUtils; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.hasUAC; |
| | | |
| | | |
| | | /** |
| | |
| | | else |
| | | { |
| | | String[] cmd; |
| | | if (SetupUtils.hasUAC()) |
| | | if (hasUAC()) |
| | | { |
| | | cmd= new String[] { |
| | | ConfigureWindowsService.getLauncherBinaryFullPath(), |
| | |
| | | import static org.opends.quicksetup.util.Utils.getMessageFromCollection; |
| | | import static org.opends.quicksetup.util.Utils.getServerClock; |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | import org.opends.server.admin.*; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | |
| | | private String getCommandLinePath(String scriptBasicName) |
| | | { |
| | | String cmdLineName; |
| | | if (Utilities.isWindows()) |
| | | if (isWindows()) |
| | | { |
| | | cmdLineName = getBinaryDir()+scriptBasicName+".bat"; |
| | | } |
| | |
| | | |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.isUnix; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | { |
| | | // TODO: set the file's permissions. This is made easier in |
| | | // Java 1.6 but until then use the TestUtilities methods |
| | | if (UpgradeUtils.isUnix()) |
| | | if (isUnix()) |
| | | { |
| | | final FilePermission permissions = |
| | | getFileSystemPermissions(objectFile); |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SchemaConfigManager; |
| | | import org.opends.server.util.ChangeOperationType; |
| | | import org.opends.server.util.SetupUtils; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import static org.opends.messages.ConfigMessages.INFO_CONFIG_FILE_HEADER; |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns <CODE>true</CODE> if we are running under windows and |
| | | * <CODE>false</CODE> otherwise. |
| | | * |
| | | * @return <CODE>true</CODE> if we are running under windows and |
| | | * <CODE>false</CODE> otherwise. |
| | | */ |
| | | static boolean isWindows() |
| | | { |
| | | return SetupUtils.isWindows(); |
| | | } |
| | | |
| | | /** |
| | | * Returns <CODE>true</CODE> if we are running under Unix and |
| | | * <CODE>false</CODE> otherwise. |
| | | * |
| | | * @return <CODE>true</CODE> if we are running under Unix and |
| | | * <CODE>false</CODE> otherwise. |
| | | */ |
| | | static boolean isUnix() |
| | | { |
| | | return SetupUtils.isUnix(); |
| | | } |
| | | |
| | | /** |
| | | * Determines whether one file is the parent of another. |
| | | * |
| | | * @param ancestor |
| | |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import com.forgerock.opendj.util.OperatingSystem; |
| | | |
| | | /** |
| | | * This interface defines a set of methods that may be used by |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.core.DirectoryServer; |
| | | |
| | | import com.forgerock.opendj.util.OperatingSystem; |
| | | |
| | | import static org.opends.messages.UtilityMessages.*; |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2013 ForgeRock AS |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.util; |
| | | |
| | |
| | | import java.util.Random; |
| | | import java.util.Set; |
| | | |
| | | import org.opends.server.types.OperatingSystem; |
| | | import com.forgerock.opendj.util.OperatingSystem; |
| | | |
| | | /** |
| | | * This class provides a number of utility methods that may be used during the |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns {@code true} if we are running under Mac OS and |
| | | * {@code false} otherwise. |
| | | * @return {@code true} if we are running under Mac OS and |
| | | * {@code false} otherwise. |
| | | */ |
| | | public static boolean isMacOS() |
| | | { |
| | | return OperatingSystem.MACOS == getOperatingSystem(); |
| | | } |
| | | |
| | | /** |
| | | * Returns {@code true} if we are running under Unix and |
| | | * {@code false} otherwise. |
| | | * @return {@code true} if we are running under Unix and |
| | | * {@code false} otherwise. |
| | | */ |
| | | public static boolean isUnix() |
| | | { |
| | | return OperatingSystem.isUNIXBased(getOperatingSystem()); |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the underlying operating system is a Windows variant. |
| | | * |
| | | * @return {@code true} if the underlying operating system is a Windows |
| | | * variant, or {@code false} if not. |
| | | */ |
| | | public static boolean isWindows() |
| | | { |
| | | return OperatingSystem.WINDOWS == getOperatingSystem(); |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the underlying operating system is Windows Vista. |
| | | * |
| | | * @return {@code true} if the underlying operating system is Windows |
| | | * Vista, or {@code false} if not. |
| | | */ |
| | | public static boolean isVista() |
| | | { |
| | | String os = System.getProperty("os.name"); |
| | | if (os != null) |
| | | { |
| | | return isWindows() && (os.toLowerCase().indexOf("vista") != -1); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the underlying operating system is Windows 2008. |
| | | * |
| | | * @return {@code true} if the underlying operating system is Windows |
| | | * 2008, or {@code false} if not. |
| | | */ |
| | | public static boolean isWindows2008() |
| | | { |
| | | String os = System.getProperty("os.name"); |
| | | if (os != null) |
| | | { |
| | | return isWindows() && (os.toLowerCase().indexOf("server 2008") != -1); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the underlying operating system is Windows 7. |
| | | * |
| | | * @return {@code true} if the underlying operating system is Windows 7, or |
| | | * {@code false} if not. |
| | | */ |
| | | public static boolean isWindows7() |
| | | { |
| | | String os = System.getProperty("os.name"); |
| | | if (os != null) |
| | | { |
| | | return os.toLowerCase().indexOf("windows 7") != -1; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the underlying operating system has UAC (User Access |
| | | * Control). |
| | | * |
| | | * @return {@code true} if the underlying operating system has UAC (User |
| | | * Access Control), or {@code false} if not. |
| | | */ |
| | | public static boolean hasUAC() |
| | | { |
| | | return isVista() || isWindows2008() || isWindows7(); |
| | | } |
| | | |
| | | /** |
| | | * Returns a String representation of the OS we are running. |
| | | * @return a String representation of the OS we are running. |
| | | */ |
| | | public static String getOSString() |
| | | { |
| | | return getOperatingSystem().toString(); |
| | | } |
| | | |
| | | /** |
| | | * Commodity method to help identifying the OS we are running on. |
| | | * @return the OperatingSystem we are running on. |
| | | */ |
| | | public static OperatingSystem getOperatingSystem() |
| | | { |
| | | return OperatingSystem.forName(System.getProperty("os.name")); |
| | | } |
| | | |
| | | /** |
| | | * Returns {@code true} if the provided port is free and we can use it, |
| | | * {@code false} otherwise. |
| | | * @param hostname the host name we are analyzing. Use <CODE>null</CODE> |
| | |
| | | socketAddress = new InetSocketAddress(port); |
| | | } |
| | | serverSocket = new ServerSocket(); |
| | | if (!isWindows()) |
| | | if (!OperatingSystem.isWindows()) |
| | | { |
| | | serverSocket.setReuseAddress(true); |
| | | } |
| | |
| | | */ |
| | | public static boolean isPriviledgedPort(int port) |
| | | { |
| | | return (port <= 1024) && !isWindows(); |
| | | return (port <= 1024) && !OperatingSystem.isWindows(); |
| | | } |
| | | |
| | | /** |
| | |
| | | public static String getScriptPath(String script) |
| | | { |
| | | String s = script; |
| | | if (isWindows()) |
| | | if (OperatingSystem.isWindows()) |
| | | { |
| | | if (s != null) |
| | | { |
| | |
| | | import org.opends.quicksetup.util.ZipExtractor; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.types.OperatingSystem; |
| | | import com.forgerock.opendj.util.OperatingSystem; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | | public class TestUtilities { |
| | |
| | | |
| | | List<String> args = new ArrayList<String>(); |
| | | File root = getQuickSetupTestServerRootDir(); |
| | | if (OperatingSystem.isUNIXBased( |
| | | OperatingSystem.forName(System.getProperty("os.name")))) { |
| | | if (OperatingSystem.isUnixBased()) { |
| | | args.add(new File(root, "setup").getPath()); |
| | | } else { |
| | | args.add(new File(root, "setup.bat").getPath()); |
| | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | import com.forgerock.opendj.util.OperatingSystem; |
| | | |
| | | /** |
| | | * This class defines some utility functions which can be used by test cases. |
| | |
| | | } |
| | | |
| | | // Make the shell scripts in the bin directory executable, if possible. |
| | | OperatingSystem os = DirectoryServer.getOperatingSystem(); |
| | | if ((os != null) && OperatingSystem.isUNIXBased(os) && |
| | | FilePermission.canSetPermissions()) |
| | | if (OperatingSystem.isUnixBased() && FilePermission.canSetPermissions()) |
| | | { |
| | | try |
| | | { |