public Location createLocation(Location parentLocation, URL defaultLocation, boolean readonly) { BasicLocation result = new BasicLocation(null, defaultLocation, readonly, dataAreaPrefix, environmentInfo); result.setParent(parentLocation); return result; }
return new BasicLocation(property, defaultLocation, userReadOnlySetting != null || !computeReadOnly ? readOnly : !canWrite(defaultLocation), dataAreaPrefix, equinoxConfig, container, debugLocations); String trimmedLocation = location.trim(); if (trimmedLocation.equalsIgnoreCase(NONE)) return null; if (trimmedLocation.equalsIgnoreCase(NO_DEFAULT)) return new BasicLocation(property, null, readOnly, dataAreaPrefix, equinoxConfig, container, debugLocations); if (trimmedLocation.startsWith(USER_HOME)) { String base = substituteVar(location, USER_HOME, PROP_USER_HOME); BasicLocation result = null; if (url != null) { result = new BasicLocation(property, null, userReadOnlySetting != null || !computeReadOnly ? readOnly : !canWrite(url), dataAreaPrefix, equinoxConfig, container, debugLocations); result.setURL(url, false);
private boolean lock(File lock, URL locationValue) throws IOException { if (isReadOnly) throw new IOException(NLS.bind(Msg.location_folderReadOnly, lock)); if (lock == null) { if (locationValue != null && !"file".equalsIgnoreCase(locationValue.getProtocol())) //$NON-NLS-1$ throw new IOException(NLS.bind(Msg.location_notFileProtocol, locationValue)); throw new IllegalStateException(Msg.location_noLockFile); // this is really unexpected } if (isLocked()) return false; File parentFile = new File(lock.getParent()); if (!parentFile.isDirectory()) { parentFile.mkdirs(); if (!parentFile.isDirectory()) throw new IOException(NLS.bind(Msg.location_folderReadOnly, parentFile)); } setLocker(lock); if (locker == null) return true; boolean locked = false; try { locked = locker.lock(); return locked; } finally { if (!locked) locker = null; } }
/** * @deprecated */ public boolean setURL(URL value, boolean lock) throws IllegalStateException { try { return set(value, lock); } catch (IOException e) { return false; } }
private boolean isLocked(File lock) throws IOException { if (lock == null || isReadOnly) return true; if (!lock.exists()) return false; setLocker(lock); return locker.isLocked(); }
public synchronized URL getURL() { if (location == null && defaultValue != null) { if (debug.get()) { EquinoxLogServices logServices = container.getLogServices(); // Note that logServices can be null if we are very early in the startup. if (logServices != null) { logServices.log(EquinoxContainer.NAME, FrameworkLogEntry.INFO, "Called Location.getURL() when it has not been set for: \"" + property + "\"", new RuntimeException("Call stack for Location.getURL()")); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ } } setURL(defaultValue, false); } return location; }
public URL getDataArea(String filename) throws IOException { URL base = getURL(); if (base == null) throw new IOException(Msg.location_notSet); String prefix = base.toExternalForm(); if (prefix.length() > 0 && prefix.charAt(prefix.length() - 1) != '/') prefix += '/'; filename = filename.replace('\\', '/'); if (filename.length() > 0 && filename.charAt(0) == '/') filename.substring(1); return new URL(prefix + dataAreaPrefix + filename); } }
if (!lock(file, value)) return false;
public FileLockServiceImpl() { anyLocation = new BasicLocation(null, null, false, null, new ConfigValues(new HashMap<String, String>(), new HashMap<Throwable, Integer>()), new EquinoxContainer(null), new AtomicBoolean(false)); }
return new BasicLocation(property, defaultLocation, userReadOnlySetting != null || !computeReadOnly ? readOnly : !canWrite(defaultLocation), dataAreaPrefix, equinoxConfig, container, debugLocations); String trimmedLocation = location.trim(); if (trimmedLocation.equalsIgnoreCase(NONE)) return null; if (trimmedLocation.equalsIgnoreCase(NO_DEFAULT)) return new BasicLocation(property, null, readOnly, dataAreaPrefix, equinoxConfig, container, debugLocations); if (trimmedLocation.startsWith(USER_HOME)) { String base = substituteVar(location, USER_HOME, PROP_USER_HOME); BasicLocation result = null; if (url != null) { result = new BasicLocation(property, null, userReadOnlySetting != null || !computeReadOnly ? readOnly : !canWrite(url), dataAreaPrefix, equinoxConfig, container, debugLocations); result.setURL(url, false);
private boolean lock(File lock, URL locationValue) throws IOException { if (isReadOnly) throw new IOException(NLS.bind(Msg.location_folderReadOnly, lock)); if (lock == null) { if (locationValue != null && !"file".equalsIgnoreCase(locationValue.getProtocol())) //$NON-NLS-1$ throw new IOException(NLS.bind(Msg.location_notFileProtocol, locationValue)); throw new IllegalStateException(Msg.location_noLockFile); // this is really unexpected } if (isLocked()) return false; File parentFile = new File(lock.getParent()); if (!parentFile.isDirectory()) { parentFile.mkdirs(); if (!parentFile.isDirectory()) throw new IOException(NLS.bind(Msg.location_folderReadOnly, parentFile)); } setLocker(lock); if (locker == null) return true; boolean locked = false; try { locked = locker.lock(); return locked; } finally { if (!locked) locker = null; } }
/** * @deprecated */ public boolean setURL(URL value, boolean lock) throws IllegalStateException { try { return set(value, lock); } catch (IOException e) { return false; } }
private boolean isLocked(File lock) throws IOException { if (lock == null || isReadOnly) return true; if (!lock.exists()) return false; setLocker(lock); return locker.isLocked(); }
public synchronized URL getURL() { if (location == null && defaultValue != null) { if (debug.get()) { EquinoxLogServices logServices = container.getLogServices(); // Note that logServices can be null if we are very early in the startup. if (logServices != null) { logServices.log(EquinoxContainer.NAME, FrameworkLogEntry.INFO, "Called Location.getURL() when it has not been set for: \"" + property + "\"", new RuntimeException("Call stack for Location.getURL()")); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ } } setURL(defaultValue, false); } return location; }
public URL getDataArea(String filename) throws IOException { URL base = getURL(); if (base == null) throw new IOException(Msg.location_notSet); String prefix = base.toExternalForm(); if (prefix.length() > 0 && prefix.charAt(prefix.length() - 1) != '/') prefix += '/'; filename = filename.replace('\\', '/'); if (filename.length() > 0 && filename.charAt(0) == '/') filename = filename.substring(1); String spec = prefix + dataAreaPrefix + filename; boolean trailingSlash = spec.length() > 0 && spec.charAt(spec.length() - 1) == '/'; return LocationHelper.buildURL(spec, trailingSlash); } }
if (!lock(file, value)) return false;
public Location createLocation(Location parentLocation, URL defaultLocation, boolean readonly) { BasicLocation result = new BasicLocation(null, defaultLocation, readonly, dataAreaPrefix, configValues, container, debug); result.setParent(parentLocation); return result; }
return new BasicLocation(property, defaultLocation, userReadOnlySetting != null || !computeReadOnly ? readOnly : !canWrite(defaultLocation), dataAreaPrefix, equinoxConfig, container, debugLocations); String trimmedLocation = location.trim(); if (trimmedLocation.equalsIgnoreCase(NONE)) return null; if (trimmedLocation.equalsIgnoreCase(NO_DEFAULT)) return new BasicLocation(property, null, readOnly, dataAreaPrefix, equinoxConfig, container, debugLocations); if (trimmedLocation.startsWith(USER_HOME)) { String base = substituteVar(location, USER_HOME, PROP_USER_HOME); BasicLocation result = null; if (url != null) { result = new BasicLocation(property, null, userReadOnlySetting != null || !computeReadOnly ? readOnly : !canWrite(url), dataAreaPrefix, equinoxConfig, container, debugLocations); result.setURL(url, false);