Package it.eng.spagobi.utilities.exceptions

Examples of it.eng.spagobi.utilities.exceptions.SpagoBIServiceException


      udpDao.setUserProfile(getUserProfile());
      daoDomain=DAOFactory.getDomainDAO();
      udpDao.setUserProfile(getUserProfile());
    } catch (EMFUserError e1) {
      logger.error(e1.getMessage(), e1);
      throw new SpagoBIServiceException(SERVICE_NAME,  "Error occurred");
    }
    HttpServletRequest httpRequest = getHttpRequest();
    MessageBuilder m = new MessageBuilder();
    Locale locale = m.getLocale(httpRequest);
   
    String serviceType = this.getAttributeAsString(MESSAGE_DET)
    logger.debug("Service type "+serviceType);
   
    if(serviceType != null && serviceType.equals(UDP_LIST)){
      try {
        Integer start = getAttributeAsInteger( START );
        Integer limit = getAttributeAsInteger( LIMIT );
       
        if(start==null){
          start = START_DEFAULT;
        }
        if(limit==null){
          limit = LIMIT_DEFAULT;
        }

        Integer totalNum = udpDao.countUdp();
       
        List<SbiUdp> udpList = udpDao.loadPagedUdpList(start,limit);
        logger.debug("Loaded udp list");
        JSONArray udpJSON = (JSONArray) SerializerFactory.getSerializer("application/json").serialize(udpList,locale);
        JSONObject udpResponseJSON = createJSONResponseUdp(udpJSON, totalNum);

        writeBackToClient(new JSONSuccess(udpResponseJSON));

      } catch (Throwable e) {
        logger.error(e.getMessage(), e);
        try {
          writeBackToClient("Exception occurred while retrieving user defined properties");
        } catch (IOException e1) {
          logger.error(e1.getMessage(), e1);
        }
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception occurred while retrieving user defined properties", e);
      }
     
    }else if(serviceType != null && serviceType.equals(UDP_DETAIL)){
      try {
        String name = getAttributeAsString(NAME);
        String label = getAttributeAsString(LABEL);
        String description = getAttributeAsString(DESCRIPTION);
        String typeStr = getAttributeAsString(TYPE);     
        Domain tmpDomain = daoDomain.loadDomainByCodeAndValue(UDP_TYPES, typeStr);
        Integer type = tmpDomain.getValueId();
        String familyStr = getAttributeAsString(FAMILY);
        tmpDomain = daoDomain.loadDomainByCodeAndValue(UDP_FAMILIES, familyStr);
        Integer family = tmpDomain.getValueId();
        Boolean isMultivalue = Boolean.valueOf(getAttributeAsBoolean(IS_MULTIVALUE));
       
        String id = getAttributeAsString(ID);
       
        SbiUdp udp = new SbiUdp();
        udp.setName(name);
        udp.setLabel(label);
        udp.setDescription(description);
        udp.setTypeId(type);
        udp.setFamilyId(family);
        udp.setIsMultivalue(isMultivalue);
     
        if(id != null && !id.equals("") && !id.equals("0")){             
          udp.setUdpId(Integer.valueOf(id));
          udpDao.update(udp);
          logger.debug("User attribute "+id+" updated");
          JSONObject attributesResponseSuccessJSON = new JSONObject()
          attributesResponseSuccessJSON.put("success", true)
          attributesResponseSuccessJSON.put("responseText", "Operation succeded");
          writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
        }else{
          Integer udpID = udpDao.insert(udp);
          logger.debug("New User Attribute inserted");
          JSONObject attributesResponseSuccessJSON = new JSONObject();
          attributesResponseSuccessJSON.put("success", true);
          attributesResponseSuccessJSON.put("responseText", "Operation succeded");
          attributesResponseSuccessJSON.put("id", udpID);
          writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
        }
      } catch (JSONException e) {
        logger.error(e.getMessage(), e);
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception occurred while saving new user attribute",
            e);
      } catch (IOException e) {
        logger.error(e.getMessage(), e);
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception occurred while saving new user attribute",
            e);
      } catch (Exception e){
        logger.error(e.getMessage(), e);
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception occurred while saving new user attribute",
            e);
      }
     
    } else if (serviceType != null  && serviceType.equalsIgnoreCase(UDP_DELETE)) {
      Integer id = getAttributeAsInteger(ID);
      try {
        udpDao.delete(id);
        logger.debug("User Attribute deleted");
        writeBackToClient( new JSONAcknowledge("Operation succeded") );

      } catch (Throwable e) {
        logger.error("Exception occurred while deleting role", e);
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception occurred while deleting user attribute",
            e);
      }
    }else if(serviceType == null){
      try {
        List types = daoDomain.loadListDomainsByType(UDP_TYPES);
        getSessionContainer().setAttribute("TYPE_LIST", types);
        List families = daoDomain.loadListDomainsByType(UDP_FAMILIES);
        getSessionContainer().setAttribute("FAMILY_LIST", families);
       
      } catch (EMFUserError e) {
        logger.error(e.getMessage(), e);
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception retrieving types and/or families", e);
      }
    }

    logger.debug("OUT");
