Package org.dmd.util.exceptions

Examples of org.dmd.util.exceptions.ResultException


    ClassDefinition    cd  = null;
    AttributeDefinition  ad  = null;
   
    if ((cd = schema.isClass((String)uco.classes.get(0))) == null){
      DebugInfo.debug("UncheckedObject:\n\n" + uco.toOIF());
          ResultException ex = new ResultException();
            ex.result.addResult(Result.ERROR,"Unknown class: " + uco.classes.get(0));
            throw(ex);
    }
   
   
    rc  = cd.newInstance();
    dmo = rc.getDmcObject();
           
    // And add any auxiliary classes if we have them
    for(int i=1; i<uco.classes.size(); i++){
      if ((cd = schema.isClass((String)uco.classes.get(i))) == null){
        DebugInfo.debug("UncheckedObject AUX:\n\n" + uco.toOIF());
            ResultException ex = new ResultException();
              ex.result.addResult(Result.ERROR,"Unknown class: " + uco.classes.get(i));
              throw(ex);
      }
      rc.addAux(cd);
    }
       
    Iterator<String> names = uco.getAttributeNames();
    while(names.hasNext()){
      String n = names.next();
      DmcAttributeInfo ai = dmo.getAttributeInfo(n);
     
      ad = schema.adef(n);
     
      if (ad == null){
            ResultException ex = new ResultException();
              ex.result.addResult(Result.ERROR,"Unknown attribute: " + n);
              throw(ex);
      }
     
      // If the DMO doesn't directly support the attribute i.e. it's not in it
      // attribute info map, the attribute must be associated with an auxiliary class.
      // So, we have to get the DmcAttributeInfo from the attribute definition.
      if (ai == null){
        ai = DmcOmni.instance().getInfo(ad.getDmdID());
        if (ai == null){
              ResultException ex = new ResultException();
                ex.result.addResult(Result.ERROR,"Could not retrieve DmcAttributeInfo for: " + n);
                throw(ex);
        }
      }
     
View Full Code Here


   */
  public void loadPlugins(String fn) throws ResultException, DmcValueException, DmcRuleExceptionSet {
    File pluginFile = new File(fn);
   
    if (!pluginFile.exists()){
      ResultException ex = new ResultException();
      ex.addError("Could not open DMP Servlet configuration file: " + fn);
      throw(ex);
    }
    configParser.parseFile(fn);
   
    for(PluginConfig sp: pluginConfigs.values()){
      DmpServletPlugin plugin = instantiatePlugin(sp);
     
      if (plugin instanceof RequestTrackerIF){
        if (requestTracker == null){
          requestTracker = (RequestTrackerIF) plugin;
          requestTrackerPlugin = plugin;
        }
        else{
          ResultException ex = new ResultException("Multiple request tracker plugins specified.");
          throw(ex);
        }
      }
      else if (plugin instanceof CacheIF){
        if (cache == null){
          cache = (CacheIF) plugin;
          cachePlugin = plugin;
        }
        else{
          ResultException ex = new ResultException("Multiple cache plugins specified.");
          throw(ex);
        }
      }
      else if (plugin instanceof SecurityManagerIF){
        if (securityManager == null){
          securityManager = (SecurityManagerIF) plugin;
          securityPlugin  = plugin;
        }
        else{
          ResultException ex = new ResultException("Multiple security manager plugins specified.");
          throw(ex);
        }
      }
      else{
        startOrder.put(sp.getStartOrder(), plugin);
      }
    }
   
    if (requestTracker == null){
      ResultException ex = new ResultException();
      ex.addError("No plugin has been specified that implements the org.dmd.dmp.server.servlet.base.interfaces.RequestTrackerIF interface");
      throw(ex);
    }
   
    if (cache == null){
      ResultException ex = new ResultException();
      ex.addError("No plugin has been specified that implements the org.dmd.dmp.server.servlet.base.interfaces.CacheIF interface");
      throw(ex);
    }
   
    if (securityManager == null){
      ResultException ex = new ResultException();
      ex.addError("No plugin has been specified that implements the org.dmd.dmp.server.servlet.base.interfaces.SecurityManagerIF interface");
      throw(ex);
    }
  }
View Full Code Here

    Class<?> pluginClass = null;
   
    try {
      pluginClass = Class.forName(pc.getPluginClass());
    } catch (ClassNotFoundException e) {
      ResultException ex = new ResultException();
      ex.addError("Plugin class not found: " + pc.getPluginClass());
      ex.setLocationInfo(pc.getFile(), pc.getLineNumber());
      throw(ex);
    }
   
    try {
      rc = (DmpServletPlugin) pluginClass.newInstance();
      rc.setManagerAndConfig(this,pc);
    } catch (InstantiationException e) {
      ResultException ex = new ResultException();
      ex.addError("InstantiationException for: " + pc.getPluginClass());
      ex.setLocationInfo(pc.getFile(), pc.getLineNumber());
      throw(ex);
    } catch (IllegalAccessException e) {
      ResultException ex = new ResultException();
      ex.addError("IllegalAccessException for: " + pc.getPluginClass());
      ex.setLocationInfo(pc.getFile(), pc.getLineNumber());
      throw(ex);
    }
   
    return(rc);
  }
