Package it.eng.spagobi.utilities.engines

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


        stream.flush();
        stream.close();
        try {       
          writeBackToClient(exportFile, null, writeBackResponseInline, "crosstab.xls", mimeType);
        } catch (IOException ioe) {
          throw new SpagoBIEngineException("Impossible to write back the responce to the client", ioe);
        }
      } else {
        throw new SpagoBIEngineException("Cannot export crosstab in " + mimeType + " format, only application/vnd.ms-excel is supported");
      }

    } catch (Throwable t) {     
      throw SpagoBIEngineServiceExceptionHandler.getInstance().getWrappedException(getActionName(), getEngineInstance(), t);
    } finally {
View Full Code Here


    try {
      rowDataJSON = new JSONObject();
      rowDataJSON.put(FORMVALUES, formJSON);   
      rowData = rowDataJSON.toString();
    } catch (Throwable e) {
      throw new SpagoBIEngineException("Impossible to store analysis state from catalogue object", e);
    }
   
    return rowData.getBytes();
  }
View Full Code Here

        setProperty( FORMVALUES,  formJSON);
 
        logger.debug("analysis state loaded succsfully from row data");
      }
    } catch (JSONException e) {
      throw new SpagoBIEngineException("Impossible to load analysis state from raw data", e);
    } finally {
      logger.debug("OUT");
    }
  }
View Full Code Here

      // Parse the request
      List items = null;
      try {
        items = upload.parseRequest(servletIOManager.getRequest());
      } catch (FileUploadException e) {
        throw new SpagoBIEngineException("Impossible to upload file", "impossible.to.upload.file", e );
      }
     
      jobDeploymentDescriptor = getJobsDeploymetDescriptor(items);
     
      // Process the uploaded items
      Iterator iter = items.iterator();
      while (iter.hasNext()) {
          FileItem item = (FileItem) iter.next();
          if (item.isFormField()) {
              processFormField(item);
          } else {
              String[] jobNames = processUploadedFile(item, jobDeploymentDescriptor);
              if(TalendEngine.getConfig().isAutoPublishActive()) {
                if(jobNames == null) continue;
                for(int i = 0; i < jobNames.length; i++) {
                  publishOnSpagoBI(servletIOManager, jobDeploymentDescriptor.getLanguage(), jobDeploymentDescriptor.getProject(), jobNames[i]);    
                }
              }
          }
      }
     
      servletIOManager.tryToWriteBackToClient( "OK" );     
     
    } catch (Exception e){
      throw new SpagoBIEngineException("An error occurred while executing [JobUploadService]", "an.unpredicted.error.occured", e);
    } finally {
      logger.debug("OUT");
    }   
  }
View Full Code Here

        //checks if some user tries to execute document with no template
        if(template == null
            ||(template.getViewName() == null || template.getViewName().equals(""))
            ||(template.getCubeName() == null || template.getCubeName().equals(""))){
          logger.error("Forbidden operation: user trying to execute document with no template or view defined");
          throw new SpagoBIEngineException("You are trying to execute document with no template or view defined.",
              "You are trying to execute document with no template or view defined.") {
          }
         
        }
      }
      jpaloUrl += ",hideconnectionaccount";
      jpaloUrl += ",hideuserrights";
      jpaloUrl += ",hideviewtabs";
      jpaloUrl += ")";
      logger.info(jpaloUrl);
      //System.out.println(jpaloUrl);

      String urlWithSessionID = servletIOManager.getResponse().encodeRedirectURL( jpaloUrl );
      servletIOManager.getResponse().sendRedirect( urlWithSessionID );
     
    } catch(Throwable t) {
      t.printStackTrace();
      logger.error(t.getMessage());
      if(t instanceof SpagoBIEngineException){
        throw (SpagoBIEngineException)t;
      }else{
        throw new SpagoBIEngineException("An unpredicted error occured while executing palo-engine. Please check the log for more informations on the causes",
        "An unpredicted error occured while executing palo-engine. Please check the log for more informations on the causes", t);   
      }
    } finally {
      servletIOManager.auditServiceEndEvent();
      logger.debug("OUT");
View Full Code Here

        logger.warn("Row data encoding version [" + encodingFormatVersion + "] does not match with the current version used by the engine [" + QbeEngineStaticVariables.CURRENT_QUERY_VERSION + "] ");
        logger.debug("Converting from encoding version [" + encodingFormatVersion + "] to encoding version [" + QbeEngineStaticVariables.CURRENT_QUERY_VERSION + "]....");
        IQbeEngineAnalysisStateLoader analysisStateLoader;
        analysisStateLoader = QbeEngineAnalysisStateLoaderFactory.getInstance().getLoader(encodingFormatVersion);
        if(analysisStateLoader == null) {
          throw new SpagoBIEngineException("Unable to load data stored in format [" + encodingFormatVersion + "] ");
        }
        abalysisStateJSON = (JSONObject)analysisStateLoader.load(str);
        logger.debug("Encoding conversion has been executed succesfully");
      }
     
      JSONObject catalogueJSON = abalysisStateJSON.getJSONObject("catalogue");
      JSONObject workSheetDefinitionJSON = abalysisStateJSON.optJSONObject(QbeEngineStaticVariables.WORKSHEET_DEFINITION_LOWER);
      setProperty( QbeEngineStaticVariables.CATALOGUE,  catalogueJSON);
      if(workSheetDefinitionJSON!=null){
        setProperty( QbeEngineStaticVariables.WORKSHEET_DEFINITION,  workSheetDefinitionJSON);
      }
      logger.debug("analysis state loaded succsfully from row data");
    } catch (JSONException e) {
      throw new SpagoBIEngineException("Impossible to load analysis state from raw data", e);
    } finally {
      logger.debug("OUT");
    }
  }
