List of usage examples for org.apache.commons.lang SystemUtils FILE_SEPARATOR
String FILE_SEPARATOR
To view the source code for org.apache.commons.lang SystemUtils FILE_SEPARATOR.
Click Source Link
The file.separator
System Property.
From source file:SystemUtilsTrial.java
public static void main(String[] args) { System.out.println("1) FILE_SEPARATOR =" + SystemUtils.FILE_SEPARATOR); System.out.println("2) JAVA_EXT_DIRS =" + SystemUtils.JAVA_EXT_DIRS); System.out.println("3) JAVA_HOME =" + SystemUtils.JAVA_HOME); System.out.println("4) Is 1.3 + =" + SystemUtils.isJavaVersionAtLeast(1.3f)); System.out.println("5) JAVA_EXT_DIRS =" + SystemUtils.JAVA_EXT_DIRS); System.out.println("6) JAVA_VENDOR =" + SystemUtils.JAVA_VENDOR); System.out.println("7) OS_NAME =" + SystemUtils.OS_NAME); }
From source file:com.vmware.identity.interop.FileSystemPathLocator.java
public static String getCacheFolderPath() { String cacheDirPath = null;//from w w w. j a v a 2s .c om if (SystemUtils.IS_OS_WINDOWS) { cacheDirPath = Shell32Util.getFolderPath(ShlObj.CSIDL_LOCAL_APPDATA); } else { cacheDirPath = LINUX_CACHE_FOLDER_ROOT; } if (cacheDirPath == null || cacheDirPath.isEmpty()) { throw new IllegalStateException("Found empty cache dir path"); } return String.format("%s%s%s%s%s", cacheDirPath, SystemUtils.FILE_SEPARATOR, VMWARE_FOLDER_NAME, SystemUtils.FILE_SEPARATOR, VMWARE_IDENTITY_FOLDER_NAME); }
From source file:com.vmware.identity.interop.FileSystemPathLocator.java
public static String getKrb5ConfFilePath() { return String.format("%s%skrb5.conf", getCacheFolderPath(), SystemUtils.FILE_SEPARATOR); }
From source file:io.uengine.util.FileUtils.java
/** * Fully Qualified Path? Path Separator . * * @param fullyQualifiedPath Fully Qualified Path * @return Path Separator //from ww w . ja va2 s .c o m */ public static String getPath(String fullyQualifiedPath) { int sep = fullyQualifiedPath.lastIndexOf(SystemUtils.FILE_SEPARATOR); if (sep != 0) { return fullyQualifiedPath.substring(0, sep); } return SystemUtils.FILE_SEPARATOR; }
From source file:io.uengine.util.FileUtils.java
/** * Fully Qualified Path? Path Separator . * * @param fullyQualifiedPath Fully Qualified Path * @return Path Separator /* w w w. ja va2 s . c om*/ */ public static String getDirectoryName(String fullyQualifiedPath) { int sep = fullyQualifiedPath.lastIndexOf(SystemUtils.FILE_SEPARATOR); int length = fullyQualifiedPath.getBytes().length; return fullyQualifiedPath.substring(sep + 1, length); }
From source file:io.uengine.util.FileUtils.java
/** * Fully Qualified Path? Path Separator ? ? ? ?? ?. * * @param fullyQualifiedPath Fully Qualified Path * @param replacement ? ? ? //from w ww . j av a2 s. c om * @return ? ? ? ?? fully qualified path */ public static String replaceLast(String fullyQualifiedPath, String replacement) { String path = getPath(fullyQualifiedPath); if (path.endsWith(SystemUtils.FILE_SEPARATOR)) { return path + replacement; } return path + SystemUtils.FILE_SEPARATOR + replacement; }
From source file:de.innovationgate.utils.WGUtils.java
/** * Calculates a relative file path, relative to the given parent path. * Example:// w ww . j av a 2 s . co m * <code> * relativeFilePath("D:\Daten\WGAConfig\WGA32Test\designsync\mysql", "D:\Daten\WGAConfig\WGA32Test") * </code> * returns "designsync\mysql" * <p> * This works only when * <ul> * <li> path itself starts with parentPath * <li>parentPath is a syntacticly valid directory path (which does not mean that the directory must exist) * </ul> * <p> * If these conditions are not met, the method either throws an IllegalArgumentException (if param failIfNoParent==true) * or just returns the path again completely (if param failIfNoParent==false) * </p> * @param path The path from which a relative path should be extracted * @param parentPath A parent path of path, to which the calculated relative path should be relative to * @param failIfNoParent Controls the failure behaviour. See method description. * @return The relative path */ public static String relativeFilePath(String path, String parentPath, boolean failIfNoParent) { // Test if parent path is the beginning of path if (!path.startsWith(parentPath)) { if (failIfNoParent) { throw new IllegalArgumentException( "Path '" + parentPath + "' is no parent path of path '" + path + "'"); } else { return path; } } // Test if parent path does not end inside a filename if (!parentPath.endsWith(SystemUtils.FILE_SEPARATOR)) { if (path.length() > parentPath.length() && !path.substring(parentPath.length(), parentPath.length() + 1) .equals(SystemUtils.FILE_SEPARATOR)) { throw new IllegalArgumentException( "Path '" + parentPath + "' is no parent directory of path '" + path + "'"); } } int cutoffLength = (parentPath.endsWith(SystemUtils.FILE_SEPARATOR) ? parentPath.length() : parentPath.length() + 1); return path.substring(cutoffLength); }
From source file:org.apache.cocoon.portal.pluto.Deploy.java
/** * Prepare the web archive of the portlet web app *///from w ww .j ava 2 s . c o m public static void prepareWebArchive(String webAppsDir, String webModule) throws Exception { System.out.println("Preparing web archive '" + webModule + "' ..."); // get portlet xml mapping file Mapping mappingPortletXml = getMapping(PortletDefinitionRegistryImpl.PORTLET_MAPPING); // get web xml mapping file Mapping mappingWebXml = getMapping(PortletDefinitionRegistryImpl.WEBXML_MAPPING); File portletXml = new File(webAppsDir + webModule + webInfDir + "portlet.xml"); File webXml = new File(webAppsDir + webModule + webInfDir + "web.xml"); Unmarshaller unmarshaller = new Unmarshaller(mappingPortletXml); PortletApplicationDefinitionImpl portletApp = (PortletApplicationDefinitionImpl) unmarshaller .unmarshal(new FileReader(portletXml)); // refill structure with necessary information Vector structure = new Vector(); structure.add(webModule); structure.add(null); structure.add(null); portletApp.preBuild(structure); if (debug) { System.out.println(portletApp); } // now generate web part WebApplicationDefinitionImpl webApp = null; if (webXml.exists()) { Unmarshaller unmarshallerWeb = new Unmarshaller(mappingWebXml); unmarshallerWeb.setIgnoreExtraElements(true); webApp = (WebApplicationDefinitionImpl) unmarshallerWeb.unmarshal(new FileReader(webXml)); } else { webApp = new WebApplicationDefinitionImpl(); DisplayNameImpl dispName = new DisplayNameImpl(); dispName.setDisplayName(webModule); dispName.setLocale(Locale.ENGLISH); DisplayNameSetImpl dispSet = new DisplayNameSetImpl(); dispSet.add(dispName); webApp.setDisplayNames(dispSet); DescriptionImpl desc = new DescriptionImpl(); desc.setDescription("Automated generated Application Wrapper"); desc.setLocale(Locale.ENGLISH); DescriptionSetImpl descSet = new DescriptionSetImpl(); descSet.add(desc); webApp.setDescriptions(descSet); } ControllerFactory controllerFactory = new ControllerFactoryImpl(); ServletDefinitionListCtrl servletDefinitionSetCtrl = (ServletDefinitionListCtrl) controllerFactory .get(webApp.getServletDefinitionList()); Collection servletMappings = webApp.getServletMappings(); Iterator portlets = portletApp.getPortletDefinitionList().iterator(); while (portlets.hasNext()) { PortletDefinition portlet = (PortletDefinition) portlets.next(); if (debug) { System.out.println(" Portlet: " + portlet.getId()); } // check if already exists ServletDefinition servlet = webApp.getServletDefinitionList().get(portlet.getName()); if (servlet != null) { if (!servlet.getServletClass().equals("org.apache.pluto.core.PortletServlet")) { System.out.println("Note: Replaced already existing the servlet with the name '" + portlet.getName() + "' with the wrapper servlet."); } ServletDefinitionCtrl _servletCtrl = (ServletDefinitionCtrl) controllerFactory.get(servlet); _servletCtrl.setServletClass("org.apache.pluto.core.PortletServlet"); } else { servlet = servletDefinitionSetCtrl.add(portlet.getName(), "org.apache.pluto.core.PortletServlet"); } ServletDefinitionCtrl servletCtrl = (ServletDefinitionCtrl) controllerFactory.get(servlet); DisplayNameImpl dispName = new DisplayNameImpl(); dispName.setDisplayName(portlet.getName() + " Wrapper"); dispName.setLocale(Locale.ENGLISH); DisplayNameSetImpl dispSet = new DisplayNameSetImpl(); dispSet.add(dispName); servletCtrl.setDisplayNames(dispSet); DescriptionImpl desc = new DescriptionImpl(); desc.setDescription("Automated generated Portlet Wrapper"); desc.setLocale(Locale.ENGLISH); DescriptionSetImpl descSet = new DescriptionSetImpl(); descSet.add(desc); servletCtrl.setDescriptions(descSet); ParameterSet parameters = servlet.getInitParameterSet(); ParameterSetCtrl parameterSetCtrl = (ParameterSetCtrl) controllerFactory.get(parameters); Parameter parameter1 = parameters.get("portlet-class"); if (parameter1 == null) { parameterSetCtrl.add("portlet-class", portlet.getClassName()); } else { ParameterCtrl parameterCtrl = (ParameterCtrl) controllerFactory.get(parameter1); parameterCtrl.setValue(portlet.getClassName()); } Parameter parameter2 = parameters.get("portlet-guid"); if (parameter2 == null) { parameterSetCtrl.add("portlet-guid", portlet.getId().toString()); } else { ParameterCtrl parameterCtrl = (ParameterCtrl) controllerFactory.get(parameter2); parameterCtrl.setValue(portlet.getId().toString()); } boolean found = false; Iterator mappings = servletMappings.iterator(); while (mappings.hasNext()) { ServletMapping servletMapping = (ServletMapping) mappings.next(); if (servletMapping.getServletName().equals(portlet.getName())) { found = true; servletMapping.setUrlPattern("/" + portlet.getName().replace(' ', '_') + "/*"); } } if (!found) { ServletMapping servletMapping = new ServletMapping(); servletMapping.setServletName(portlet.getName()); servletMapping.setUrlPattern("/" + portlet.getName().replace(' ', '_') + "/*"); servletMappings.add(servletMapping); } SecurityRoleRefSet servletSecurityRoleRefs = ((ServletDefinitionImpl) servlet) .getInitSecurityRoleRefSet(); SecurityRoleRefSetCtrl servletSecurityRoleRefSetCtrl = (SecurityRoleRefSetCtrl) controllerFactory .get(servletSecurityRoleRefs); SecurityRoleSet webAppSecurityRoles = webApp.getSecurityRoles(); SecurityRoleRefSet portletSecurityRoleRefs = portlet.getInitSecurityRoleRefSet(); Iterator p = portletSecurityRoleRefs.iterator(); while (p.hasNext()) { SecurityRoleRef portletSecurityRoleRef = (SecurityRoleRef) p.next(); if (portletSecurityRoleRef.getRoleLink() == null && webAppSecurityRoles.get(portletSecurityRoleRef.getRoleName()) == null) { System.out.println( "Note: The web application has no security role defined which matches the role name \"" + portletSecurityRoleRef.getRoleName() + "\" of the security-role-ref element defined for the wrapper-servlet with the name '" + portlet.getName() + "'."); break; } SecurityRoleRef servletSecurityRoleRef = servletSecurityRoleRefs .get(portletSecurityRoleRef.getRoleName()); if (null != servletSecurityRoleRef) { System.out.println( "Note: Replaced already existing element of type <security-role-ref> with value \"" + portletSecurityRoleRef.getRoleName() + "\" for subelement of type <role-name> for the wrapper-servlet with the name '" + portlet.getName() + "'."); servletSecurityRoleRefSetCtrl.remove(servletSecurityRoleRef); } servletSecurityRoleRefSetCtrl.add(portletSecurityRoleRef); } } TagDefinition portletTagLib = new TagDefinition(); Collection taglibs = webApp.getCastorTagDefinitions(); taglibs.add(portletTagLib); if (debug) { System.out.println(webApp); } OutputFormat of = new OutputFormat(); of.setIndenting(true); of.setIndent(4); // 2-space indention of.setLineWidth(16384); // As large as needed to prevent linebreaks in text nodes of.setDoctype(WEB_PORTLET_PUBLIC_ID, WEB_PORTLET_DTD); FileWriter writer = new FileWriter(webAppsDir + webModule + SystemUtils.FILE_SEPARATOR + "WEB-INF" + SystemUtils.FILE_SEPARATOR + "web.xml"); XMLSerializer serializer = new XMLSerializer(writer, of); try { Marshaller marshaller = new Marshaller(serializer.asDocumentHandler()); marshaller.setMapping(mappingWebXml); marshaller.marshal(webApp); } finally { writer.close(); } if (debug) { System.out.println("Finished!"); } }
From source file:org.apache.ctakes.jdl.common.FileUtil.java
/** * @param fileName/* ww w. j a v a 2s .co m*/ * the name of the file * @return the file if exist in one of all the javaClassPaths otherwise null */ public static File getFile(final String fileName) { File file = new File(fileName); if (file.exists()) { return file; } for (String token : getJavaClassPaths()) { file = new File(token + SystemUtils.FILE_SEPARATOR + fileName); if (file.exists()) { return file; } } return null; }
From source file:org.apache.ctakes.jdl.common.FileUtil.java
/** * @param filePath/* w w w . j a va2 s. com*/ * the filePath of the file * @param fileName * the fileName of the file * @return the canonical pathname string */ public static String fullPath(File filePath, String fileName) { return getCanonical(filePath) + SystemUtils.FILE_SEPARATOR + fileName; }