Package it.eng.spagobi.utilities.engines

Examples of it.eng.spagobi.utilities.engines.SpagoBIEngineServiceException


     
     
     
      JSONResponse jsonResponse = null;
      if(uresolvedReferenceErrors.size() > 0) {
        SpagoBIEngineServiceException validationException;
        String msg = "Unresolved reference error: ";
        for(int i = 0; i < uresolvedReferenceErrors.size(); i++) {
          String error = (String)uresolvedReferenceErrors.get(i);
          msg += "\n" + error + "; ";
        }
        validationException =  new SpagoBIEngineServiceException(getActionName(), msg);
        jsonResponse = new JSONFailure(validationException);
      } else
        scriptManager = new ScriptEngineManager();
        groovyScriptEngine = scriptManager.getEngineByName("groovy");
       
        // bindings ...
        groovyScriptEngine.put("attributes", attributes);
        groovyScriptEngine.put("parameters", parameters);
        groovyScriptEngine.put("qFields", qFields);
        groovyScriptEngine.put("dmFields", dmFields);
        groovyScriptEngine.put("fields", qFields);
       
        Object calculatedValue = null;
        try {
          calculatedValue = groovyScriptEngine.eval(expression);
          jsonResponse = new JSONAcknowledge();
        } catch (ScriptException e) {
          SpagoBIEngineServiceException validationException;
          Throwable t = e;
          String msg = t.getMessage();
          while( (msg = t.getMessage()) == null && t.getCause()!= null) t = t.getCause();
          if(msg == null) msg = e.toString();
          //msg = "Syntatic error at line:" + e.getLineNumber() + ", column:" + e.getColumnNumber() + ". Error details: " + msg;
          validationException = new SpagoBIEngineServiceException(getActionName(), msg, e);
          jsonResponse = new JSONFailure(validationException);
          //logger.error("validation error", e);
       
      }
     
      try {
        writeBackToClient( jsonResponse );
      } catch (IOException e) {
        String message = "Impossible to write back the responce to the client";
        throw new SpagoBIEngineServiceException(getActionName(), message, e);
      }
     
    } catch(Throwable t) {
      throw SpagoBIEngineServiceExceptionHandler.getInstance().getWrappedException(getActionName(), getEngineInstance(), t);
    } finally {
View Full Code Here


     
      try {
        writeBackToClient( new JSONAcknowledge() );
      } catch (IOException e) {
        String message = "Impossible to write back the responce to the client";
        throw new SpagoBIEngineServiceException(getActionName(), message, e);
      }
     
    } catch(Throwable t) {
      throw SpagoBIEngineServiceExceptionHandler.getInstance().getWrappedException(getActionName(), getEngineInstance(), t);
    } finally {
View Full Code Here

        field = new ModelCalculatedField(alias, type, expression, true);
      }
     
     
    } catch (Throwable t) {
      throw new SpagoBIEngineServiceException(getActionName(), "impossible to deserialize calculated field [" + fieldJSON.toString() + "]", t);
    }         
   
   
    return field;
  }
