Java Code Examples for org.apache.commons.lang.StringUtils#EMPTY

The following examples show how to use org.apache.commons.lang.StringUtils#EMPTY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamCatalogService.java    From streamline with Apache License 2.0 6 votes vote down vote up
private String parseAndSerialize(TopologyWindow topologyWindow) throws JsonProcessingException {
    if (topologyWindow.getStreams() == null || topologyWindow.getStreams().isEmpty()) {
        LOG.error("Streams should be specified.");
        return StringUtils.EMPTY;
    }
    Rule rule = new Rule();
    rule.setId(topologyWindow.getId());
    rule.setName(topologyWindow.getName());
    rule.setDescription(topologyWindow.getDescription());
    rule.setWindow(topologyWindow.getWindow());
    rule.setActions(topologyWindow.getActions());
    String sql = getSqlString(topologyWindow.getStreams(),
            topologyWindow.getProjections(),
            topologyWindow.getCondition(),
            topologyWindow.getGroupbykeys());
    updateRuleWithSql(rule, sql, topologyWindow.getTopologyId(), topologyWindow.getVersionId());
    validateProjection(rule.getProjection().getExpressions(), rule.getGroupBy().getExpressions());
    ObjectMapper mapper = new ObjectMapper();
    return mapper.writeValueAsString(rule);
}
 
Example 2
Source File: ChartData.java    From rebuild with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 获取过滤 SQL
 * 
 * @return
 */
protected String getFilterSql() {
	String previewFilter = StringUtils.EMPTY;
	// 限制预览数据量
	if (isFromPreview() && getSourceEntity().containsField(EntityHelper.AutoId)) {
		String maxAidSql = String.format("select max(%s) from %s", EntityHelper.AutoId, getSourceEntity().getName());
		Object[] o = Application.createQueryNoFilter(maxAidSql).unique();
		long maxAid = ObjectUtils.toLong(o[0]);
		if (maxAid > 5000) {
			previewFilter = String.format("(%s >= %d) and ", EntityHelper.AutoId, Math.max(maxAid - 2000, 0));
		}
	}
	
	JSONObject filterExp = config.getJSONObject("filter");
	if (filterExp == null || filterExp.isEmpty()) {
		return previewFilter + "(1=1)";
	}
	
	AdvFilterParser filterParser = new AdvFilterParser(filterExp);
	String sqlWhere = filterParser.toSqlWhere();
	if (sqlWhere != null) {
		sqlWhere = previewFilter + sqlWhere;
	}
	return StringUtils.defaultIfBlank(sqlWhere, "(1=1)");
}
 
Example 3
Source File: TestMBooleanInput.java    From sqoop-on-spark with Apache License 2.0 6 votes vote down vote up
/**
 * Test for equals() method
 */
@Test
public void testEquals() {
  // Positive test
  MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY,
      StringUtils.EMPTY);
  MBooleanInput input2 = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY,
      StringUtils.EMPTY);
  assertTrue(input1.equals(input2));

  // Negative test
  MBooleanInput input3 = new MBooleanInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY );
  MBooleanInput input4 = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY, StringUtils.EMPTY );
  assertFalse(input3.equals(input4));

  MBooleanInput input5 = new MBooleanInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY );
  MBooleanInput input6 = new MBooleanInput("sqoop", false, InputEditable.ANY, StringUtils.EMPTY );
  assertFalse(input5.equals(input6));
}
 
Example 4
Source File: InterceptorFactory.java    From DataLink with Apache License 2.0 6 votes vote down vote up
private static Object getInterceptorInternal(Long key) {
    InterceptorInfo info = DataLinkFactory.getObject(InterceptorService.class).getInterceptorById(key);
    Class<?> clazz = null;
    String fullname = StringUtils.EMPTY;

    if (info.getType() == InterceptorType.Class && StringUtils.isNotBlank(info.getContent())) {
        clazz = scan(info.getContent());
        fullname = "[" + info.getContent() + "]ClassPath";
    } else if (info.getType() == InterceptorType.Script && StringUtils.isNotBlank(info.getContent())) {
        JavaSource javaSource = new JavaSource(info.getContent());
        clazz = jdkCompiler.compile(javaSource);
        fullname = "[" + javaSource.toString() + "]SourceText";
    }

    if (clazz == null) {
        throw new InterceptorLoadException("ERROR ## classload this interceptor=" + fullname + " has an error");
    }

    try {
        return clazz.newInstance();
    } catch (Exception e) {
        throw new InterceptorLoadException("ERROR ## classload this interceptor=" + fullname + " has an error", e);
    }
}
 
