Example #1
0
 private boolean equalsMaterialCategory(MaterialCategory obj1, MaterialCategory obj2) {
     String name1 = StringUtils.deleteWhitespace(obj1.getName()
             .toLowerCase());
     String name2 = StringUtils.deleteWhitespace(obj2.getName()
             .toLowerCase());
     return name1.equals(name2);
 }
Example #2
0
  /** @see de.willuhn.jameica.gui.input.TextInput#setValue(java.lang.Object) */
  @Override
  public void setValue(Object value) {
    super.setValue(value);

    if (value == null) return;

    // Formatierungsleerzeichen zum Testen entfernen
    String s = StringUtils.trimToNull(StringUtils.deleteWhitespace(value.toString()));
    if (s == null) return;

    try {
      // 1. IBAN sofort checken
      IBAN iban = HBCIProperties.getIBAN(s);

      if (iban == null) // Keine IBAN
      return;

      if (this.bicInput == null) return;

      // 2. Wenn wir ein BICInput haben, dann gleich noch die BIC ermitteln und
      // vervollstaendigen
      String bic = StringUtils.trimToNull(iban.getBIC());
      if (bic == null) return;

      this.bicInput.setValue(bic);
    } catch (ApplicationException ae) {
      Application.getMessagingFactory()
          .sendMessage(new StatusBarMessage(ae.getMessage(), StatusBarMessage.TYPE_ERROR));
    }
  }
  public static Fqn<String> constructJcrQueryFQN(String jcrQuery, CacheRegion cacheRegion) {

    // replace all '/'  and spaces with empty string
    String jcrQueryWithoutForwardSlashes = StringUtils.remove(jcrQuery, CmsConstants.FORWARD_SLASH);

    if (cacheRegion == null) {
      cacheRegion = CmsCriteria.DEFAULT_CACHE_REGION;
    }

    // Create  Cache Region FQN
    Fqn<String> cacheRegionFqn =
        Fqn.fromRelativeElements(JCR_QUERY_NODE_FQN, cacheRegion.getRegionName());

    // Create FQN for authentication token
    String authenticationToken = AstroboaClientContextHolder.getActiveAuthenticationToken();

    if (authenticationToken == null) {
      throw new CmsException(
          "No active authenticationToken found. Could not construct appropriate FQN for query "
              + jcrQuery);
    }

    Fqn<String> autheticationTokenFqn =
        Fqn.fromRelativeElements(cacheRegionFqn, authenticationToken);

    return Fqn.fromRelativeElements(
        autheticationTokenFqn, StringUtils.deleteWhitespace(jcrQueryWithoutForwardSlashes));
  }
Example #4
0
  /**
   * Ueberschrieben, um sicherzustellen, dass die IBAN keine Leerzeichen enthaelt.
   *
   * @see de.willuhn.jameica.gui.input.TextInput#getValue()
   */
  @Override
  public Object getValue() {
    String s = (String) super.getValue();
    if (s == null) return s;

    return StringUtils.deleteWhitespace(s);
  }
  @Override
  public void initialize(List<Parameter> parameterList) throws WorkflowImplException {

    if (!validateParams(parameterList)) {
      throw new WorkflowRuntimeException(
          "Workflow initialization failed, required parameter is missing");
    }

    Parameter wfNameParameter =
        WorkflowManagementUtil.getParameter(
            parameterList,
            WFConstant.ParameterName.WORKFLOW_NAME,
            WFConstant.ParameterHolder.WORKFLOW_IMPL);

    if (wfNameParameter != null) {
      processName = StringUtils.deleteWhitespace(wfNameParameter.getParamValue());
      role =
          WorkflowManagementUtil.createWorkflowRoleName(
              StringUtils.deleteWhitespace(wfNameParameter.getParamValue()));
    }

    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
    if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
      tenantContext = "t/" + tenantDomain + "/";
    }

    Parameter bpsProfileParameter =
        WorkflowManagementUtil.getParameter(
            parameterList,
            WFImplConstant.ParameterName.BPS_PROFILE,
            WFConstant.ParameterHolder.WORKFLOW_IMPL);
    if (bpsProfileParameter != null) {
      String bpsProfileName = bpsProfileParameter.getParamValue();
      bpsProfile =
          WorkflowImplServiceDataHolder.getInstance()
              .getWorkflowImplService()
              .getBPSProfile(bpsProfileName, tenantId);
    }
    htName = processName + BPELDeployer.Constants.HT_SUFFIX;

    generateAndDeployArtifacts();
  }
 @Override
 public void removeWorkflow(String workflowId) throws WorkflowException {
   Workflow workflow = workflowDAO.getWorkflow(workflowId);
   // Deleting the role that is created for per workflow
   if (workflow != null) {
     WorkflowManagementUtil.deleteWorkflowRole(
         StringUtils.deleteWhitespace(workflow.getWorkflowName()));
     workflowDAO.removeWorkflowParams(workflowId);
     workflowDAO.removeWorkflow(workflowId);
   }
 }
