Package org.osgi.service.prefs

Examples of org.osgi.service.prefs.BackingStoreException


        /*
         * @see org.osgi.service.prefs.Preferences#sync()
         */
        public void sync() throws BackingStoreException {
            // sync all children
            BackingStoreException exception = null;
            String[] names = childrenNames();
            for (int i = 0; i < names.length; i++) {
                try {
                    node(names[i]).sync();
                } catch (BackingStoreException e) {
View Full Code Here


      input = new BufferedInputStream(file.getContents(true));
      result.load(input);
    } catch (CoreException e) {
      String message = NLS.bind(Messages.preferences_loadException, file.getFullPath());
      log(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, IStatus.ERROR, message, e));
      throw new BackingStoreException(message);
    } catch (IOException e) {
      String message = NLS.bind(Messages.preferences_loadException, file.getFullPath());
      log(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, IStatus.ERROR, message, e));
      throw new BackingStoreException(message);
    } finally {
      FileUtil.safeClose(input);
    }
    return result;
  }
View Full Code Here

      input = new BufferedInputStream(localFile.getContents(true));
      fromDisk.load(input);
    } catch (CoreException e) {
      String message = NLS.bind(Messages.preferences_loadException, localFile.getFullPath());
      log(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, IStatus.ERROR, message, e));
      throw new BackingStoreException(message);
    } catch (IOException e) {
      String message = NLS.bind(Messages.preferences_loadException, localFile.getFullPath());
      log(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, IStatus.ERROR, message, e));
      throw new BackingStoreException(message);
    } finally {
      FileUtil.safeClose(input);
    }
    convertFromProperties(this, fromDisk, true);
  }
View Full Code Here

        };
        ISchedulingRule rule = factory.deleteRule(fileInWorkspace);
        try {
          ResourcesPlugin.getWorkspace().run(operation, rule, IResource.NONE, null);
        } catch (OperationCanceledException e) {
          throw new BackingStoreException(Messages.preferences_operationCanceled);
        }
        return;
      }
      table.put(VERSION_KEY, VERSION_VALUE);
      ByteArrayOutputStream output = new ByteArrayOutputStream();
      try {
        table.store(output, null);
      } catch (IOException e) {
        String message = NLS.bind(Messages.preferences_saveProblems, absolutePath());
        log(new Status(IStatus.ERROR, Platform.PI_RUNTIME, IStatus.ERROR, message, e));
        throw new BackingStoreException(message);
      } finally {
        try {
          output.close();
        } catch (IOException e) {
          // ignore
        }
      }
      final InputStream input = new BufferedInputStream(new ByteArrayInputStream(output.toByteArray()));
      IWorkspaceRunnable operation = new IWorkspaceRunnable() {
        public void run(IProgressMonitor monitor) throws CoreException {
          if (fileInWorkspace.exists()) {
            if (Policy.DEBUG_PREFERENCES)
              Policy.debug("Setting preference file contents for: " + fileInWorkspace.getFullPath()); //$NON-NLS-1$
            if (fileInWorkspace.isReadOnly()) {
              IStatus status = fileInWorkspace.getWorkspace().validateEdit(new IFile[] {fileInWorkspace}, IWorkspace.VALIDATE_PROMPT);
              if (!status.isOK())
                throw new CoreException(status);
            }
            // set the contents
            fileInWorkspace.setContents(input, IResource.KEEP_HISTORY, null);
          } else {
            // create the file
            IFolder folder = (IFolder) fileInWorkspace.getParent();
            if (!folder.exists()) {
              if (Policy.DEBUG_PREFERENCES)
                Policy.debug("Creating parent preference directory: " + folder.getFullPath()); //$NON-NLS-1$
              folder.create(IResource.NONE, true, null);
            }
            if (Policy.DEBUG_PREFERENCES)
              Policy.debug("Creating preference file: " + fileInWorkspace.getLocation()); //$NON-NLS-1$
            fileInWorkspace.create(input, IResource.NONE, null);
          }
        }
      };
      //don't bother with scheduling rules if we are already inside an operation
      try {
        if (((Workspace) workspace).getWorkManager().isLockAlreadyAcquired()) {
          operation.run(null);
        } else {
          // we might: create the .settings folder, create the file, or modify the file.
          ISchedulingRule rule = MultiRule.combine(factory.createRule(fileInWorkspace.getParent()), factory.modifyRule(fileInWorkspace));
          workspace.run(operation, rule, IResource.NONE, null);
        }
      } catch (OperationCanceledException e) {
        throw new BackingStoreException(Messages.preferences_operationCanceled);
      }
    } catch (CoreException e) {
      String message = NLS.bind(Messages.preferences_saveProblems, fileInWorkspace.getFullPath());
      log(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, IStatus.ERROR, message, e));
      throw new BackingStoreException(message);
    }
  }
View Full Code Here

TOP

Related Classes of org.osgi.service.prefs.BackingStoreException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.