View Full Code Here

    PluginConfig config = null;
   
    try {
      config = (PluginConfig) factory.createWrapper(uco);
    } catch (ClassNotFoundException e) {
      ResultException ex = new ResultException("Unknown object class: " + uco.classes.get(0));
      ex.result.lastResult().moreMessages("The plugin configuration file should contain PluginConfig objects.");
      ex.result.lastResult().fileName(infile);
      ex.result.lastResult().lineNumber(lineNumber);
      throw(ex);
    } catch (ClassCastException e){
      ResultException ex = new ResultException("Invalid object in plugin config file: " + uco.classes.get(0));
      ex.result.lastResult().fileName(infile);
      ex.result.lastResult().lineNumber(lineNumber);
      throw(ex);
    }
   
    config.setLineNumber(lineNumber);
    config.setFile(infile);
    if (config.getPluginName() != null)
      config.setCamelCaseName(config.getPluginName());
   
    try {
      ruleManager.executeAttributeValidation(config.getDmcObject());
      ruleManager.executeObjectValidation(config.getDmcObject());
//    } catch (DmcValueExceptionSet e) {
//      ResultException ex = new ResultException();
//      for(DmcValueException dve: e.getExceptions()){
//        ex.addError(dve.getLocalizedMessage());
//      }
//      ex.setLocationInfo(infile, lineNumber);
//      ex.result.lastResult().moreMessages("Object class: " + config.getConstructionClassName());
//     
//      throw(ex);
    } catch (DmcRuleExceptionSet e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
   
    if (pluginConfigs.get(config.getObjectName()) != null){
      ResultException ex = new ResultException("Duplicate plugin name: " + config.getObjectName());
      ex.result.lastResult().fileName(infile);
      ex.result.lastResult().lineNumber(lineNumber);
      throw(ex);
    }
   
View Full Code Here

    synchronized (theCache) {
     
      DmwNamedObjectWrapper existing = theCache.get(obj.getObjectName());
     
      if (existing != null){
        ResultException ex = new ResultException();
        ex.addError("Duplicate object name: " + obj.getObjectName());
        ex.result.lastResult().moreMessages("Existing:\n" + existing.toOIF());
        ex.result.lastResult().moreMessages("New:\n" + obj.toOIF());
        throw(ex);
      }
     
      if (obj.getConstructionClass().getIsNamedBy().getType().getIsHierarchicName()){
        DmcHierarchicObjectName hon = ((DmwHierarchicObjectWrapper)obj).getObjectName();
        DmcHierarchicObjectName pn = hon.getParentName();
       
        if (pn != null){
          DmwHierarchicObjectWrapper po = (DmwHierarchicObjectWrapper) theCache.get(pn);
         
          if(po == null){
            ResultException ex = new ResultException();
            ex.addError("Could not find parent object: " + po + " for object: " + hon);
            throw(ex);
          }
         
          if (obj.getConstructionClass().allowsParent(po.getConstructionClass())){
            po.addSubComponent((DmwHierarchicObjectWrapper) obj);
          }
          else{
            ResultException ex = new ResultException();
            ex.addError("Object of class: " + po.getConstructionClassName() + " is not a valid parent for object of class: " + obj.getConstructionClassName());
            throw(ex);
          }
        }
       
      }
View Full Code Here

    DmwNamedObjectWrapper wrapper = null;
   
    try {
      wrapper = (DmwNamedObjectWrapper) factory.createWrapper(uco);
    } catch (ClassNotFoundException e) {
      ResultException ex = new ResultException("Unknown object class: " + uco.classes.get(0));
      ex.result.lastResult().fileName(infile);
      ex.result.lastResult().lineNumber(lineNumber);
      throw(ex);
    }
    catch (ResultException ex){
      ex.setLocationInfo(infile, lineNumber);
      throw(ex);
    }
    catch(DmcValueException e){
      ResultException ex = new ResultException();
      ex.addError(e.getMessage());
      if (e.getAttributeName() != null)
        ex.result.lastResult().moreMessages("Attribute: " + e.getAttributeName());
      ex.setLocationInfo(infile, lineNumber);
      throw(ex);
    }
 
    addObject(wrapper);
  }
View Full Code Here

    if (handledBy != null){
      // If nothing fires this event and it's supposed to be fired in this module, complain
      // An event that is meant to be fired outside a module's scope will have its firedInThisModule
      // flag set to false.
      if ((firedBy == null) && isFiredInThisModule()){
        ResultException ex = new ResultException();
        ex.addError("The " + getEventName() + " is handled by the following components, but is never fired or broadcast:");
        for(MvwDefinition def: handledBy){
          ex.result.lastResult().moreMessages(def.getConstructionClassName() + ":" + def.getObjectName() + " defined in: " + def.getFile());
        }
        if (local != null){
          ex.result.lastResult().moreMessages(" ");
View Full Code Here

      // Someone wants to handle this event, but it isn't fired by anyone
      StringBuffer sb = new StringBuffer();
      for(MvwDefinition def: handledBy){
        sb.append(def.getObjectName() + " ");
      }
      ResultException ex = new ResultException();
      ex.addError("The " + getEventName() + " is handled by: " + sb.toString() + " but is never fired.");
      throw(ex);
    }
    if ( (firedBy != null) || (handledBy != null))
      return(true);
    return(false);
View Full Code Here

     
      try {
        objclass = Class.forName(getEnumGeneratorClass());
      } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        ResultException ex = new ResultException("Could not load java class for enum mapping generator: " + getEnumGeneratorClass());
        throw(ex);
      };

      try {
        gen = objclass.newInstance();
      } catch (Exception e) {
        ResultException ex = new ResultException("Could not instantiate java class for enum mapping generator: " + getEnumGeneratorClass());
        throw(ex);
      }
     
      try {
        generator = (MvwEnumMappingGeneratorIF)gen;
      } catch (Exception e) {
        ResultException ex = new ResultException("This class does not implement the MvwEnumMappingGeneratorIF interface: " + getEnumGeneratorClass());
        throw(ex);
      }
    }
  }
