Package org.eclipse.core.runtime

Examples of org.eclipse.core.runtime.CoreException


  }
 
  private void throwCoreException(String message, Exception e) throws CoreException {
    IStatus status =
      new Status(IStatus.ERROR, WGADesignerPlugin.PLUGIN_ID, IStatus.OK, message, e);
    throw new CoreException(status);   
  }
View Full Code Here


                                    DataSource content = new FileDataSource(((IFile) resource).getLocation().toFile());
                                    try {
                                        _remoteServer.getServices().updateFSDesignResource(_remoteServer.getSession(), remotePath, content, resource.getLocalTimeStamp());
                                    }
                                    catch (WGAServiceException e) {
                                        throw new CoreException(new Status(IStatus.ERROR, WGADesignerPlugin.PLUGIN_ID, "Creating design file failed.", e));
                                    }
                                }
                                else if (resource.getType() == IResource.FOLDER) {
                                    try {
                                        _remoteServer.getServices().mkFSDesignDir(_remoteServer.getSession(), remotePath);
                                    }
                                    catch (WGAServiceException e) {
                                        throw new CoreException(new Status(IStatus.ERROR, WGADesignerPlugin.PLUGIN_ID, "Creating design folder failed.", e));
                                    }
                                }
                                return true;
                            }
                        });
View Full Code Here

    try {
      writer = new XMLWriter(OutputFormat.createPrettyPrint());
      writer.setOutputStream(new FileOutputStream(new File(getWGABase().getLocation().toFile(), "auth.xml")));
      writer.write(auth);
    } catch (Exception e) {
      throw new CoreException(new Status(Status.ERROR, WGADesignerPlugin.PLUGIN_ID, "Unable to generate default auth configuration.", e));
    } finally {
      try {
        if (writer != null) {
          writer.close();
        }
      } catch (IOException e) {
      }
    }
    FileOutputStream configFileStream = null;
    try {
      _config = WGARuntimeConfiguration.createDefaultConfig();
      synchronized (_wgaConfigLock) {
        configFileStream = new FileOutputStream(getConfigFile().getLocation().toFile());
        WGARuntimeConfiguration.write(_config, configFileStream);
      }
    } catch (Exception e) {
      throw new CoreException(new Status(Status.ERROR, WGADesignerPlugin.PLUGIN_ID, "Unable to generate default runtime configuration.", e));
    } finally {
      if (configFileStream != null) {
        try {
          configFileStream.close();
        } catch (IOException e) {
        }
      }

    }

    // create wga.xml defaults
    try {
      retrieveWGAConfig(true);
    } catch (IncompatibleWGAConfigVersion e) {
      // should not happen bc. config file does not exist yet - but for
      // sure we generate a notice
      throw new CoreException(new Status(Status.ERROR, WGADesignerPlugin.PLUGIN_ID, "Unable to generate default wga configuration.", e));
    } catch (IOException e) {
      throw new CoreException(new Status(Status.ERROR, WGADesignerPlugin.PLUGIN_ID, "Unable to generate default wga configuration.", e));
    }

    _project.refreshLocal(IResource.DEPTH_INFINITE, null);
  }
View Full Code Here

      WGADesign wgaDesign = (WGADesign) design;
      // create new folder and dirlink in design-root
      try {
        registerExternalDesign(wgaDesign);
      } catch (IOException e) {
        throw new CoreException(new Status(Status.ERROR, WGADesignerPlugin.PLUGIN_ID, "Unable to register external design.", e));
      }
    }

    if (createdb) {
      IContainer container = null;
      if (design instanceof WGADesign) {
        container = ((WGADesign) design).getProject();
      } else {
        container = (IFolder) design;
      }
      WGAConfiguration wgaConfig = null;
      try {
        wgaConfig = retrieveWGAConfig(true);
      } catch (IncompatibleWGAConfigVersion e) {
        MessageDialog.openWarning(Display.getDefault().getActiveShell(), "Warning",
            "Unable to register design in runtime. WGA Version seams to be incompatible. Please ensure you are using the latest version of WGADevelopmentStudio.");
        WGADesignerPlugin.getDefault().logError(e.getMessage(), e);
      } catch (IOException e) {
        throw new CoreException(new Status(Status.ERROR, WGADesignerPlugin.PLUGIN_ID, "Unable to create default wga configuration.", e));
      }

      if (wgaConfig != null) {
        if (dbkey == null) {
          dbkey = container.getName();
        }
        dbkey = dbkey.toLowerCase();
        if (title == null) {
          title = container.getName();
        }
        if (domain == null) {
          domain = wgaConfig.getDefaultDomain();
        }
        // check if db already exists
        boolean csExists = wgaConfig.hasContentDatabase(dbkey);
        if (csExists) {
          throw new CoreException(new Status(Status.ERROR, WGADesignerPlugin.PLUGIN_ID, "A database with key '" + dbkey + "' already exists."));
        } else {
          int existingDbs = wgaConfig.getContentDatabases().size();
          ContentStore cs = wgaConfig.createContentStoreOnEmbeddedServer(dbkey, container.getName());
          cs.setDomain(domain.getUid());
          cs.setTitle(title);

          if (properties != null) {
            cs.setDefaultLanguage(properties.getProperty(DesignTemplate.PROP_DEFAULT_LANGUAGE, Locale.getDefault().getLanguage()));
          } else {
            cs.setDefaultLanguage(Locale.getDefault().getLanguage());
          }

          // if this is the first autocreated db - make it the default
          // db
          if (wgaConfig.getDefaultDatabase() == null && existingDbs == 0) {
            wgaConfig.setDefaultDatabase(cs.getKey());
          }
        }

        try {
          saveWGAConfig(wgaConfig);
        } catch (Exception e) {
          throw new CoreException(new Status(Status.ERROR, WGADesignerPlugin.PLUGIN_ID, "Unable to update wga configfile.", e));
        }
      }
    }
  }