Example #7
0
 /**
  * Translates a comp system name (from e.g. an action or a parameter) to how it shall be used in
  * api
  *
  * @param name original name
  * @return the name which should be used in api
  */
 public String translateFromCompSystem(String name) {
   String desiredName = CompSystemI18n.getString(name);
   desiredName =
       desiredName
           .replace(StringConstants.MINUS, StringConstants.SPACE)
           .replace(StringConstants.LEFT_PARENTHESES, StringConstants.SPACE)
           .replace(StringConstants.RIGHT_PARENTHESES, StringConstants.SPACE)
           .replace(StringConstants.SLASH, StringConstants.SPACE);
   desiredName = WordUtils.capitalize(desiredName);
   desiredName = StringUtils.deleteWhitespace(desiredName);
   desiredName = WordUtils.uncapitalize(desiredName);
   return desiredName;
 }
Example #8
0
 @Test
 public void testBase64Long() throws Exception {
   // This one has spaces in it
   byte[] bytes = Base64.decode(longMsg);
   assertNotNull(bytes);
   byte[] encBytes = Base64.encode(bytes, false);
   String str1 = new String(encBytes);
   String str2 = new String(longMsg);
   // Should not be same, str2 has blanks in it
   assertFalse(str1 == str2);
   str2 = StringUtils.deleteWhitespace(str2);
   // now it should be same
   assertEquals(str1, str2);
 }
Example #9
0
 /**
  * Translates a component name from the comp system to how it shall be used in the api
  *
  * @param name the class name in comp system
  * @return the name of the class in the api
  */
 public String getClassName(String name) {
   String desiredName = CompSystemI18n.getString(name);
   desiredName = desiredName.replace(StringConstants.SLASH, StringConstants.SPACE);
   if (desiredName.startsWith(StringConstants.LEFT_PARENTHESES)) {
     desiredName = StringUtils.substringAfter(desiredName, StringConstants.RIGHT_PARENTHESES);
   }
   desiredName =
       desiredName
           .replace(StringConstants.LEFT_PARENTHESES, StringConstants.SPACE)
           .replace(StringConstants.RIGHT_PARENTHESES, StringConstants.SPACE);
   desiredName = WordUtils.capitalize(desiredName);
   desiredName = StringUtils.deleteWhitespace(desiredName);
   return desiredName;
 }
