/** * @see org.opencms.main.I_CmsShellCommands#shellExit() */ public void shellExit() { System.out.println(); System.out.println(getMessages().key(Messages.GUI_SHELL_GOODBYE_0)); }
/** * Provides help information for the CmsShell.<p> */ public void help() { System.out.println(); System.out.println(getMessages().key(Messages.GUI_SHELL_HELP1_0)); System.out.println(getMessages().key(Messages.GUI_SHELL_HELP2_0)); System.out.println(getMessages().key(Messages.GUI_SHELL_HELP3_0)); System.out.println(getMessages().key(Messages.GUI_SHELL_HELP4_0)); System.out.println(); }
/** * Returns the Locales available on the system ready to use on Method * {@link #setLocale(String)} from the <code>{@link CmsShell}</code>. <p> * * Note that the full name containing language, country and optional variant seperated * by underscores is returned always but the latter two parts may be left out. <p> */ public void getLocales() { System.out.println(getMessages().key(Messages.GUI_SHELL_LOCALES_AVAILABLE_0)); Locale[] locales = Locale.getAvailableLocales(); for (int i = locales.length - 1; i >= 0; i--) { System.out.println(" \"" + locales[i].toString() + "\""); } }
/** * Turns the echo status for the shell on or off.<p> * * @param echo if "on", echo is turned on, otherwise echo is turned off */ public void echo(String echo) { if (echo == null) { return; } boolean b = "on".equalsIgnoreCase(echo.trim()); m_shell.setEcho(b); if (b) { System.out.println(getMessages().key(Messages.GUI_SHELL_ECHO_ON_0)); } else { System.out.println(getMessages().key(Messages.GUI_SHELL_ECHO_OFF_0)); } }
/** * Displays a list of all currently installed modules.<p> * * @throws Exception if something goes wrong */ public void listModules() throws Exception { Set modules = OpenCms.getModuleManager().getModuleNames(); System.out.println("\n" + getMessages().key(Messages.GUI_SHELL_LIST_MODULES_1, new Integer(modules.size()))); Iterator i = modules.iterator(); while (i.hasNext()) { String moduleName = (String)i.next(); System.out.println(moduleName); } System.out.println(); }
/** * Returns the Locales available on the system ready to use on Method * {@link #setLocale(String)} from the <code>{@link CmsShell}</code>. <p> * * Note that the full name containing language, country and optional variant seperated * by underscores is returned always but the latter two parts may be left out. <p> */ public void getLocales() { m_shell.getOut().println(getMessages().key(Messages.GUI_SHELL_LOCALES_AVAILABLE_0)); Locale[] locales = Locale.getAvailableLocales(); for (int i = locales.length - 1; i >= 0; i--) { m_shell.getOut().println(" \"" + locales[i].toString() + "\""); } }
/** * Provides help information for the CmsShell.<p> */ public void help() { m_shell.getOut().println(); m_shell.getOut().println(getMessages().key(Messages.GUI_SHELL_HELP1_0)); m_shell.getOut().println(getMessages().key(Messages.GUI_SHELL_HELP2_0)); m_shell.getOut().println(getMessages().key(Messages.GUI_SHELL_HELP3_0)); m_shell.getOut().println(getMessages().key(Messages.GUI_SHELL_HELP4_0)); m_shell.getOut().println(); }
/** * Returns the version information for this OpenCms instance.<p> */ public void version() { System.out.println(); System.out.println(getMessages().key(Messages.GUI_SHELL_VERSION_1, OpenCms.getSystemInfo().getVersionNumber())); }
/** * @see org.opencms.main.I_CmsShellCommands#shellExit() */ public void shellExit() { m_shell.getOut().println(); m_shell.getOut().println(getMessages().key(Messages.GUI_SHELL_GOODBYE_0)); }
/** * Turns the echo status for the shell on or off.<p> * * @param echo if "on", echo is turned on, otherwise echo is turned off */ public void echo(String echo) { if (echo == null) { return; } boolean b = "on".equalsIgnoreCase(echo.trim()); m_shell.setEcho(b); if (b) { m_shell.getOut().println(getMessages().key(Messages.GUI_SHELL_ECHO_ON_0)); } else { m_shell.getOut().println(getMessages().key(Messages.GUI_SHELL_ECHO_OFF_0)); } }
/** * Displays a list of all currently installed modules.<p> * * @throws Exception if something goes wrong */ public void listModules() throws Exception { Set<String> modules = OpenCms.getModuleManager().getModuleNames(); m_shell.getOut().println( "\n" + getMessages().key(Messages.GUI_SHELL_LIST_MODULES_1, new Integer(modules.size()))); Iterator<String> i = modules.iterator(); while (i.hasNext()) { String moduleName = i.next(); m_shell.getOut().println(moduleName); } m_shell.getOut().println(); }
/** * @see org.opencms.main.I_CmsShellCommands#shellStart() */ public void shellStart() { System.out.println(); System.out.println(getMessages().key(Messages.GUI_SHELL_WELCOME_0)); System.out.println(); // print the version information version(); // print the copyright message copyright(); // print the help information help(); }
/** * Displays a list of all resources in the current folder.<p> * * @throws Exception if something goes wrong * @see CmsObject#getResourcesInFolder(String, CmsResourceFilter) */ public void ls() throws Exception { String folder = CmsResource.getFolderPath(m_cms.getRequestContext().getUri()); List resources = m_cms.getResourcesInFolder(folder, CmsResourceFilter.IGNORE_EXPIRATION); System.out.println("\n" + getMessages().key(Messages.GUI_SHELL_LS_2, folder, new Integer(resources.size()))); Iterator i = resources.iterator(); while (i.hasNext()) { CmsResource r = (CmsResource)i.next(); System.out.println(m_cms.getSitePath(r)); } System.out.println(); }
/** * Returns the version information for this OpenCms instance.<p> */ public void version() { m_shell.getOut().println(); m_shell.getOut().println( getMessages().key(Messages.GUI_SHELL_VERSION_1, OpenCms.getSystemInfo().getVersionNumber())); }
/** * Creates a new user.<p> * * @param name the name for the new user * @param password the password for the new user * @param description the description for the new user * * @throws Exception if something goes wrong * @see CmsObject#createUser(String, String, String, java.util.Map) * @return the created user */ public CmsUser createUser(String name, String password, String description) throws Exception { if (existsUser(name)) { m_shell.getOut().println(getMessages().key(Messages.GUI_SHELL_USER_ALREADY_EXISTS_1, name)); return null; } return m_cms.createUser(name, password, description, new Hashtable<String, Object>()); }
/** * Displays a list of all resources in the current folder.<p> * * @throws Exception if something goes wrong * @see CmsObject#getResourcesInFolder(String, CmsResourceFilter) */ public void ls() throws Exception { String folder = CmsResource.getFolderPath(m_cms.getRequestContext().getUri()); List<CmsResource> resources = m_cms.getResourcesInFolder(folder, CmsResourceFilter.IGNORE_EXPIRATION); m_shell.getOut().println( "\n" + getMessages().key(Messages.GUI_SHELL_LS_2, folder, new Integer(resources.size()))); Iterator<CmsResource> i = resources.iterator(); while (i.hasNext()) { CmsResource r = i.next(); m_shell.getOut().println(m_cms.getSitePath(r)); } m_shell.getOut().println(); }
/** * Creates a new folder in the given target folder.<p> * * @param targetFolder the target folder * @param folderName the new folder to create in the target folder * @return the created folder * @throws Exception if somthing goes wrong */ public CmsResource createFolder(String targetFolder, String folderName) throws Exception { if (m_cms.existsResource(targetFolder + folderName)) { m_shell.getOut().println( getMessages().key(Messages.GUI_SHELL_FOLDER_ALREADY_EXISTS_1, targetFolder + folderName)); return null; } return m_cms.createResource(targetFolder + folderName, CmsResourceTypeFolder.getStaticTypeId()); }
/** * @see org.opencms.main.I_CmsShellCommands#shellStart() */ public void shellStart() { m_shell.getOut().println(); m_shell.getOut().println(getMessages().key(Messages.GUI_SHELL_WELCOME_0)); m_shell.getOut().println(); // print the version information version(); // print the copyright message copyright(); if (m_shell.isInteractive()) { // print the help information for interactive terminals help(); } }
/** * Log a user in to the the CmsSell.<p> * * @param username the name of the user to log in * @param password the password of the user */ public void login(String username, String password) { username = OpenCms.getImportExportManager().translateUser(username); try { m_cms.loginUser(username, password); // reset the settings, this will switch the startup site root etc. m_shell.initSettings(); System.out.println(getMessages().key(Messages.GUI_SHELL_LOGIN_1, whoami().getName())); // output the login message if required CmsLoginMessage message = OpenCms.getLoginManager().getLoginMessage(); if ((message != null) && (message.isActive())) { System.out.println(message.getMessage()); } } catch (Exception exc) { System.out.println(getMessages().key(Messages.GUI_SHELL_LOGIN_FAILED_0)); } }
/** * Changes the current folder (i.e. the URI in the VFS).<p> * * @param target the new URI * @throws Exception if something goes wrong * @see org.opencms.file.CmsRequestContext#setUri(String) */ public void cd(String target) throws Exception { String folder = CmsResource.getFolderPath(m_cms.getRequestContext().getUri()); if (!target.endsWith("/")) { target += "/"; } String resolvedTarget = CmsLinkManager.getAbsoluteUri(target, folder); CmsResource res = m_cms.readResource(resolvedTarget); if (!res.isFolder()) { throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_NOT_A_FOLDER_1, resolvedTarget)); } m_cms.getRequestContext().setUri(resolvedTarget); System.out.println('\n' + getMessages().key(Messages.GUI_SHELL_CURRENT_FOLDER_1, new Object[] {resolvedTarget})); System.out.println(); }