Example 5
Source File: NotebookSocket.java    From submarine with Apache License 2.0 5 votes vote down vote up
public NotebookSocket(HttpServletRequest req, String protocol,
    NotebookSocketListener listener) {
  this.listener = listener;
  this.request = req;
  this.protocol = protocol;
  this.user = StringUtils.EMPTY;
}
 
Example 6
Source File: DefaultCustomerNameFormatterImpl.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
private String formatNameInternal(final Customer customer, final String format) {
    if (customer != null) {

        final Map<String, String> values = new HashMap<>();
        values.put("salutation", StringUtils.defaultString(customer.getSalutation()));
        values.put("firstname", StringUtils.defaultString(customer.getFirstname()));
        values.put("middlename", StringUtils.defaultString(customer.getMiddlename()));
        values.put("lastname", StringUtils.defaultString(customer.getLastname()));

        return new StrSubstitutor(values, "{{", "}}").replace(format);

    }
    return StringUtils.EMPTY;
}
 
Example 7
Source File: AbstractAuthorizeNetBasePaymentGatewayImpl.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
/**
 * Get street address.
 *
 * @param addreLine1 line 1
 * @param addreLine2 line 2
 * @return street address
 */
protected String getStreetAddress(final String addreLine1, final String addreLine2) {
    return addreLine1
            + (
            StringUtils.isNotBlank(addreLine2) ?
                    " " + addreLine2 :
                    StringUtils.EMPTY)
            ;

}
 
Example 8
Source File: ItemNavigator.java    From lutece-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Get the next page link of the item
 * 
 * @return the next page link of the item
 */
public String getNextPageLink( )
{
    int nNextItemId = _nCurrentItemId + 1;

    if ( ( _listItems != null ) && !_listItems.isEmpty( ) && ( nNextItemId < _listItems.size( ) ) )
    {
        UrlItem url = new UrlItem( _strBaseUrl );
        url.addParameter( _strParameterName, _listItems.get( nNextItemId ) );

        return url.getUrl( );
    }

    return StringUtils.EMPTY;
}
 
Example 9
Source File: ModuleMapper.java    From SugarOnRest with MIT License 5 votes vote down vote up
/**
 * Gets the table name based on module name.
 *
 * @param moduleName Module name.
 * @return SugarCRM module table name.
 */
public static String getTablename(String moduleName)
{
    if (mapper.containsValue(moduleName)) {
        for (Map.Entry<String, String> entry: mapper.entrySet()) {
            if (entry.getValue().equalsIgnoreCase(moduleName)) {
                return entry.getKey();
            }
        }
    }

    return StringUtils.EMPTY;
}
 
Example 10
Source File: OpenWeatherMapConnection.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
private String encodeParam(String value) {
    try {
        return URLEncoder.encode(value, StandardCharsets.UTF_8.name());
    } catch (UnsupportedEncodingException e) {
        logger.debug("UnsupportedEncodingException occurred during execution: {}", e.getLocalizedMessage(), e);
        return StringUtils.EMPTY;
    }
}
 
Example 11
Source File: GobblinAWSUtils.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
private static String getClasspathFromPath(File path) {
  if (null == path) {
    return StringUtils.EMPTY;
  }
  if (!path.isDirectory()) {
    return path.getAbsolutePath();
  }

  return Joiner.on(":").skipNulls().join(path.list(FileFileFilter.FILE));
}
 
Example 12
Source File: RBAC.java    From lutece-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Retrieve the label of the resource type from the resource type key
 * 
 * @return the label of the resource type
 */
public String getResourceTypeLabel( )
{
    ResourceType resourceType = ResourceTypeManager.getResourceType( getResourceTypeKey( ) );

    if ( resourceType != null )
    {
        return resourceType.getResourceTypeLabel( );
    }

    return StringUtils.EMPTY;
}
 
Example 13
Source File: JvmUtils.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
/**
 * Formats the specified jvm arguments such that any tokens are replaced with concrete values;
 * @param jvmArguments
 * @return The formatted jvm arguments.
 */
public static String formatJvmArguments(Optional<String> jvmArguments) {
  if (jvmArguments.isPresent()) {
    return PORT_UTILS.replacePortTokens(jvmArguments.get());
  }
  return StringUtils.EMPTY;
}
 