View Full Code Here


    // build begin Date     

    if(directory==null){
      logger.error("search directory not specified");
      throw new SpagoBIServiceException(SERVICE_NAME, "Missing directory parameter");
    }

    if(beginDate==null || beginTime==null){
      throw new SpagoBIServiceException(SERVICE_NAME, "Missing begin date parameter");
    }

    if(endDate==null || endTime==null){
      throw new SpagoBIServiceException(SERVICE_NAME, "Missing end date parameter");
    }

    try {

      // remove / from days name
      beginDate = beginDate.replaceAll("/", "");
      endDate = endDate.replaceAll("/", "");
      beginTime = beginTime.replaceAll(":", "");
      endTime = endTime.replaceAll(":", "");

      String beginWhole=beginDate+" "+beginTime;
      String endWhole=endDate+" "+endTime;

      java.text.DateFormat myTimeFormat = new java.text.SimpleDateFormat(PARAMETERS_FORMAT);

      Date begin=myTimeFormat.parse(beginWhole);
      Date end=myTimeFormat.parse(endWhole);


      logger.debug("earch file from begin date " + begin.toString() + " to end date " + end.toString());

      directory=directory.replaceAll("\\\\", "/");

      File dir=new File(directory);
      if(!dir.isDirectory()){
        logger.error("Not a valid directory specified");
        return;
      }


      // get all files that has to be zipped
      Vector filesToZip = searchDateFiles(dir, begin, end, prefix1 + prefix2);
      if (filesToZip.size() == 0){
        /*throw new Exception ("Warning: Files not found with these parameters: <p><br>" +
                   " <b>Directory:</b> " + dir + "<p>" +
                   " <b>Begin date:</b> " + begin + "<p>" +
                   " <b>End date:</b> " + end + "<p>" +
                   " <b>Prefix:</b> " + prefix1 + prefix2 ); */
        throw new Exception ("Warning: Missing files in specified interval!");
      }

      Date today=(new Date());
      DateFormat formatter = new SimpleDateFormat("dd-MMM-yy hh:mm:ss");
      //date = (Date)formatter.parse("11-June-07");   
      String randomName = formatter.format(today);     
      randomName=randomName.replaceAll(" ", "_");
      randomName=randomName.replaceAll(":", "-");

      String directoryZip=System.getProperty("java.io.tmpdir");     
      if (!directoryZip.endsWith(System.getProperty("file.separator"))) {
        directoryZip += System.getProperty("file.separator");
      }
      String fileZip=randomName+".zip";
      String pathZip=directoryZip+fileZip;
      pathZip=pathZip.replaceAll("\\\\","/");     
      directoryZip=directoryZip.replaceAll("\\\\", "/");

//      String directoryZip="C:/logs";
//      String fileZip="prova.zip";
//      String pathZip=directoryZip+"/"+fileZip;

      createZipFromFiles(filesToZip, pathZip, directory);

      //Vector<File> filesToZip = searchDateFiles(dir, beginDate, endDate)

      manageDownloadZipFile(httpRequest, httpResponse, directoryZip, fileZip);

      //manageDownloadExportFile(httpRequest, httpResponse);
    } catch (Throwable t) {
      logger.error("Error in writing the zip ",t);
      throw new SpagoBIServiceException(SERVICE_NAME, t.getMessage() , t);
      /* this manage defines a file with the error message and returns it.
      try{             
        File file = new File("exception.txt");
        String text = t.getMessage() + " \n" + (( t.getStackTrace()!=null)?t.getStackTrace():"");
        FileUtils.writeStringToFile(file, text, "UTF-8");
View Full Code Here

      // get sorted array
      File[] files=getSortedArray(dir, prefix);

      if (files == null){
        throw new SpagoBIServiceException(SERVICE_NAME, "Missing files in specified interval");
      }

      // cycle on all files
      boolean exceeded = false;
      for (int i = 0; i < files.length && !exceeded; i++) {
View Full Code Here

          // dispatch the request to the presentation layer
          requestDispatcher = getServletContext().getRequestDispatcher( REQUEST_DISPATCHER_URL );
            try {
              requestDispatcher.forward(servletIOManager.getRequest(), servletIOManager.getResponse());
        } catch (Throwable t) {
          throw new SpagoBIServiceException(ENGINE_NAME, "An error occurred while dispatching request to [" + REQUEST_DISPATCHER_URL + "]", t);
        }
        } catch(Throwable t) {
          logger.error("Impossible to execute document", t);
          t.printStackTrace();
          throw new SpagoBIServiceException(ENGINE_NAME, t);
        } finally {
          logger.debug("OUT");          
        }       

  }
View Full Code Here

    try {
      dsDao = DAOFactory.getDataSetDAO();
      dsDao.setUserProfile(profile);
    } catch (EMFUserError e1) {
      logger.error(e1.getMessage(), e1);
      throw new SpagoBIServiceException(SERVICE_NAME,  "Error occurred");
    }
    Locale locale = getLocale();
    String serviceType = this.getAttributeAsString(DataSetConstants.MESSAGE_DET);
    logger.debug("Service type "+serviceType);
   
View Full Code Here

      JSONObject responseJSON = createJSONResponse(itemsJSON, totalItemsNum);
      writeBackToClient(new JSONSuccess(responseJSON));

    } catch (Throwable e) {
      logger.error("Exception occurred while retrieving items", e);
      throw new SpagoBIServiceException(SERVICE_NAME, "sbi.general.retrieveItemsError", e);
    }
  }
View Full Code Here

      JSONObject responseJSON = createJSONResponse(itemsJSON, totalItemsNum);
      writeBackToClient(new JSONSuccess(responseJSON));

    } catch (Throwable e) {
      logger.error("Exception occurred while retrieving items", e);
      throw new SpagoBIServiceException(SERVICE_NAME,  "sbi.general.retrieveItemsError", e);
    }
  }
View Full Code Here

          }
          writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
        }
      } catch (Throwable e) {
        logger.error(e.getMessage(), e);
        throw new SpagoBIServiceException(SERVICE_NAME,"sbi.ds.saveDsError", e);
      }
    }else{
      logger.error("DataSet name, label or type are missing");
      throw new SpagoBIServiceException(SERVICE_NAME,  "sbi.ds.fillFieldsError");
    }
  }
View Full Code Here

      JSONObject dataSetJSON = datasetTest();
      if(dataSetJSON!=null){
        try {
          writeBackToClient( new JSONSuccess( dataSetJSON ) );
        } catch (IOException e) {
          throw new SpagoBIServiceException("Impossible to write back the responce to the client", e);
        }
      }else{
        throw new SpagoBIServiceException(SERVICE_NAME,"sbi.ds.testError");
      }
    } catch (Throwable e) {
      logger.error(e.getMessage(), e);
      throw new SpagoBIServiceException(SERVICE_NAME,"sbi.ds.testError", e);
    }
  }
View Full Code Here

      dsDao.deleteDataSet(dsID);
      logger.debug("Dataset deleted");
      writeBackToClient( new JSONAcknowledge("Operation succeded") );
    } catch (Throwable e) {
      logger.error("Exception occurred while retrieving dataset to delete", e);
      throw new SpagoBIServiceException(SERVICE_NAME,"sbi.ds.deleteDsError", e);
    }
  }
View Full Code Here

TOP

Related Classes of it.eng.spagobi.utilities.exceptions.SpagoBIServiceException

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.