View Full Code Here

        } else {
          writeBackToClient( new JSONSuccess( array, callback ));
        }
      } catch (IOException e) {
        String message = "Impossible to write back the responce to the client";
        throw new SpagoBIEngineServiceException(getActionName(), message, e);
      }
     
    } catch (Throwable t) {
      throw SpagoBIEngineServiceExceptionHandler.getInstance().getWrappedException(getActionName(), getEngineInstance(), t);
    } finally {
View Full Code Here

     
      try {
        writeBackToClient(image, null, true, fileName, mimetype);
      } catch (IOException e) {
        String message = "Impossible to write back the responce to the client";
        throw new SpagoBIEngineServiceException(getActionName(), message, e);
      }
     
    } catch (Throwable t) {
      throw SpagoBIEngineServiceExceptionHandler.getInstance().getWrappedException(getActionName(), getEngineInstance(), t);
    } finally {
View Full Code Here

      Assert.assertNotNull(records, "Parameter [" + RECORDS + "] cannot be null in oder to execute " + this.getActionName() + " service");

      // if no records are selected, send a message to the client
      if (records.length() == 0) {
        try {
          writeBackToClient( new JSONFailure(new SpagoBIEngineServiceException(getActionName(), "No records selected!!")) );
          return;
        } catch (IOException e) {
          String message = "Impossible to write back the responce to the client";
          throw new SpagoBIEngineServiceException(getActionName(), message, e);
        }
      }
     
      // if some columns are missing, send a message to the client
      List<String> missingColumns = getMissingColumns(serviceConfig, records);
      logger.debug("Missing columns : " + join(missingColumns, ","));
      if (missingColumns.size() > 0) {
        logger.debug("The following columns are required in order to invoke " +
            "the required service: " + join(missingColumns, ","));
        try {
          JSONObject obj = new JSONObject();
          obj.put("missingcolumns", join(missingColumns, ","));
          writeBackToClient( new JSONSuccess(obj) );
          return;
        } catch (IOException e) {
          String message = "Impossible to write back the responce to the client";
          throw new SpagoBIEngineServiceException(getActionName(), message, e);
        }
      }
     
      // invoke external service
      String serviceResponse = null;
      try {
        extServiceMonitor = MonitorFactory.start("QbeEngine.externalService");
        serviceResponse = invokeExternalService(serviceConfig, records);
      } finally {
        extServiceMonitor.stop();
      }
      logger.debug("Service has returned this message response:\n" + serviceResponse);
     
      try {
        JSONObject obj = new JSONObject();
        obj.put("serviceresponse", serviceResponse);
        writeBackToClient( new JSONSuccess(obj) );
      } catch (IOException e) {
        String message = "Impossible to write back the responce to the client";
        throw new SpagoBIEngineServiceException(getActionName(), message, e);
      }
     
    } catch(Throwable t) {
      errorHitsMonitor = MonitorFactory.start("QbeEngine.errorHits");
      errorHitsMonitor.stop();
View Full Code Here

    String result = null;
    try {
      result = proxy.processRecords(records.toString(), serviceConfig.getOperation());
    } catch (RemoteException e) {
      if (e.detail != null && e.detail instanceof SocketTimeoutException) {
        throw new SpagoBIEngineServiceException(getActionName(), "Service invocation produced a timeout error", e);
      } else {
        throw e;
      }
    }
    return result;
View Full Code Here

     
      try {
        writeBackToClient( new JSONSuccess(responseJSON) );
      } catch (IOException e) {
        String message = "Impossible to write back the responce to the client";
        throw new SpagoBIEngineServiceException(getActionName(), message, e);
      }
    } catch(Throwable t) {
      throw SpagoBIEngineServiceExceptionHandler.getInstance().getWrappedException(getActionName(), getEngineInstance(), t);
    } finally {
      logger.debug("OUT");
View Full Code Here

      try {
      super.service(request, response);
     
      FileItem uploaded = (FileItem) request.getAttribute("UPLOADED_FILE");
      if (uploaded == null) {
        throw new SpagoBIEngineServiceException(getActionName(), "No file was uploaded");
      }
       
      UserProfile userProfile = (UserProfile) getEnv().get(EngineConstants.ENV_USER_PROFILE);
      logger.info("User [id : " + userProfile.getUserId() + ", name : " + userProfile.getUserName() + "] " +
          "is uploading file [" + uploaded.getName() + "] with size [" + uploaded.getSize() + "]");
     
      checkUploadedFile(uploaded);
     
      logger.debug("Saving file...");
      saveFile(uploaded);
      logger.debug("File saved");
     
      replayToClient( null );
     
    } catch (Throwable t) {
      SpagoBIEngineServiceException e = SpagoBIEngineServiceExceptionHandler
          .getInstance().getWrappedException(getActionName(),
              getEngineInstance(), t);
      replayToClient( e );
    } finally {
      logger.debug("OUT");
View Full Code Here

      // check if number of existing images is the max allowed
      File[] existingImages = GetWorksheetImagesListAction.getImagesList();
      int existingImagesNumber = existingImages.length;
      int maxNumber = QbeEngineConfig.getInstance().getWorksheetImagesMaxNumber();
      if (existingImagesNumber >= maxNumber) {
        throw new SpagoBIEngineServiceException(getActionName(), "Max images number reached");
      }
      // check if the file already exists
      String fileName = SpagoBIUtilities.getRelativeFileNames(uploaded.getName());
      File imagesDir = QbeEngineConfig.getInstance().getWorksheetImagesDir();
      File saveTo = new File(imagesDir, fileName);
      if (saveTo.exists()) {
        throw new SpagoBIEngineServiceException(getActionName(), "File already exists");
      }
      // check if the uploaded file is empty
      if (uploaded.getSize() == 0) {
        throw new SpagoBIEngineServiceException(getActionName(), "The uploaded file is empty");
      }
      // check if the uploaded file exceeds the maximum dimension
      int maxSize = QbeEngineConfig.getInstance().getWorksheetImagesMaxSize();
      if (uploaded.getSize() > maxSize) {
        throw new SpagoBIEngineServiceException(getActionName(), "The uploaded file exceeds the maximum size, that is " + maxSize);
      }
    } finally {
      logger.debug("OUT");
    }
  }
View Full Code Here

TOP

Related Classes of it.eng.spagobi.utilities.engines.SpagoBIEngineServiceException

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.