Example 14
Source File: ErasmusCandidacyProcessReport.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private String getEmail(MobilityIndividualApplicationProcess process) {
    if (process.getCandidacyHashCode() != null) {
        return process.getCandidacyHashCode().getEmail();
    }
    if (process.getCandidacy() != null) {
        if (process.getCandidacy().getPersonalDetails() != null) {
            return process.getCandidacy().getPersonalDetails().getEmail();
        }
    }
    return StringUtils.EMPTY;
}
 
Example 15
Source File: DefaultCustomerNameFormatterImpl.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
private String formatNameInternal(final Address address, final String format) {
    if (address != null) {

        final Map<String, String> values = new HashMap<>();
        values.put("salutation", StringUtils.defaultString(address.getSalutation()));
        values.put("firstname", StringUtils.defaultString(address.getFirstname()));
        values.put("middlename", StringUtils.defaultString(address.getMiddlename()));
        values.put("lastname", StringUtils.defaultString(address.getLastname()));

        return new StrSubstitutor(values, "{{", "}}").replace(format);

    }
    return StringUtils.EMPTY;
}
 
Example 16
Source File: XslExportJspBean.java    From lutece-core with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Get the request data and if there is no error insert the data in the exportFormat object specified in parameter. return null if there is no error or else
 * return the error page url
 * 
 * @param request
 *            the request
 * @param xslExport
 *            the exportFormat Object
 * @return null if there is no error or else return the error page url
 */
private String getXslExportData( HttpServletRequest request, XslExport xslExport )
{
    String strError = StringUtils.EMPTY;
    String strTitle = request.getParameter( PARAMETER_TITLE );
    String strDescription = request.getParameter( PARAMETER_DESCRIPTION );
    String strExtension = request.getParameter( PARAMETER_EXTENSION );
    String strPlugin = request.getParameter( PARAMETER_PLUGIN );
    File fileSource = getFileData( PARAMETER_ID_FILE, request );

    if ( ( strTitle == null ) || strTitle.trim( ).equals( EMPTY_STRING ) )
    {
        strError = FIELD_TITLE;
    }

    else
        if ( ( strDescription == null ) || strDescription.trim( ).equals( EMPTY_STRING ) )
        {
            strError = FIELD_DESCRIPTION;
        }

        else
            if ( StringUtils.isBlank( strExtension ) )
            {
                strError = FIELD_EXTENSION;
            }

            else
                if ( ( xslExport.getFile( ) == null ) && ( fileSource == null ) )
                {
                    strError = FIELD_FILE;
                }

    if ( strPlugin == null )
    {
        strPlugin = StringUtils.EMPTY;
    }

    // Mandatory fields
    if ( !strError.equals( EMPTY_STRING ) )
    {
        Object [ ] tabRequiredFields = {
                I18nService.getLocalizedString( strError, getLocale( ) )
        };

        return AdminMessageService.getMessageUrl( request, MESSAGE_MANDATORY_FIELD, tabRequiredFields, AdminMessage.TYPE_STOP );
    }

    // Check the XML validity of the XSL stylesheet
    if ( fileSource != null )
    {
        strError = isValid( fileSource.getPhysicalFile( ).getValue( ) );

        if ( strError != null )
        {
            Object [ ] args = {
                    strError
            };

            return AdminMessageService.getMessageUrl( request, MESSAGE_XML_NOT_VALID, args, AdminMessage.TYPE_STOP );
        }
    }

    xslExport.setTitle( strTitle );
    xslExport.setDescription( strDescription );
    xslExport.setExtension( strExtension );
    xslExport.setPlugin( strPlugin );

    xslExport.setFile( fileSource );

    return null;
}
 
Example 17
Source File: AdminUserJspBean.java    From lutece-core with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Update an account life time email
 * 
 * @param request
 *            The request
 * @return The Jsp URL of the process result
 * @throws AccessDeniedException
 *             if the security token is invalid
 */