View Full Code Here

      rowDataJSON.put("catalogue", catalogueJSON);
      rowDataJSON.put("crosstabdefinition", workSheetDefinitionJSON);
     
      rowData = rowDataJSON.toString();
    } catch (Throwable e) {
      throw new SpagoBIEngineException("Impossible to store analysis state from catalogue object", e);
    }
   
    return rowData.getBytes();
  }
View Full Code Here

        logger.warn("Row data encoding version [" + encodingFormatVersion + "] does not match with the current version used by the engine [" + CURRENT_VERSION + "] ");
        logger.debug("Converting from encoding version [" + encodingFormatVersion + "] to encoding version [" + CURRENT_VERSION + "]....");
        IFormStateLoader formViewerStateLoader;
        formViewerStateLoader = FormStateLoaderFactory.getInstance().getLoader(encodingFormatVersion);
        if (formViewerStateLoader == null) {
          throw new SpagoBIEngineException("Unable to load data stored in format [" + encodingFormatVersion + "] ");
        }
        formStateJSON = (JSONObject) formViewerStateLoader.load(str);
        logger.debug("Encoding conversion has been executed succesfully");
      }
     
      logger.debug("analysis state loaded succsfully from row data");
     
      // adding other info that are created dynamically
      QbeJSONTemplateParser.addAdditionalInfo(formStateJSON);
      setProperty( FORM_STATE,  formStateJSON);
     
    } catch (JSONException e) {
      throw new SpagoBIEngineException("Impossible to load form state from raw data", e);
    } finally {
      logger.debug("OUT");
    }
  }
View Full Code Here

    try {
      formStateJSON = (JSONObject) getProperty( FORM_STATE );
      formStateJSON.put("version", CURRENT_VERSION);
      rowData = formStateJSON.toString();
    } catch (Throwable e) {
      throw new SpagoBIEngineException("Impossible to store form state", e);
    }
   
    return rowData.getBytes();
  }
