Examples of EMFValidationError


Examples of it.eng.spago.validation.EMFValidationError

  FileItem uploaded = (FileItem) serviceRequest.getAttribute("UPLOADED_FILE");
    String fileName = null;
    if(uploaded!=null) {
      fileName = GeneralUtilities.getRelativeFileNames(uploaded.getName());
    if (uploaded.getSize() == 0 && ((String)serviceRequest.getAttribute("MESSAGEDET")).equals("DETAIL_INS")) {
      EMFValidationError error = new EMFValidationError(EMFErrorSeverity.ERROR, "uploadFile", "201");
      getErrorHandler().addError(error);
      return map;
    }
    int maxSize = GeneralUtilities.getTemplateMaxSize();
    if (uploaded.getSize() > maxSize && ((String)serviceRequest.getAttribute("MESSAGEDET")).equals("DETAIL_INS")) {
      EMFValidationError error = new EMFValidationError(EMFErrorSeverity.ERROR, "uploadFile", "202");
      getErrorHandler().addError(error);
      return map;
    }
    if (uploaded.getSize()  > 0){
          try {
View Full Code Here

Examples of it.eng.spago.validation.EMFValidationError

                name = samples.getString(NAME);
                if (GenericValidator.isBlankOrNull(name) ||
                    !GenericValidator.matchRegexp(name, ALPHANUMERIC_STRING_REGEXP_NOSPACE)||
                      !GenericValidator.maxLength(name, nameMaxLenght)){
                  logger.error("Either the field name is blank or it exceeds maxlength or it is not alfanumeric");
                  EMFValidationError e = new EMFValidationError(EMFErrorSeverity.ERROR, description, "9000","");
                  getHttpResponse().setStatus(404)
                  JSONObject attributesResponseSuccessJSON = new JSONObject();
                  attributesResponseSuccessJSON.put("success", false);
                  attributesResponseSuccessJSON.put("message", "Either the field name is blank or it exceeds maxlength or it is not alfanumeric");
                  attributesResponseSuccessJSON.put("data", "[]");
                 
                  writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );

                  return;
 
                }
              }
              if(!samples.isNull(DESCRIPTION)){
                description = samples.getString(DESCRIPTION);
 
                if (GenericValidator.isBlankOrNull(description) ||
                    !GenericValidator.matchRegexp(description, ALPHANUMERIC_STRING_REGEXP_NOSPACE) ||
                        !GenericValidator.maxLength(description, descriptionMaxLenght)){
                  logger.error("Either the field description is blank or it exceeds maxlength or it is not alfanumeric");
 
                  EMFValidationError e = new EMFValidationError(EMFErrorSeverity.ERROR, description, "9000","");
                  getHttpResponse().setStatus(404)
                  JSONObject attributesResponseSuccessJSON = new JSONObject();
                  attributesResponseSuccessJSON.put("success", false);
                  attributesResponseSuccessJSON.put("message", "Either the field description is blank or it exceeds maxlength or it is not alfanumeric");
                  attributesResponseSuccessJSON.put("data", "[]");
                  writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
                  return;
                }
              }
           
              SbiAttribute attribute = new SbiAttribute();
              if(description!=null){
                attribute.setDescription(description);
              }
              if(name!=null){
                attribute.setAttributeName(name);
              }
              boolean isNewAttrForRes = true;
              if(idStr!=null && !idStr.equals("")){
                Integer attributeId = new Integer(idStr);
                attribute.setAttributeId(attributeId.intValue());
                isNewAttrForRes = false;
              }
              Integer attrID = attrDao.saveOrUpdateSbiAttribute(attribute);
              logger.debug("Attribute updated");

              ArrayList<SbiAttribute> attributes = new ArrayList<SbiAttribute> ();
              attribute.setAttributeId(attrID);
              attributes.add(attribute);
             
              getAttributesListAdded(locale,attributes,isNewAttrForRes, attrID);

            }
            //else the List of attributes will be sent to the client
          }else{
            getAttributesList(locale,attrDao);
          }
        }else{
          getAttributesList(locale,attrDao);
        }

      } catch (Throwable e) {
        logger.error(e.getMessage(), e);
        getHttpResponse().setStatus(404);               
        try {
          JSONObject attributesResponseSuccessJSON = new JSONObject();
          attributesResponseSuccessJSON.put("success", true);
          attributesResponseSuccessJSON.put("message", "Exception occurred while saving attribute");
          attributesResponseSuccessJSON.put("data", "[]");
          writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) )
        } catch (IOException e1) {
          logger.error(e1.getMessage(), e1);
        } catch (JSONException e2) {
          logger.error(e2.getMessage(), e2);
        }
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception occurred while retrieving attributes", e);
      }
    } else if (serviceType != null  && serviceType.equalsIgnoreCase(ATTR_DELETE)) {
     
      String idStr = null;
      try {
        BufferedReader b =httpRequest.getReader();
        if(b!=null){
          String respJsonObject = b.readLine();
          if(respJsonObject!=null){
            JSONObject responseJSON = deserialize(respJsonObject);
            idStr = responseJSON.getString(SAMPLES);
          }
        }
       
      } catch (IOException e1) {
        logger.error("IO Exception",e1);
        e1.printStackTrace();
      } catch (SerializationException e) {
        logger.error("Deserialization Exception",e);
        e.printStackTrace();
      } catch (JSONException e) {
        logger.error("JSONException",e);
        e.printStackTrace();
      }
      if(idStr!=null && !idStr.equals("")){
        Integer id = new Integer(idStr);
        try {
          attrDao.deleteSbiAttributeById(id);
View Full Code Here

Examples of it.eng.spago.validation.EMFValidationError

          try{
          tryClass=(JavaClassDestination)Class.forName(javaClassPath).newInstance();
          }
          catch (ClassCastException e) {
            logger.error("Error in istantiating class");
            EMFValidationError emfError=new EMFValidationError(EMFErrorSeverity.ERROR, "sendtojavaclass_"+biobId+"__"+index, "12200");
            errorHandler.addError(emfError);
         
          }       
          catch (Exception e) {
            logger.error("Error in istantiating class");
            EMFValidationError emfError=new EMFValidationError(EMFErrorSeverity.ERROR, "sendtojavaclass_"+biobId+"__"+index, "12100");
            errorHandler.addError(emfError);
          }         
          sInfo.setJavaClassPath(javaClassPath);
       
       
       
        String saveasdoc = (String)request.getAttribute("saveasdocument_"+biobId+"__"+index)
        if(saveasdoc!=null) {
          sInfo.setSaveAsDocument(true);
          String docname = (String)request.getAttribute("documentname_"+biobId+"__"+index)
          sInfo.setDocumentName(docname);
          String docdescr = (String)request.getAttribute("documentdescription_"+biobId+"__"+index)
          sInfo.setDocumentDescription(docdescr);
          boolean useFixedFolder = "true".equalsIgnoreCase((String) request.getAttribute("useFixedFolder_"+biobId+"__"+index));
          sInfo.setUseFixedFolder(useFixedFolder);
          if (useFixedFolder) {
            String functIdsConcat = "";
            String tmpValReq = "tree_"+biobId+"__"+index+"_funct_id";
            List functIds = request.getAttributeAsList(tmpValReq)
            Iterator iterFunctIds = functIds.iterator();
            while(iterFunctIds.hasNext()) {
              String idFunct = (String)iterFunctIds.next();
              functIdsConcat += idFunct;
              if(iterFunctIds.hasNext()){
                functIdsConcat += ",";
              }
            }
            sInfo.setFunctionalityIds(functIdsConcat);
          }
          //gestire acquisizione folder
          boolean useFolderDataset = "true".equalsIgnoreCase((String) request.getAttribute("useFolderDataset_"+biobId+"__"+index));
          sInfo.setUseFolderDataSet(useFolderDataset);
          if (useFolderDataset) {
            String dsLabel = (String)request.getAttribute("datasetFolderLabel_"+biobId+"__"+index)
            sInfo.setDataSetFolderLabel(dsLabel);
            String datasetParameterLabel = (String)request.getAttribute("datasetFolderParameter_"+biobId+"__"+index)
            sInfo.setDataSetFolderParameterLabel(datasetParameterLabel);
            if (dsLabel == null || dsLabel.trim().equals("")) {
              BIObject biobj = DAOFactory.getBIObjectDAO().loadBIObjectById(biobId);
              List params = new ArrayList();
              params.add(biobj.getName());
              this.getErrorHandler().addError(new EMFValidationError(EMFErrorSeverity.ERROR, null, "errors.trigger.missingDataSet", params, "component_scheduler_messages"));
            }
            if (datasetParameterLabel == null || datasetParameterLabel.trim().equals("")) {
              BIObject biobj = DAOFactory.getBIObjectDAO().loadBIObjectById(biobId);
              List params = new ArrayList();
              params.add(biobj.getName());
              this.getErrorHandler().addError(new EMFValidationError(EMFErrorSeverity.ERROR, null, "errors.trigger.missingDataSetParameter", params, "component_scheduler_messages"));
            }
          //  sInfo.setFunctionalityIds(functIdsConcat);
          }
        }
        String sendmail = (String)request.getAttribute("sendmail_"+biobId+"__"+index)
        if(sendmail!=null) {
          sInfo.setSendMail(true);
          boolean useFixedRecipients = "true".equalsIgnoreCase((String) request.getAttribute("useFixedRecipients_"+biobId+"__"+index));
          sInfo.setUseFixedRecipients(useFixedRecipients);
          if (useFixedRecipients) {
            String mailtos = (String)request.getAttribute("mailtos_"+biobId+"__"+index);
            sInfo.setMailTos(mailtos);
            if (mailtos == null || mailtos.trim().equals("")) {
              BIObject biobj = DAOFactory.getBIObjectDAO().loadBIObjectById(biobId);
              List params = new ArrayList();
              params.add(biobj.getName());
              this.getErrorHandler().addError(new EMFValidationError(EMFErrorSeverity.ERROR, null, "errors.trigger.missingFixedRecipients", params, "component_scheduler_messages"));
            }
          }
          boolean useDataset = "true".equalsIgnoreCase((String) request.getAttribute("useDataset_"+biobId+"__"+index));
          sInfo.setUseDataSet(useDataset);
          if (useDataset) {
            String dsLabel = (String)request.getAttribute("datasetLabel_"+biobId+"__"+index)
            sInfo.setDataSetLabel(dsLabel);
            String datasetParameterLabel = (String)request.getAttribute("datasetParameter_"+biobId+"__"+index)
            sInfo.setDataSetParameterLabel(datasetParameterLabel);
            if (dsLabel == null || dsLabel.trim().equals("")) {
              BIObject biobj = DAOFactory.getBIObjectDAO().loadBIObjectById(biobId);
              List params = new ArrayList();
              params.add(biobj.getName());
              this.getErrorHandler().addError(new EMFValidationError(EMFErrorSeverity.ERROR, null, "errors.trigger.missingDataSet", params, "component_scheduler_messages"));
            }
            if (datasetParameterLabel == null || datasetParameterLabel.trim().equals("")) {
              BIObject biobj = DAOFactory.getBIObjectDAO().loadBIObjectById(biobId);
              List params = new ArrayList();
              params.add(biobj.getName());
              this.getErrorHandler().addError(new EMFValidationError(EMFErrorSeverity.ERROR, null, "errors.trigger.missingDataSetParameter", params, "component_scheduler_messages"));
            }
          }
          boolean useExpression = "true".equalsIgnoreCase((String) request.getAttribute("useExpression_"+biobId+"__"+index));
          sInfo.setUseExpression(useExpression);
          if (useExpression) {
            String expression = (String)request.getAttribute("expression_"+biobId+"__"+index)
            sInfo.setExpression(expression);
            if (expression == null || expression.trim().equals("")) {
              BIObject biobj = DAOFactory.getBIObjectDAO().loadBIObjectById(biobId);
              List params = new ArrayList();
              params.add(biobj.getName());
              this.getErrorHandler().addError(new EMFValidationError(EMFErrorSeverity.ERROR, null, "errors.trigger.missingExpression", params, "component_scheduler_messages"));
            }
          }
         
          if (!useFixedRecipients && !useDataset && !useExpression) {
            BIObject biobj = DAOFactory.getBIObjectDAO().loadBIObjectById(biobId);
            List params = new ArrayList();
            params.add(biobj.getName());
            this.getErrorHandler().addError(new EMFValidationError(EMFErrorSeverity.ERROR, null, "errors.trigger.missingRecipients", params, "component_scheduler_messages"))
          }
         
          String mailsubj = (String)request.getAttribute("mailsubj_"+biobId+"__"+index)
          sInfo.setMailSubj(mailsubj);
          String mailtxt = (String)request.getAttribute("mailtxt_"+biobId+"__"+index)
View Full Code Here

Examples of it.eng.spago.validation.EMFValidationError

      Engine en = (Engine) i.next();
      if (en.getLabel().equals(label) && !en.getId().equals(id)) {
        HashMap params = new HashMap();
        params.put(AdmintoolsConstants.PAGE,
            ListEnginesModule.MODULE_PAGE);
        EMFValidationError error = new EMFValidationError(EMFErrorSeverity.ERROR, "label",
            "1011", new Vector(), params);
        getErrorHandler().addError(error);
      }
    }
       
View Full Code Here

Examples of it.eng.spago.validation.EMFValidationError

            // the lov type was changed
            HashMap errparams = new HashMap();
            errparams.put(AdmintoolsConstants.PAGE, "DetailModalitiesValuePage");
            List params = new ArrayList();
            params.add(documents.toString());
            EMFValidationError error = new EMFValidationError(EMFErrorSeverity.ERROR, "input_type", "1058", params, errparams);
            errorHandler.addError(error);
            prepareDetailModalitiesValuePage(modVal, mod, response);
            return;
          } else {
            // the lov type was not changed, must verify that the dependency columns are still present
            // load all the columns returned by the lov
            String queryDetXML = modVal.getLovProvider();
            ILovDetail lovProvDet = LovDetailFactory.getLovFromXML(queryDetXML);
            List visColumns = lovProvDet.getVisibleColumnNames();
            List invisColumns = lovProvDet.getInvisibleColumnNames();
            List columns = new ArrayList();
            if( (visColumns!=null) && (visColumns.size()!=0) )
              columns.addAll(visColumns);
            if( (invisColumns!=null) && (invisColumns.size()!=0) )
              columns.addAll(invisColumns);
            // for each correlation column name chechs if the column is still present
            Iterator correlationsIt = correlations.iterator();
            boolean columnNoMorePresent = false;
            List columnsNoMorePresent = new ArrayList();
            while (correlationsIt.hasNext()) {
              ObjParuse aObjParuse = (ObjParuse) correlationsIt.next();
              String filterColumn = aObjParuse.getFilterColumn();
              // because spago put all sourcebean attribute to Uppercase
              //filterColumn = filterColumn.toUpperCase();
              if (!columns.contains(filterColumn)) {
                columnNoMorePresent = true;
                columnsNoMorePresent.add(filterColumn);
              }
            }
            // if there are some column no more present then generate an error and return to the detail page
            if (columnNoMorePresent) {
              HashMap errparams = new HashMap();
              errparams.put(AdmintoolsConstants.PAGE, "DetailModalitiesValuePage");
              List params = new ArrayList();
              params.add(documents.toString());
              params.add(columnsNoMorePresent.toString());
              EMFValidationError error = new EMFValidationError(EMFErrorSeverity.ERROR, 1059, params, errparams);
              errorHandler.addError(error);
              prepareDetailModalitiesValuePage(modVal, mod, response);
              return;
            }
          }
View Full Code Here

Examples of it.eng.spago.validation.EMFValidationError

        String valueLabel = value.getLabel();
        if (valueLabel.equals(label)) {
          HashMap params = new HashMap();
          params.put(AdmintoolsConstants.PAGE,
              ListLovsModule.MODULE_PAGE);
          EMFValidationError error = new EMFValidationError(EMFErrorSeverity.ERROR, "label", "1024",
              new Vector(), params);
          errorHandler.addError(error);
        }
      }
    } else {
      String currentId = (String) request.getAttribute("id");
      Iterator i = allModVal.iterator();
      while (i.hasNext()) {
        ModalitiesValue value = (ModalitiesValue) i.next();
        String valueLabel = value.getLabel();
        String valueId = value.getId().toString();
        if (valueLabel.equals(label)
            && (!currentId.equalsIgnoreCase(valueId))) {
          HashMap params = new HashMap();
          params.put(AdmintoolsConstants.PAGE,
              ListLovsModule.MODULE_PAGE);
          EMFValidationError error = new EMFValidationError(EMFErrorSeverity.ERROR, "label", "1024",
              new Vector(), params);
          errorHandler.addError(error);
        }
      }
    }