View Full Code Here

      WGARuntimeConfiguration.write(_config, configFileStream);

      _project.refreshLocal(IResource.DEPTH_ONE, null);
    } catch (Exception e) {
      WGADesignerPlugin.getDefault().logError("Unable to save config of runtime '" + getName() + "'.", e);
      throw new CoreException(new Status(Status.ERROR, WGADesignerPlugin.PLUGIN_ID, "Unable to save config of runtime '" + getName() + "'.", e));
    } finally {
      try {
        if (configFileStream != null) {
          configFileStream.close();
        }
View Full Code Here

        } else {
          _encoding = new WGADesignStructureHelper(((IFileEditorInput) element).getFile()).determineDesignEncoding();         
        }
        return super.createDocument(element)
      } else {
        throw new CoreException(new Status(Status.ERROR, Plugin.PLUGIN_ID, "Unsupported editorinput."))
      }
    } else {
      throw new CoreException(new Status(Status.ERROR, Plugin.PLUGIN_ID, "Unsupported editorinput. Please import files into an eclipse project first."));
    }   
  }
View Full Code Here

      try {
        charset= Charset.forName(encoding);
      } catch (UnsupportedCharsetException ex) {
        String message= "Unsupported encoding '" + encoding + "'.";
        IStatus s= new Status(IStatus.ERROR, Plugin.PLUGIN_ID, IStatus.OK, message, ex);
        throw new CoreException(s);
      } catch (IllegalCharsetNameException ex) {
        String message= "Unsupported encoding '" + encoding + "'.";
        IStatus s= new Status(IStatus.ERROR, Plugin.PLUGIN_ID, IStatus.OK, message, ex);
        throw new CoreException(s);
      }

      CharsetEncoder encoder= charset.newEncoder();
      encoder.onMalformedInput(CodingErrorAction.REPLACE);
      encoder.onUnmappableCharacter(CodingErrorAction.REPORT);

      InputStream stream;

      try {
        byte[] bytes;
        ByteBuffer byteBuffer= encoder.encode(CharBuffer.wrap(document.get()));
        if (byteBuffer.hasArray())
          bytes= byteBuffer.array();
        else {
          bytes= new byte[byteBuffer.limit()];
          byteBuffer.get(bytes);
        }
        stream= new ByteArrayInputStream(bytes, 0, byteBuffer.limit());
      } catch (CharacterCodingException ex) {
        Assert.isTrue(ex instanceof UnmappableCharacterException);
        String message= "Charset mapping failed.";
        IStatus s= new Status(IStatus.ERROR, Plugin.PLUGIN_ID, EditorsUI.CHARSET_MAPPING_FAILED, message, null);
        throw new CoreException(s);
      }

      if (file.exists()) {

        if (info != null && !overwrite)
View Full Code Here

        }
      } else {       
        manager.createDeployment(getProject(), monitor);
      }
    } catch (Exception e) {
      throw new CoreException(new Status(Status.ERROR, WGADesignerPlugin.PLUGIN_ID, "Unable to create or update wga deployment.", e));
    }
    return null;
  }
View Full Code Here

   * a <code>NullProgressMonitor</code> if no progress is to be reported.
   * @return Returns the Status of the Operation.
   */
  public IStatus reload(final IBookMark bookmark, final Shell shell, final IProgressMonitor monitor) {
    Assert.isNotNull(bookmark);
    CoreException ex = null;

    /* Keep URL of Feed as final var */
    final URI feedLink = bookmark.getFeedLinkReference().getLink();

    try {
View Full Code Here

   * a <code>NullProgressMonitor</code> if no progress is to be reported.
   * @return Returns the Status of the Operation.
   */
  public IStatus reload(final IBookMark bookmark, final Shell shell, final IProgressMonitor monitor) {
    Assert.isNotNull(bookmark);
    CoreException ex = null;

    /* Keep URL of Feed as final var */
    final URI feedLink = bookmark.getFeedLinkReference().getLink();

    try {
View Full Code Here

TOP

Related Classes of org.eclipse.core.runtime.CoreException

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.