Example #10
0
  protected void service(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String fileName = "";

    try {
      fileName = StringUtils.substringAfterLast(request.getRequestURI(), "/");

      File file = new File(imageDirectory + fileName);
      if (!file.exists()) {
        file = new File(imageTempDirectory + fileName);
      }
      if (!file.exists()) {
        fileName = request.getParameter("fileName");

        // report file delivery validates the filename against the username
        // of the user in session for security purposes.
        ReportUser user = (ReportUser) request.getSession().getAttribute(ORStatics.REPORT_USER);
        if (user == null || fileName.indexOf(user.getName()) < 0) {
          String message = "Not Authorized...";
          response.getOutputStream().write(message.getBytes());

          return;
        }

        file = new File(reportGenerationDirectory + fileName);
      }

      String contentType = ORUtil.getContentType(fileName);

      response.setContentType(contentType);
      if (contentType != ReportEngineOutput.CONTENT_TYPE_HTML) {
        response.setHeader(
            "Content-disposition", "inline; filename=" + StringUtils.deleteWhitespace(fileName));
      }

      byte[] content = FileUtils.readFileToByteArray(file);

      response.setContentLength(content.length);

      ServletOutputStream ouputStream = response.getOutputStream();
      ouputStream.write(content, 0, content.length);
      ouputStream.flush();
      ouputStream.close();
    } catch (Exception e) {
      log.warn(e);

      String message = "Error Loading File...";
      response.getOutputStream().write(message.getBytes());
    }
  }
  /**
   * @see org.kuali.kfs.sys.batch.BatchInputFileType#getFileName(java.lang.String, java.lang.Object,
   *     java.lang.String)
   */
  @Override
  public String getFileName(
      String principalName, Object parsedFileContents, String fileUserIdentifier) {
    StringBuilder fileName = new StringBuilder();

    fileUserIdentifier = StringUtils.deleteWhitespace(fileUserIdentifier);
    fileUserIdentifier =
        StringUtils.remove(fileUserIdentifier, TemConstants.FILE_NAME_PART_DELIMITER);

    fileName.append(this.getFileNamePrefix()).append(TemConstants.FILE_NAME_PART_DELIMITER);
    fileName.append(principalName).append(TemConstants.FILE_NAME_PART_DELIMITER);
    fileName.append(fileUserIdentifier).append(TemConstants.FILE_NAME_PART_DELIMITER);

    fileName.append(dateTimeService.toDateTimeStringForFilename(dateTimeService.getCurrentDate()));

    return fileName.toString();
  }
  @Override
  public void addWorkflow(Workflow workflow, List<Parameter> parameterList, int tenantId)
      throws WorkflowException {

    // TODO:Workspace Name may contain spaces , so we need to remove spaces and prepare process for
    // that
    Parameter workflowNameParameter =
        new Parameter(
            workflow.getWorkflowId(),
            WFConstant.ParameterName.WORKFLOW_NAME,
            workflow.getWorkflowName(),
            WFConstant.ParameterName.WORKFLOW_NAME,
            WFConstant.ParameterHolder.WORKFLOW_IMPL);

    if (!parameterList.contains(workflowNameParameter)) {
      parameterList.add(workflowNameParameter);
    } else {
      workflowNameParameter = parameterList.get(parameterList.indexOf(workflowNameParameter));
    }
    if (!workflowNameParameter.getParamValue().equals(workflow.getWorkflowName())) {
      workflowNameParameter.setParamValue(workflow.getWorkflowName());
      // TODO:Since the user has changed the workflow name, we have to undeploy bpel package that is
      // already
      // deployed using previous workflow name.
    }

    AbstractWorkflow abstractWorkflow =
        WorkflowServiceDataHolder.getInstance()
            .getWorkflowImpls()
            .get(workflow.getTemplateId())
            .get(workflow.getWorkflowImplId());
    // deploying the template
    abstractWorkflow.deploy(parameterList);

    // add workflow to the database
    if (workflowDAO.getWorkflow(workflow.getWorkflowId()) == null) {
      workflowDAO.addWorkflow(workflow, tenantId);
      WorkflowManagementUtil.createAppRole(
          StringUtils.deleteWhitespace(workflow.getWorkflowName()));
    } else {
      workflowDAO.removeWorkflowParams(workflow.getWorkflowId());
      workflowDAO.updateWorkflow(workflow);
    }
    workflowDAO.addWorkflowParams(parameterList, workflow.getWorkflowId());
  }
  public void xxxtestMapsToXml() throws Exception {
    // This is the structure our app data currently takes
    Map<String, Map<String, String>> map = Maps.newTreeMap();
    Map<String, String> item1Map = ImmutableMap.of("value", "1");
    map.put("item1", item1Map);

    Map<String, String> item2Map = ImmutableMap.of("value", "2");
    map.put("item2", item2Map);

    String xml = beanXmlConverter.convertToXml(map);

    // TODO: Change this test to use parsing once we have the right format
    XmlUtil.parse(xml);

    // TODO: I don't believe this is the output we are looking for for app
    // data... we will probably have to tweak this.
    String expectedXml =
        "<treemap>"
            + "<empty>false</empty>"
            + "<entry>"
            + "<key>item1</key>"
            + "<value>"
            + "<empty>false</empty>"
            + "<entry>"
            + "<key>value</key>"
            + "<value>1</value>"
            + "</entry>"
            + "</value>"
            + "</entry>"
            + "<entry>"
            + "<key>item2</key>"
            + "<value>"
            + "<empty>false</empty>"
            + "<entry>"
            + "<key>value</key>"
            + "<value>2</value>"
            + "</entry>"
            + "</value>"
            + "</entry>"
            + "</treemap>";
    assertEquals(expectedXml, StringUtils.deleteWhitespace(xml));
  }
 public static TimeValue parseTimeValue(String sValue) {
   try {
     long millis;
     sValue = org.apache.commons.lang.StringUtils.deleteWhitespace(sValue);
     if (sValue.endsWith("S")) {
       millis = Long.parseLong(sValue.substring(0, sValue.length() - 1));
     } else if (sValue.endsWith("ms")) {
       millis = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - "ms".length())));
     } else if (sValue.endsWith("s")) {
       millis = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 1)) * 1000);
     } else if (sValue.endsWith("m")) {
       millis = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 1)) * 60 * 1000);
     } else if (sValue.endsWith("H") || sValue.endsWith("h")) {
       millis =
           (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 1)) * 60 * 60 * 1000);
     } else if (sValue.endsWith("d")) {
       millis =
           (long)
               (Double.parseDouble(sValue.substring(0, sValue.length() - 1))
                   * 24
                   * 60
                   * 60
                   * 1000);
     } else if (sValue.endsWith("w")) {
       millis =
           (long)
               (Double.parseDouble(sValue.substring(0, sValue.length() - 1))
                   * 7
                   * 24
                   * 60
                   * 60
                   * 1000);
     } else {
       millis = Long.parseLong(sValue);
     }
     return new TimeValue(millis, TimeUnit.MILLISECONDS);
   } catch (NumberFormatException e) {
     throw new IllegalArgumentException("Failed to parse [" + sValue + "]", e);
   }
 }
  public Set<Method> getAnnotatedMethods(Class customClass) {
    Set<Method> annotatedMethods = new HashSet<Method>();

    List<Method> methods = customClass.getMethods();
    for (Method method : methods) {
      List<String> comments = method.getComments();
      if (comments != null && comments.size() > 0) {
        for (String comment : comments) {
          String[] lines = comment.split("[\\r\\n]+");
          for (String line : lines) {
            String deleteWhitespace = StringUtils.deleteWhitespace(line);
            if (StringUtils.endsWith(deleteWhitespace, MODEL_ANNOTATION)) {
              String difference = StringUtils.removeEnd(deleteWhitespace, MODEL_ANNOTATION);
              if (StringUtils.containsOnly(difference, VALID_PREFIX_CHARACTERS)
                  || difference.isEmpty()) {
                annotatedMethods.add(method);
              }
            }
          }
        }
      }
    }
    return annotatedMethods;
  }
  @Test
  public void shouldEvaluateOBRORUR01TemplateForOBSGroup() throws Exception {
    // given
    Encounter encounter = new Encounter();

    Date date = new Date();
    encounter.setEncounterDatetime(date);
    encounter.setUuid("ENCOUNTER UUID");

    EncounterType encounterType = new EncounterType();
    encounterType.setName("ENCOUNTER TYPE NAME");
    encounter.setEncounterType(encounterType);

    Location location = new Location(1);
    location.setUuid("LOCATION UUID");
    location.setName("LOCATION NAME");
    encounter.setLocation(location);

    Person provider = new Person(1);
    provider.setUuid("PROVIDER UUID");
    provider.addName(
        new PersonName("PROVIDER GIVENNAME", "PROVIDER MIDDLENAME", "PROVIDER FAMILYNAME"));
    encounter.setProvider(provider);

    ConceptSource source = new ConceptSource();
    source.setName("AMPATH");

    ConceptMap map = new ConceptMap();
    map.setSourceCode("200");
    map.setSource(source);

    ConceptDatatype datatype = new ConceptDatatype();
    datatype.setUuid(ConceptDatatype.NUMERIC_UUID);
    datatype.setHl7Abbreviation(ConceptDatatype.NUMERIC);

    ConceptNumeric concept = new ConceptNumeric();
    concept.setDatatype(datatype);
    concept.addConceptMapping(map);
    concept.addName(new ConceptName("NumericConcept", Locale.ENGLISH));
    concept.setUnits("mg");

    Date dateCreated = new Date(213231421890234L);

    Obs obs = new Obs(2);
    obs.setConcept(concept);
    obs.setDateCreated(dateCreated);
    obs.setValueNumeric(10d);

    obs.setObsGroup(getObsGroup());
    obs.getObsGroup().addGroupMember(obs);

    encounter.addObs(obs);

    obs = new Obs(3);
    obs.setConcept(concept);
    obs.setDateCreated(dateCreated);
    obs.setValueNumeric(23d);
    encounter.addObs(obs);

    Map<String, Object> bindings = new HashMap<String, Object>();
    bindings.put("encounter", encounter);
    bindings.put("implementationId", "MVP");

    // when
    HL7Template hl7Template = hl7QueryService.getHL7TemplateByName("Generic Obs Group");
    String evaluatedTemplate = hl7QueryService.evaluateTemplate(hl7Template, bindings);

    // then
    evaluatedTemplate = StringUtils.deleteWhitespace(evaluatedTemplate);
    Assert.assertEquals(
        "<ORU_R01.ORDER_OBSERVATION><OBR><OBR.1>0</OBR.1><OBR.4><CE.1>100</CE.1>"
            + "<CE.2>MEDICALRECORDOBSERVATIONS</CE.2><CE.3>LOCAL</CE.3></OBR.4><OBR.18>0</OBR.18>"
            + "<OBR.29><EIP.2><EI.3>ENCOUNTERUUID</EI.3></EIP.2></OBR.29></OBR><ORU_R01.OBSERVATION>"
            + "<OBX><OBX.1>1</OBX.1><OBX.2>NM</OBX.2><OBX.3><CE.1>200</CE.1><CE.2>NumericConcept</CE.2>"
            + "<CE.3>AMPATH</CE.3></OBX.3><OBX.5>23.0</OBX.5><OBX.6><CE.1>mg</CE.1><CE.3>UCUM</CE.3></OBX.6>"
            + "<OBX.14><TS.1>"
            + new HL7TemplateFunctions().formatDate(dateCreated, null)
            + "</TS.1>"
            + "</OBX.14></OBX></ORU_R01.OBSERVATION></ORU_R01.ORDER_OBSERVATION>"
            + "<ORU_R01.ORDER_OBSERVATION><OBR><OBR.1>2</OBR.1><OBR.4><CE.1>100</CE.1><CE.2>MedSet</CE.2>"
            + "<CE.3>LOCAL</CE.3></OBR.4><OBR.18>0</OBR.18><OBR.29><EIP.2><EI.3>ENCOUNTERUUID</EI.3></EIP.2></OBR.29"
            + "></OBR><ORU_R01.OBSERVATION><OBX><OBX.1>2</OBX.1><OBX.2>NM</OBX.2><OBX.3><CE.1>200</CE.1>"
            + "<CE.2>NumericConcept</CE.2><CE.3>AMPATH</CE.3></OBX.3><OBX.5>10.0</OBX.5><OBX.6><CE.1>mg</CE.1>"
            + "<CE.3>UCUM</CE.3></OBX.6><OBX.14><TS.1>"
            + new HL7TemplateFunctions().formatDate(dateCreated, null)
            + "</TS.1></OBX.14></OBX></ORU_R01.OBSERVATION></ORU_R01.ORDER_OBSERVATION>",
        evaluatedTemplate);
  }