View Full Code Here

Examples of it.eng.spago.validation.EMFValidationError

        jsonObject = createResponseContent(internalError);
      }
    } else if (error instanceof EMFUserError) {
      EMFUserError userError = (EMFUserError) error;
      if (userError instanceof EMFValidationError) {
        EMFValidationError validationError = (EMFValidationError) error;
        jsonObject = createResponseContent(validationError);
      } else {
        jsonObject = createResponseContent(userError);
      }
    } else {
View Full Code Here

Examples of it.eng.spago.validation.EMFValidationError

  logger.debug("IN");
  IExportManager expManager = null;
  String exportFileName = (String) request.getAttribute("exportFileName");
  if ((exportFileName == null) || (exportFileName.trim().equals(""))) {
      logger.error("Missing name of the exported file");
      throw new EMFValidationError(EMFErrorSeverity.ERROR, "exportFileName", "8006", "component_impexp_messages");

  }
  try {
      String exportSubObject = (String) request.getAttribute("exportSubObj");
      boolean expSubObj = false;
View Full Code Here

Examples of it.eng.spago.validation.EMFValidationError

    //String archiveName = archive.getFileName();
    String archiveName = GeneralUtilities.getRelativeFileNames(archive.getName());
    if (archiveName.trim().equals("")) {
        logger.error("Missing exported file");
      response.setAttribute(ImportExportConstants.PUBLISHER_NAME, "ImportExportLoopbackStopImport");
        throw new EMFValidationError(EMFErrorSeverity.ERROR, "exportedArchive", "8007", "component_impexp_messages");
    }
   
    int maxSize = ImportUtilities.getImportFileMaxSize();
    if (archive.getSize() > maxSize) {
        logger.error("File is too large!!!");
      response.setAttribute(ImportExportConstants.PUBLISHER_NAME, "ImportExportLoopbackStopImport");
        throw new EMFValidationError(EMFErrorSeverity.ERROR, "exportedArchive", "202");
    }
   
    // checks if the association file is bigger than 1 MB, that is more than enough!!
    if (associationsFileItem != null) {
      if (associationsFileItem.getSize() > 1048576) {
        throw new EMFValidationError(EMFErrorSeverity.ERROR, "associationsFile", "202");
      }
      // loads association file
      associationsFile = new UploadedFile();
      associationsFile.setFileContent(associationsFileItem.get());
      associationsFile.setFieldNameInForm(associationsFileItem.getFieldName());
      associationsFile.setSizeInBytes(associationsFileItem.getSize());
      associationsFile.setFileName(GeneralUtilities.getRelativeFileNames(associationsFileItem.getName()));
    }
   
    // if the user choose to have no associations, checks the form, otherwise set the variable associationsFile = null
    if (!isNoAssociationModality) {
      // check if the name of associations file is empty (in this case set
      // null to the variable)
      if (associationsFile != null) {
        String associationsFileName = associationsFile.getFileName();
        if (associationsFileName.trim().equals("")) {
            associationsFile = null;
        }
      }
      // if the association file is empty then check if there is an
      // association id
      // rebuild the uploaded file and assign it to associationsFile variable
      if (associationsFile == null) {
          String assId = (String) request.getAttribute("hidAssId");
          if ((assId != null) && !assId.trim().equals("")) {
        IAssociationFileDAO assfiledao = new AssociationFileDAO();
        assFile = assfiledao.loadFromID(assId);
        byte[] content = assfiledao.getContent(assFile);
        UploadedFile uplFile = new UploadedFile();
        uplFile.setSizeInBytes(content.length);
        uplFile.setFileContent(content);
        uplFile.setFileName("association.xml");
        uplFile.setFieldNameInForm("");
        associationsFile = uplFile;
          }
      }
    } else {
      associationsFile = null;
    }
   
    // get the association mode
    String assMode = IImportManager.IMPORT_ASS_DEFAULT_MODE;
    if (assKindFromReq.equalsIgnoreCase("predefinedassociations")) {
        assMode = IImportManager.IMPORT_ASS_PREDEFINED_MODE;
    }
    // get bytes of the archive
    byte[] archiveBytes = archive.get();
 
      // get path of the import tmp directory
      String pathImpTmpFolder = ImportUtilities.getImportTempFolderPath();
    
      // apply transformation
      TransformManager transManager = new TransformManager();
      archiveBytes = transManager.applyTransformations(archiveBytes, archiveName, pathImpTmpFolder);

      impManager = ImportUtilities.getImportManagerInstance();
      // prepare import environment
      impManager.init(pathImpTmpFolder, archiveName, archiveBytes);
      impManager.openSession();
      impManager.setAssociationFile(assFile);
     
    // if the associations file has been uploaded fill the association keeper
    if(associationsFile!=null) {
      byte[] assFilebys = associationsFile.getFileContent();
      String assFileStr = new String(assFilebys);
      try {
        impManager.getUserAssociation().fillFromXml(assFileStr);
      } catch (Exception e) {
        logger.error("Error while loading association file content:\n " + e);
        response.setAttribute(ImportExportConstants.PUBLISHER_NAME, "ImportExportLoopbackStopImport");
        throw new EMFValidationError(EMFErrorSeverity.ERROR, "exportedArchive", "8009", "component_impexp_messages");
      }
    }

      // set into import manager the association import mode
      impManager.setImpAssMode(assMode);
View Full Code Here

Examples of it.eng.spago.validation.EMFValidationError

   *
   * @param objParFatherId The id of the BIObjectParameter object to check
   * @throws EMFUserError
   */
  public static EMFValidationError checkForDependancies(Integer objParFatherId) throws EMFUserError {
    EMFValidationError error = null;
    IObjParuseDAO objParuseDAO = DAOFactory.getObjParuseDAO();
    List objParametersCorrelated = objParuseDAO.getDependencies(objParFatherId);
    if (objParametersCorrelated != null && objParametersCorrelated.size() > 0) {
      HashMap params = new HashMap();
      params.put(AdmintoolsConstants.PAGE,
          DetailBIObjectModule.MODULE_PAGE);
      Vector v = new Vector();
      v.add(objParametersCorrelated.toString());
      error = new EMFValidationError(EMFErrorSeverity.ERROR, 1049, v, params);
    }
    return error;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.