/** * * Creates the proper file name for the given resource instance and then * delegates creation of the file's contents to the abstract method of * the same name. * * @param epr * @param resource * * @see #getNextFileNumber(String) * @see #createResourceFile(EndpointReference, Resource, File) * */ protected void createResourceFile(EndpointReference epr, Resource resource) throws SoapFault { String contextPath = resource.getContextPath(); int nextNumber = getNextFileNumber(contextPath); String nextFileName = getNextFileName(nextNumber); File resourceTypeDir = getResourceTypeDirectory(contextPath); File resourceFile = new File(resourceTypeDir, nextFileName); createResourceFile(epr, resource, resourceFile); Map fileNumbersByEPR = (Map)getFileNumberTables().get(contextPath); fileNumbersByEPR.put(epr, new Integer(nextNumber)); }
/** * * @param fileNumber * * @return A string of the following format: {file-prefix}{file-number}.xml * */ protected String getNextFileName(int fileNumber) { return getFilePrefix() + fileNumber + ".xml"; }
public String getInitializationParameter(String name) { return (String)getInitializationParameters().get(name); }
throws SoapFault ResourceManager manager = getResourceManager(); Iterator i = manager.getResourceContextPaths().iterator(); continue; getFileNumberTables().put(contextPath, new HashMap()); File resourceTypeDir = getResourceTypeDirectory(contextPath); reloadResources(contextPath, resourceTypeDir);
throws SoapFault String contextPath = getContextPath(epr); Map fileNumbersByEPR = (Map)getFileNumberTables().get(contextPath); Integer fileNumber = (Integer)fileNumbersByEPR.get(epr); FileNumberFilter filter = new FileNumberFilter(fileNumber); File resourceTypeDir = getResourceTypeDirectory(contextPath); File[] results = resourceTypeDir.listFiles(filter);
Resource resource = reloadResource(contextPath, root); Integer fileNumber = getFileNumber(fileName); Map fileNumbersByEPR = (Map)getFileNumberTables().get(contextPath); fileNumbersByEPR.put(resource.getEndpointReference(), fileNumber);
/** * * @return The File directory that was specified as the persistence location * in muse.xml. The directory may not exist, so use File.exists() * and/or File.mkdirs() to prevent I/O errors. * */ protected File getPersistenceDirectory() { String path = getPersistenceLocation(); if (path == null) throw new RuntimeException(_MESSAGES.get("NoPersistenceLocation")); File workingDir = getResourceManager().getEnvironment().getRealDirectory(); return new File(workingDir, path); }
/** * * @param contextPath * * @return Returns a directory for a given resource type, under the * specified persistence location. The name of the directory * is the context path provided. If the directory does not * exist, this method will create it before returning the * File object. * * @see #getPersistenceDirectory() * @see File#mkdirs() * */ protected File getResourceTypeDirectory(String contextPath) { File dir = new File(getPersistenceDirectory(), contextPath); if (!dir.exists()) dir.mkdirs(); return dir; }
/** * * @return The next number that is available for creation of unique file * names; this number is determined by taking the largest number * currently used and incrementing it by one. The method does not * attempt to reuse numbers in 'gaps' caused by deletions (that is, * if numbers 1, 2, 5, and 6 are used, the method returns 7, not 3). * */ protected int getNextFileNumber(String contextPath) { Map fileNumbersByEPR = (Map)getFileNumberTables().get(contextPath); if (fileNumbersByEPR.isEmpty()) return 1; // // create a binary tree of numbers, pick the last one (= largest) // TreeSet sortedNumbers = new TreeSet(fileNumbersByEPR.values()); Integer largest = (Integer)sortedNumbers.last(); return largest.intValue() + 1; }
public boolean accept(File file) { if (file == null || file.getName() == null) return false; return file.getName().startsWith(getFilePrefix()); } }