Example #17
0
        @Override
        public void textEdited(
            User user, SPath filePath, int offset, String replacedText, String text) {
          /*
           * delete whitespaces from the text because we don't want to count
           * them. that would result in quite a number of counted characters
           * the user actually hasn't written, e.g. when eclipse automatically
           * starts lines with tabs or spaces
           */
          int textLength = StringUtils.deleteWhitespace(text).length();

          EditEvent event = new EditEvent(System.currentTimeMillis(), textLength);

          /*
           * if the edit activity text length exceeds the threshold for
           * possible pastes store this as a possible paste and file it for
           * the user who made that possible paste. Moreover, store the number
           * of characters that were "pasted" or auto generated.
           */
          if (textLength > pasteThreshold) {
            Integer currentPasteCount = pastes.get(user);
            if (currentPasteCount == null) {
              currentPasteCount = 0;
            }
            pastes.put(user, currentPasteCount + 1);

            Integer currentPasteChars = pastesCharCount.get(user);
            if (currentPasteChars == null) {
              currentPasteChars = 0;
            }
            pastesCharCount.put(user, currentPasteChars + textLength);
          }

          if (log.isTraceEnabled()) {
            log.trace(
                String.format(
                    "Received chars written from %s " + "(whitespaces omitted): %s [%s]",
                    user, textLength, StringEscapeUtils.escapeJava(text)));
          }

          if (textLength > 0) {
            if (user.isLocal()) {
              /*
               * accumulate the written chars of the local user and store
               * the time and text length of this Activity
               */
              addToCharsWritten(textLength);
              localEvents.add(event);
            } else {
              /*
               * store all remote text edits for future comparison. As
               * those text edits are remote it needs to be determined,
               * who made the edit and to increase the appropriate edited
               * character count. The total text edit count is increased
               * by one for each TextEditActivity received.
               */
              remoteEvents.add(event);
              Integer currentCharCount = remoteCharCount.get(user);
              if (currentCharCount == null) {
                currentCharCount = 0;
              }
              remoteCharCount.put(user, currentCharCount + textLength);
            }
          }
        }
  @Override
  public void configure(Context context) {
    if (!isLocal) {
      if (StringUtils.isNotBlank(context.getString(HOSTNAMES))) {
        serverAddresses = StringUtils.deleteWhitespace(context.getString(HOSTNAMES)).split(",");
      }
      Preconditions.checkState(
          serverAddresses != null && serverAddresses.length > 0, "Missing Param:" + HOSTNAMES);
    }

    if (StringUtils.isNotBlank(context.getString(INDEX_NAME))) {
      this.indexName = context.getString(INDEX_NAME);
    }

    if (StringUtils.isNotBlank(context.getString(INDEX_TYPE))) {
      this.indexType = context.getString(INDEX_TYPE);
    }

    if (StringUtils.isNotBlank(context.getString(CLUSTER_NAME))) {
      this.clusterName = context.getString(CLUSTER_NAME);
    }

    if (StringUtils.isNotBlank(context.getString(BATCH_SIZE))) {
      this.batchSize = Integer.parseInt(context.getString(BATCH_SIZE));
    }

    if (StringUtils.isNotBlank(context.getString(TTL))) {
      this.ttlMs = parseTTL(context.getString(TTL));
      Preconditions.checkState(ttlMs > 0, TTL + " must be greater than 0 or not set.");
    }

    if (StringUtils.isNotBlank(context.getString(CLIENT_TYPE))) {
      clientType = context.getString(CLIENT_TYPE);
    }

    elasticSearchClientContext = new Context();
    elasticSearchClientContext.putAll(context.getSubProperties(CLIENT_PREFIX));

    String serializerClazz = DEFAULT_SERIALIZER_CLASS;
    if (StringUtils.isNotBlank(context.getString(SERIALIZER))) {
      serializerClazz = context.getString(SERIALIZER);
    }

    Context serializerContext = new Context();
    serializerContext.putAll(context.getSubProperties(SERIALIZER_PREFIX));

    try {
      @SuppressWarnings("unchecked")
      Class<? extends Configurable> clazz =
          (Class<? extends Configurable>) Class.forName(serializerClazz);
      Configurable serializer = clazz.newInstance();

      if (serializer instanceof ElasticSearchIndexRequestBuilderFactory) {
        indexRequestFactory = (ElasticSearchIndexRequestBuilderFactory) serializer;
        indexRequestFactory.configure(serializerContext);
      } else if (serializer instanceof ElasticSearchEventSerializer) {
        eventSerializer = (ElasticSearchEventSerializer) serializer;
        eventSerializer.configure(serializerContext);
      } else {
        throw new IllegalArgumentException(
            serializerClazz + " is not an ElasticSearchEventSerializer");
      }
    } catch (Exception e) {
      logger.error("Could not instantiate event serializer.", e);
      Throwables.propagate(e);
    }

    if (sinkCounter == null) {
      sinkCounter = new SinkCounter(getName());
    }

    String indexNameBuilderClass = DEFAULT_INDEX_NAME_BUILDER_CLASS;
    if (StringUtils.isNotBlank(context.getString(INDEX_NAME_BUILDER))) {
      indexNameBuilderClass = context.getString(INDEX_NAME_BUILDER);
    }

    Context indexnameBuilderContext = new Context();
    indexnameBuilderContext.putAll(context.getSubProperties(INDEX_NAME_BUILDER_PREFIX));

    try {
      @SuppressWarnings("unchecked")
      Class<? extends IndexNameBuilder> clazz =
          (Class<? extends IndexNameBuilder>) Class.forName(indexNameBuilderClass);
      indexNameBuilder = clazz.newInstance();
      indexnameBuilderContext.put(INDEX_NAME, indexName);
      indexNameBuilder.configure(indexnameBuilderContext);
    } catch (Exception e) {
      logger.error("Could not instantiate index name builder.", e);
      Throwables.propagate(e);
    }

    if (sinkCounter == null) {
      sinkCounter = new SinkCounter(getName());
    }

    Preconditions.checkState(StringUtils.isNotBlank(indexName), "Missing Param:" + INDEX_NAME);
    Preconditions.checkState(StringUtils.isNotBlank(indexType), "Missing Param:" + INDEX_TYPE);
    Preconditions.checkState(StringUtils.isNotBlank(clusterName), "Missing Param:" + CLUSTER_NAME);
    Preconditions.checkState(batchSize >= 1, BATCH_SIZE + " must be greater than 0");
  }
 @Override
 public String getCookieName() {
   return StringUtils.deleteWhitespace(getBaseSiteService().getCurrentBaseSite().getUid())
       + "-customerLocation";
 }