@Test(expected = NoSuchMethodException.class)
 public void testExceptionOnNonExistingConstructor() throws Throwable {
   ExceptionFactory ef =
       new ExceptionFactory() {
         @Override
         protected Constructor<?> getExceptionConstructor(Class<?> exceptionClass) {
           return null;
         }
       };
   ef.createException(new ExceptionInfo(new TestException()));
 }
Beispiel #2
0
 public CConfigurationDescription createConvertedConfiguration(
     String id, String name, ICStorageElement el) throws CoreException {
   if (fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException();
   CConfigurationDescription cfg = new CConfigurationDescription(id, name, el, this);
   configurationCreated(cfg);
   return cfg;
 }
Beispiel #3
0
 ICSettingsStorage getStorageBase() throws CoreException {
   if (fStorage == null)
     //			fStorage = new CStorage((InternalXmlStorageElement) getRootStorageElement());
     throw ExceptionFactory.createCoreException(
         "CProjectDescription ICSettingsStorage == null"); //$NON-NLS-1$
   return fStorage;
 }
Beispiel #4
0
 @Override
 public ICConfigurationDescription createConfiguration(
     String id, String name, ICConfigurationDescription base) throws CoreException {
   if (fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException();
   CConfigurationDescription cfg = new CConfigurationDescription(id, name, base, this);
   configurationCreated(cfg);
   return cfg;
 }
Beispiel #5
0
 @Override
 public ICConfigurationDescription createConfiguration(
     String buildSystemId, CConfigurationData data) throws CoreException {
   if (fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException();
   CConfigurationDescription cfg = new CConfigurationDescription(data, buildSystemId, this);
   configurationCreated(cfg);
   return cfg;
 }
Beispiel #6
0
  @Override
  public void removeConfiguration(String name) throws WriteAccessException {
    if (fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException();

    CConfigurationDescription cfgDes = (CConfigurationDescription) getConfigurationByName(name);
    if (cfgDes != null) {
      cfgDes.removeConfiguration();
    }
  }
Beispiel #7
0
  @Override
  public void setCdtProjectCreated() {
    if (!fIsCreating) return;

    if (fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException();

    fIsCreating = false;
    fIsModified = true;
  }
Beispiel #8
0
  @Override
  public void setActiveConfiguration(ICConfigurationDescription cfg) throws WriteAccessException {
    if (fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException();
    if (cfg == null) throw new NullPointerException();

    fActiveCfgInfo.setConfiguration(cfg);

    if (getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
      fSettingCfgInfo.setConfiguration(cfg);
  }
Beispiel #9
0
  public ICStorageElement getRootStorageElement() throws CoreException {
    if (fRootStorageElement == null)
      throw ExceptionFactory.createCoreException(
          "CProjectDescription ICStorageElement == null"); //$NON-NLS-1$

    //		if (fRootStorageElement == null) {
    //			fRootStorageElement = CProjectDescriptionManager.getInstance().createStorage(fProject,
    // true, true, isReadOnly());
    //		}
    return fRootStorageElement;
  }
  /**
   * Return a 2-element array String[]{projName, cfgId}
   *
   * @param id id to parse, must not be null
   * @return String[]{projName, cfgId}
   * @throws CoreException if prjName not valid
   */
  private static String[] parseId(String id) throws CoreException {
    if (id == null) throw new NullPointerException();

    String projName, cfgId;
    int index = id.indexOf(DELIMITER);
    if (index != -1) {
      projName = id.substring(0, index);
      cfgId = id.substring(index + 1);
    } else {
      projName = id;
      cfgId = ACTIVE_CONFIG_ID;
    }

    if ((projName = projName.trim()).length() == 0)
      throw ExceptionFactory.createCoreException(
          SettingsModelMessages.getString("CfgExportSettingContainerFactory.2")); // $NON-NLS-1$

    return new String[] {projName, cfgId};
  }
 @Override
 public void setPath(IPath path) throws WriteAccessException {
   throw ExceptionFactory.createIsReadOnlyException();
 }
 public void setExcluded(boolean excluded) {
   throw ExceptionFactory.createIsReadOnlyException();
 }
 @Override
 public CLanguageData createLanguageDataForExtensions(String languageId, String[] extensions) {
   throw ExceptionFactory.createIsReadOnlyException();
 }
 @Override
 public CLanguageData createLanguageDataForContentTypes(String languageId, String[] typesIds) {
   throw ExceptionFactory.createIsReadOnlyException();
 }
 public ICLanguageSetting createLanguageSettingForExtensions(
     String languageId, String[] extensions) {
   throw ExceptionFactory.createIsReadOnlyException();
 }
 public ICLanguageSetting createLanguageSettingForContentTypes(
     String languageId, String[] typeIds) {
   throw ExceptionFactory.createIsReadOnlyException();
 }
Beispiel #17
0
  public void touch() throws WriteAccessException {
    if (fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException();

    fIsModified = true;
  }
Beispiel #18
0
  @Override
  public void removeConfiguration(ICConfigurationDescription cfg) throws WriteAccessException {
    if (fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException();

    ((CConfigurationDescription) cfg).removeConfiguration();
  }
 public void setName(String name) throws WriteAccessException {
   throw ExceptionFactory.createIsReadOnlyException();
 }
  /**
   * @see net.sf.hajdbc.invocation.InvocationStrategy#invoke(net.sf.hajdbc.sql.SQLProxy,
   *     net.sf.hajdbc.invocation.Invoker)
   */
  @Override
  public <Z, D extends Database<Z>, T, R, E extends Exception> SortedMap<D, R> invoke(
      SQLProxy<Z, D, T, E> proxy, Invoker<Z, D, T, R, E> invoker) throws E {
    Map.Entry<SortedMap<D, R>, SortedMap<D, E>> results = this.collectResults(proxy, invoker);

    SortedMap<D, R> resultMap = results.getKey();
    SortedMap<D, E> exceptionMap = results.getValue();

    if (!exceptionMap.isEmpty()) {
      ExceptionFactory<E> exceptionFactory = proxy.getExceptionFactory();
      DatabaseCluster<Z, D> cluster = proxy.getDatabaseCluster();
      Dialect dialect = cluster.getDialect();

      List<D> failedDatabases = new ArrayList<D>(exceptionMap.size());

      // Determine which exceptions are due to failures
      for (Map.Entry<D, E> entry : exceptionMap.entrySet()) {
        if (exceptionFactory.indicatesFailure(entry.getValue(), dialect)) {
          failedDatabases.add(entry.getKey());
        }
      }

      StateManager stateManager = cluster.getStateManager();

      // Deactivate failed databases, unless all failed
      if (!resultMap.isEmpty() || (failedDatabases.size() < exceptionMap.size())) {
        for (D failedDatabase : failedDatabases) {
          E exception = exceptionMap.remove(failedDatabase);

          if (cluster.deactivate(failedDatabase, stateManager)) {
            logger.error(
                "" + exception + "" + Messages.DATABASE_DEACTIVATED.getMessage(),
                failedDatabase,
                cluster);
          }
        }
      }

      if (!exceptionMap.isEmpty()) {
        // If primary database threw exception
        if (resultMap.isEmpty() || !exceptionMap.headMap(resultMap.firstKey()).isEmpty()) {
          D primaryDatabase = exceptionMap.firstKey();
          E primaryException = exceptionMap.get(primaryDatabase);

          // Deactivate databases with non-matching exceptions
          for (Map.Entry<D, E> entry : exceptionMap.tailMap(primaryDatabase).entrySet()) {
            E exception = entry.getValue();

            if (!exceptionFactory.equals(exception, primaryException)) {
              D database = entry.getKey();

              if (cluster.deactivate(database, stateManager)) {
                logger.error("" + exception + " " + Messages.DATABASE_INCONSISTENT.getMessage());
              }
            }
          }

          // Deactivate databases with results
          for (Map.Entry<D, R> entry : resultMap.entrySet()) {
            D database = entry.getKey();

            if (cluster.deactivate(database, stateManager)) {
              logger.error(Messages.DATABASE_INCONSISTENT.getMessage());
            }
          }

          throw primaryException;
        }
      }
      // Else primary was successful
      // Deactivate databases with exceptions
      for (Map.Entry<D, E> entry : exceptionMap.entrySet()) {
        D database = entry.getKey();
        E exception = entry.getValue();

        if (cluster.deactivate(database, stateManager)) {
          logger.error(Messages.DATABASE_DEACTIVATED.getMessage(), database, cluster);
        }
      }
    }

    return resultMap;
  }
 public ICLanguageSetting createLanguageSetting(IContentType srcType) {
   throw ExceptionFactory.createIsReadOnlyException();
 }