public String doModifyAccountLifeTimeEmails( HttpServletRequest request ) throws AccessDeniedException
{
    if ( !SecurityTokenService.getInstance( ).validate( request, JSP_URL_MODIFY_ACCOUNT_LIFE_TIME_EMAIL ) )
    {
        throw new AccessDeniedException( ERROR_INVALID_TOKEN );
    }
    String strEmailType = request.getParameter( PARAMETER_EMAIL_TYPE );

    String strSenderKey = StringUtils.EMPTY;
    String strSubjectKey = StringUtils.EMPTY;
    String strBodyKey = StringUtils.EMPTY;

    if ( CONSTANT_EMAIL_TYPE_FIRST.equalsIgnoreCase( strEmailType ) )
    {
        strSenderKey = CONSTANT_ADVANCED_PARAMS + PARAMETER_FIRST_ALERT_MAIL_SENDER;
        strSubjectKey = CONSTANT_ADVANCED_PARAMS + PARAMETER_FIRST_ALERT_MAIL_SUBJECT;
        strBodyKey = PARAMETER_FIRST_ALERT_MAIL;
    }
    else
        if ( CONSTANT_EMAIL_TYPE_OTHER.equalsIgnoreCase( strEmailType ) )
        {
            strSenderKey = CONSTANT_ADVANCED_PARAMS + PARAMETER_OTHER_ALERT_MAIL_SENDER;
            strSubjectKey = CONSTANT_ADVANCED_PARAMS + PARAMETER_OTHER_ALERT_MAIL_SUBJECT;
            strBodyKey = PARAMETER_OTHER_ALERT_MAIL;
        }
        else
            if ( CONSTANT_EMAIL_TYPE_EXPIRED.equalsIgnoreCase( strEmailType ) )
            {
                strSenderKey = CONSTANT_ADVANCED_PARAMS + PARAMETER_EXPIRED_ALERT_MAIL_SENDER;
                strSubjectKey = CONSTANT_ADVANCED_PARAMS + PARAMETER_EXPIRED_ALERT_MAIL_SUBJECT;
                strBodyKey = PARAMETER_EXPIRATION_MAIL;
            }
            else
                if ( CONSTANT_EMAIL_TYPE_REACTIVATED.equalsIgnoreCase( strEmailType ) )
                {
                    strSenderKey = CONSTANT_ADVANCED_PARAMS + PARAMETER_REACTIVATED_ALERT_MAIL_SENDER;
                    strSubjectKey = CONSTANT_ADVANCED_PARAMS + PARAMETER_REACTIVATED_ALERT_MAIL_SUBJECT;
                    strBodyKey = PARAMETER_ACCOUNT_REACTIVATED;
                }
                else
                    if ( CONSTANT_EMAIL_PASSWORD_EXPIRED.equalsIgnoreCase( strEmailType ) )
                    {
                        strSenderKey = CONSTANT_ADVANCED_PARAMS + PARAMETER_PASSWORD_EXPIRED_MAIL_SENDER;
                        strSubjectKey = CONSTANT_ADVANCED_PARAMS + PARAMETER_PASSWORD_EXPIRED_MAIL_SUBJECT;
                        strBodyKey = PARAMETER_NOTIFY_PASSWORD_EXPIRED;
                    }

    AdminUserService.updateSecurityParameter( strSenderKey, request.getParameter( MARK_EMAIL_SENDER ) );
    AdminUserService.updateSecurityParameter( strSubjectKey, request.getParameter( MARK_EMAIL_SUBJECT ) );
    DatabaseTemplateService.updateTemplate( strBodyKey, request.getParameter( MARK_EMAIL_BODY ) );

    return JSP_MANAGE_ADVANCED_PARAMETERS;
}
 
Example 18
Source File: Degree.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public String constructSchoolClassPrefix(final Integer curricularYear) {
    return isBolonhaDegree() ? getSigla() + "0" + curricularYear.toString() : StringUtils.EMPTY;
}
 