View Full Code Here

      fieldsReader = new SQLFieldsReader(sqlQuery, transaction.getSQLConnection());
      try {
        extractedFields = fieldsReader.readFields();
      } catch (Exception e) {
        logger.debug("Impossible to extract fields from query");
        throw new SpagoBIEngineException("Impossible to extract fields from query: " + jpaQueryStr, e);
      }
      logger.debug("Fields extracted succesfully");
     
      Assert.assertTrue(getEngineInstance().getActiveQuery().getDataMartSelectFields(true).size()+getEngineInstance().getActiveQuery().getInLineCalculatedSelectFields(true).size() == extractedFields.size(),
          "The number of fields extracted from query resultset cannot be different from the number of fields specified into the query select clause");
     
      decorateExtractedFields( extractedFields );
     
      params = new HashMap();
      params.put("pagination", getPaginationParamVaue(mimeType) );
     
     
      SourceBean config = (SourceBean)ConfigSingleton.getInstance();   
      SourceBean baseTemplateFileSB = (SourceBean)config.getAttribute("QBE.TEMPLATE-BUILDER.BASE-TEMPLATE");
      String baseTemplateFileStr = null;
      if(baseTemplateFileSB != null) baseTemplateFileStr = baseTemplateFileSB.getCharacters();
      File baseTemplateFile = null;
      if(baseTemplateFileStr != null) baseTemplateFile = new File(baseTemplateFileStr);
     
      templateBuilder = new TemplateBuilder(sqlQuery, extractedFields, params, baseTemplateFile);
      templateContent = templateBuilder.buildTemplate();
     
      if( !"text/jrxml".equalsIgnoreCase( mimeType ) ) {
        if( "application/vnd.ms-excel".equalsIgnoreCase( mimeType ) ) {
         
          IDataStore dataStore = null;
         
          if (!isFormEngineInstance) {
            // case of standard QBE
           
            IDataSet dataSet = null;
           
            Integer limit = 0;
            Integer start = 0;
            Integer maxSize = QbeEngineConfig.getInstance().getResultLimit()
            boolean isMaxResultsLimitBlocking = QbeEngineConfig.getInstance().isMaxResultLimitBlocking();
            dataSet = QbeDatasetFactory.createDataSet(statement);
            dataSet.setAbortOnOverflow(isMaxResultsLimitBlocking);
           
            Map userAttributes = new HashMap();
            UserProfile profile = (UserProfile)this.getEnv().get(EngineConstants.ENV_USER_PROFILE);
            Iterator it = profile.getUserAttributeNames().iterator();
            while(it.hasNext()) {
              String attributeName = (String)it.next();
              Object attributeValue = profile.getUserAttribute(attributeName);
              userAttributes.put(attributeName, attributeValue);
            }
            dataSet.addBinding("attributes", userAttributes);
            dataSet.addBinding("parameters", this.getEnv());
            logger.debug("Executing query ...");
            dataSet.loadData(start, limit, (maxSize == null? -1: maxSize.intValue()));
           
            dataStore = dataSet.getDataStore();
         
          } else {
            // case of FormEngine
           
            JDBCDataSet dataset = new JDBCDataSet();
            IDataSource datasource = (IDataSource) this.getEnv().get( EngineConstants.ENV_DATASOURCE );
            dataset.setDataSource(datasource);
            dataset.setUserProfileAttributes(UserProfileUtils.getProfileAttributes( (UserProfile) this.getEnv().get(EngineConstants.ENV_USER_PROFILE)));
            dataset.setQuery(sqlQuery);
            logger.debug("Executing query ...");
            dataset.loadData();
            dataStore = dataset.getDataStore();
          }
         
          Exporter exp = new Exporter(dataStore);
          exp.setExtractedFields(extractedFields);
         
          Workbook wb = exp.exportInExcel();
         
          File file = File.createTempFile("workbook", ".xls");
          FileOutputStream stream = new FileOutputStream(file);
          wb.write(stream);
          stream.flush();
          stream.close();
          try {       
            writeBackToClient(file, null, writeBackResponseInline, "workbook.xls", mimeType);
          } catch (IOException ioe) {
            throw new SpagoBIEngineException("Impossible to write back the responce to the client", ioe);
          finally{
            if(file != null && file.exists()) {
              try {
                file.delete();
              } catch (Exception e) {
                logger.warn("Impossible to delete temporary file " + file, e);
              }
            }
          }
     
        }else{
          try {
            reportFile = File.createTempFile("report", ".rpt");
          } catch (IOException ioe) {
            throw new SpagoBIEngineException("Impossible to create a temporary file to store the template generated on the fly", ioe);
          }
         
          setJasperClasspath();
          connection = transaction.getSQLConnection();
         
          runner = new ReportRunner( );
          Locale locale = this.getLocale();
          try {
            runner.run( templateContent, reportFile, mimeType, connection, locale);
          catch (Exception e) {
            throw new SpagoBIEngineException("Impossible compile or to export the report", e);
          }
         
          try {       
            writeBackToClient(reportFile, null, writeBackResponseInline, "report." + fileExtension, mimeType);
          } catch (IOException ioe) {
            throw new SpagoBIEngineException("Impossible to write back the responce to the client", ioe);
         
        }
      } else {
        try {       
          writeBackToClient(200, templateContent, writeBackResponseInline, "report." + fileExtension, mimeType);
        } catch (IOException e) {
          throw new SpagoBIEngineException("Impossible to write back the responce to the client", e);
        }
      }
    } catch (Throwable t) {     
      throw SpagoBIEngineServiceExceptionHandler.getInstance().getWrappedException(getActionName(), getEngineInstance(), t);
    } finally {
View Full Code Here

TOP

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

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.