View Full Code Here

  }
 
  public void initLabelInfo(RunContextItemCollection context) throws ResultException {
    if (getDisplayLabel() == null){
      if (getDisplayLabelI18N() == null){
        ResultException errors  = new ResultException();
        errors.addError("The " + getElementName() + " SubMenu must have either a displayLabel or a displayLabelI18N defined.");
        errors.result.lastResult().fileName(getFile());
        errors.result.lastResult().lineNumber(getLineNumber());     
        throw(errors);
      }
      int period = getDisplayLabelI18N().indexOf(".");
      if (period == -1){
        ResultException errors  = new ResultException();
        errors.addError("The " + getElementName() + " SubMenu has a malformed displayLabelI18N: " + getDisplayLabelI18N());
        errors.result.lastResult().fileName(getFile());
        errors.result.lastResult().lineNumber(getLineNumber());     
        throw(errors);
      }
      String rciString = getDisplayLabelI18N().substring(0, period).trim();
     
      RunContextItem rci = context.getItem(rciString);
     
      if (rci == null){
        ResultException errors  = new ResultException();
        errors.addError("The " + getElementName() + " SubMenu refers to an unknown RunContextItem in its displayLabelI18N: " + rciString);
        errors.result.lastResult().fileName(getFile());
        errors.result.lastResult().lineNumber(getLineNumber());     
        throw(errors);
      }
      I18NRCI = rci;
View Full Code Here

TOP

Related Classes of org.dmd.util.exceptions.ResultException

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.