Example 19
Source File: ContactsModuleTests.java    From SugarOnRest with MIT License 2 votes vote down vote up
public static void crudTest() {
    SugarRestClient client = new SugarRestClient(TestAccount.Url, TestAccount.Username, TestAccount.Password);

    Contacts insertContact = ContactsModule.getTestContact();

    // -------------------Create Contact-------------------
    SugarRestResponse response = ContactsModule.createContact(client, insertContact);

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    String insertId = (response.getData() == null) ? StringUtils.EMPTY : response.getData().toString();

    assertNotNull(insertId);
    assertNotSame(insertId, StringUtils.EMPTY );
    // -------------------End Create Contact-------------------


    // -------------------Read Contact-------------------
    response = ContactsModule.readContact(client, insertId);

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    Contacts readOnCreateContact = (Contacts) response.getData();

    assertNotNull(readOnCreateContact);
    assertEquals(insertContact.getFirstName(), readOnCreateContact.getFirstName());
    assertEquals(insertContact.getLastName(), readOnCreateContact.getLastName());
    assertEquals(insertContact.getTitle(), readOnCreateContact.getTitle());
    assertEquals(insertContact.getPrimaryAddressPostalcode(), readOnCreateContact.getPrimaryAddressPostalcode());
    // -------------------End Read Contact-------------------


    // -------------------Update Contact-------------------
    response = ContactsModule.updateContact(client, readOnCreateContact.getId());

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    String updateId = (response.getData() == null) ? StringUtils.EMPTY : response.getData().toString();

    assertNotNull(updateId);
    assertNotSame(updateId, StringUtils.EMPTY );
    // -------------------End Update Contact-------------------


    // -------------------Read Contact-------------------
    response = ContactsModule.readContact(client, updateId);

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    Contacts readOnUpdateContact = (Contacts) response.getData();

    assertNotNull(readOnUpdateContact.getTitle());
    assertNotSame(readOnUpdateContact.getTitle(), StringUtils.EMPTY );
    assertEquals(updateId, updateId);
    assertNotSame(readOnCreateContact.getTitle(), readOnUpdateContact.getTitle());
    // -------------------End Read Contact-------------------


    // -------------------Delete Contact-------------------
    response = ContactsModule.deleteContact(client, updateId);

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);;

    String deleteId = (response.getData() == null) ? StringUtils.EMPTY : response.getData().toString();

    assertNotNull(deleteId);
    assertNotSame(deleteId, StringUtils.EMPTY );
    assertEquals(insertId, deleteId);
    // -------------------End Delete Contact-------------------
}
 
Example 20
Source File: AccountsModuleTests.java    From SugarOnRest with MIT License 2 votes vote down vote up
@Test
public void crudByTypeTest() throws JsonProcessingException {
    SugarRestClient client = new SugarRestClient(TestAccount.Url, TestAccount.Username, TestAccount.Password);

    Accounts insertAccount = AccountsModule.getTestAccount();

    // -------------------Create Account-------------------
    SugarRestResponse response = AccountsModule.createAccountByType(client, insertAccount);

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    String insertId = (response.getData() == null) ? StringUtils.EMPTY : response.getData().toString();

    assertNotNull(insertId);
    assertNotSame(insertId, StringUtils.EMPTY );

    // -------------------End Create Account-------------------


    // -------------------Read Account-------------------
    response = AccountsModule.readAccountByType(client, insertId);

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    Accounts readOnCreateAccount = (Accounts)response.getData();

    assertNotNull(readOnCreateAccount);
    assertEquals(insertAccount.getName(), readOnCreateAccount.getName());
    assertEquals(insertAccount.getIndustry(), readOnCreateAccount.getIndustry());
    assertEquals(insertAccount.getWebsite(), readOnCreateAccount.getWebsite());
    assertEquals(insertAccount.getShippingAddressCity(), readOnCreateAccount.getShippingAddressCity());
    // -------------------End Read Account-------------------


    // -------------------Update Account-------------------
    response = AccountsModule.updateAccountByType(client, readOnCreateAccount.getId());

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    String updateId = (response.getData() == null) ? StringUtils.EMPTY : response.getData().toString();

    assertNotNull(updateId);
    assertNotSame(updateId, StringUtils.EMPTY );
    // -------------------End Update Account-------------------


    // -------------------Read Account-------------------
    response = AccountsModule.readAccount(client, updateId);

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    Accounts readOnUpdateAccount = (Accounts)response.getData();

    assertNotNull(readOnUpdateAccount.getName());
    assertNotSame(readOnUpdateAccount.getName(), StringUtils.EMPTY );
    assertEquals(updateId, updateId);
    assertNotEquals(readOnCreateAccount.getName(), readOnUpdateAccount.getName());
    // -------------------End Read Account-------------------

    // -------------------Delete Account-------------------
    response = AccountsModule.deleteAccountByType(client, updateId);

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    String deleteId = (response.getData() == null) ? StringUtils.EMPTY : response.getData().toString();

    assertNotNull(deleteId);
    assertNotSame(deleteId, StringUtils.EMPTY );
    assertEquals(insertId, deleteId);

    // -------------------End Delete Account-------------------
}