Java Code Examples for org.apache.commons.lang.StringUtils#isBlank()

The following examples show how to use org.apache.commons.lang.StringUtils#isBlank() . These examples are extracted from open source projects. 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
/**
 * 清除token(注销登录)
 */
@SysLog("登出")
@DeleteMapping("/logout")
@ApiOperation(value = "登出")
public ApiResponse logout(@RequestHeader(value = HttpHeaders.AUTHORIZATION, required = false) String authHeader) {
    if (StringUtils.isBlank(authHeader)) {
        return fail("退出失败,token 为空");
    }
    //注销当前用户
    String tokenValue = authHeader.replace(OAuth2AccessToken.BEARER_TYPE, StringUtils.EMPTY).trim();
    OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue);
    tokenStore.removeAccessToken(accessToken);
    OAuth2RefreshToken refreshToken = accessToken.getRefreshToken();
    tokenStore.removeRefreshToken(refreshToken);
    return success("注销成功");
}
 
Example 2
Source Project: Bats   File: LaunchContainerRunnable.java    License: Apache License 2.0 6 votes vote down vote up
private void setClasspath(Map<String, String> env)
{
  // add localized application jar files to classpath
  // At some point we should not be required to add
  // the hadoop specific classpaths to the env.
  // It should be provided out of the box.
  // For now setting all required classpaths including
  // the classpath to "." for the application jar
  StringBuilder classPathEnv = new StringBuilder("./*");
  String classpath = nmClient.getConfig().get(YarnConfiguration.YARN_APPLICATION_CLASSPATH);
  for (String c : StringUtils.isBlank(classpath) ? YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH : classpath.split(",")) {
    if (c.equals("$HADOOP_CLIENT_CONF_DIR")) {
      // SPOI-2501
      continue;
    }
    classPathEnv.append(':');
    classPathEnv.append(c.trim());
  }
  classPathEnv.append(":."); // include log4j.properties, if any

  env.put("CLASSPATH", classPathEnv.toString());
  LOG.info("CLASSPATH: {}", classPathEnv);
}
 
Example 3
public String handleResponse(HttpResponse response)
		throws ClientProtocolException, IOException {
	StatusLine statusLine = response.getStatusLine();
	if (statusLine.getStatusCode() >= 300) {
		throw new HttpResponseException(statusLine.getStatusCode(),
				statusLine.getReasonPhrase());
	}
	HttpEntity entity = response.getEntity();
	if (entity != null) {
		if (!StringUtils.isBlank(charset)) {
			return EntityUtils.toString(entity, charset);
		} else {
			return EntityUtils.toString(entity);
		}
	} else {
		return null;
	}
}
 
Example 4
Source Project: bulbasaur   File: Machine.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 计算下一个节点
 *
 * @return void
 * @throws Throwable
 * @author: [email protected]
 * @since 2012-12-12 下午8:51:48
 */
protected StateLike run0_calcNext(StateLike currentState) {

    //判断是否有直接跳转
    String next = null;
    if (currentState.getJumpTo() != null) {
        next = currentState.getJumpTo();
    } else {
        next = currentState.willGo(context);
    }
    if (!StringUtils.isBlank(next)) {
        // 不为空,则有下一节点
        return definition.getState(next);
    }
    return null;
}
 
Example 5
Source Project: rice   File: KimType.java    License: Educational Community License v2.0 6 votes vote down vote up
/**
    * Gets the KimTypeAttribute matching the id of it's KimAttribute.  If no attribute definition exists with that
    * id then null is returned.
    *
    * <p>
    * If multiple exist with the same id then the first match is returned.  Since id
    * is supposed to be unique this should not be a problem in practice.
    * </p>
    *
    * @param id the KimTypeAttribute.KimAttribute's id
    * @return the KimTypeAttribute or null
    * @throws IllegalArgumentException if the id is blank
    */
   public KimTypeAttribute getAttributeDefinitionById(String id) {
       if (StringUtils.isBlank(id)) {
           throw new IllegalArgumentException("id is blank");
       }

       if (this.attributeDefinitions != null) {
           for (KimTypeAttribute att : this.attributeDefinitions) {
               if (att != null && att.getKimAttribute() != null
                       && id.equals(att.getKimAttribute().getId())) {
                   return att;
               }
           }
       }
	return null;
}
 
Example 6
Source Project: Lottery   File: CmsTopic.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 获得简短名称,如果不存在则返回名称
 * 
 * @return
 */
public String getSname() {
	if (!StringUtils.isBlank(getShortName())) {
		return getShortName();
	} else {
		return getName();
	}
}
 
Example 7
Source Project: jstorm   File: UIUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static Integer parseWindow(String windowStr) {
    Integer window;
    if (StringUtils.isBlank(windowStr)) {
        window = AsmWindow.M1_WINDOW;
    } else {
        window = Integer.valueOf(windowStr);
    }
    return window;
}
 
Example 8
Source Project: youkefu   File: CubeController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 已发布模型列表
 * @param map
 * @param request
 * @param typeid
 * @param msg
 * @return
 */
@RequestMapping("/pbcubeindex")
@Menu(type = "report" , subtype = "pbcube" )
public ModelAndView pbcubeindex(ModelMap map , HttpServletRequest request , @Valid String typeid) {
	List<CubeType> cubeTypeList = cubeTypeRes.findByOrgi(super.getOrgi(request)) ; 
	if(!StringUtils.isBlank(typeid)){
    	map.put("cubeType", cubeTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))) ;
		map.put("cubeList", publishedCubeRes.getByOrgiAndTypeid(super.getOrgi(request) , typeid , new PageRequest(super.getP(request), super.getPs(request)))) ;
	}else{
		map.put("cubeList", publishedCubeRes.getByOrgi(super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request)))) ;
	}
	map.put("pubCubeTypeList", cubeTypeList) ;
	map.put("typeid", typeid);
	return request(super.createAppsTempletResponse("/apps/business/report/cube/pbCubeIndex"));
}
 
Example 9
protected static String extractFragmentOutput(GuiFragment fragment, RequestContext reqCtx) throws Throwable {
	if (null == fragment) {
		return null;
	}
	try {
		String currentGui = fragment.getCurrentGui();
		if (StringUtils.isBlank(currentGui)) {
			_logger.info("The fragment '{}' is not available", fragment.getCode());
			return "";
		}
		ExecutorBeanContainer ebc = (ExecutorBeanContainer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_EXECUTOR_BEAN_CONTAINER);
		Integer frame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME);
		Widget currentWidget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
		StringBuilder templateName = new StringBuilder(String.valueOf(frame)).append("_").append(fragment.getCode());
		if (null != currentWidget && null != currentWidget.getType()) {
			templateName.append("_").append(currentWidget.getType().getCode());
		}
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		Writer out = new OutputStreamWriter(baos);
		Template template = new Template(templateName.toString(), new StringReader(currentGui), ebc.getConfiguration());
		template.process(ebc.getTemplateModel(), out);
		out.flush();
		return baos.toString().trim();
	} catch (Throwable t) {
		String msg = "Error creating fragment output - code '" + fragment.getCode() + "'";
		_logger.error(msg, t);
		throw new ApsSystemException(msg, t);
	}
}
 
Example 10
/**
 * @param input
 *          the input.
 * @return new list, never null.
 */
public static List<String> fromString( final String input ) {
  final List<String> result = new ArrayList<String>();
  if ( StringUtils.isBlank( input ) ) {
    return result;
  }
  for ( String value : StringUtils.split( input, SEPARATOR_CHAR ) ) {
    result.add( value );
  }
  return result;
}
 
Example 11
private void buildNameSearch(String searchString, StringBuilder sqlBuilder, boolean useWhere) {
if (!StringUtils.isBlank(searchString)) {
    String[] tokens = searchString.trim().split("\\s+");
    for (String token : tokens) {
	String escToken = StringEscapeUtils.escapeSql(token);
	sqlBuilder.append(useWhere ? " WHERE " : " AND ").append("(user.fullname LIKE '%").append(escToken)
		.append("%' OR user.username LIKE '%").append(escToken).append("%') ");
    }
}
   }
 
Example 12
Source Project: lams   File: MessageForm.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
    * MessageForm validation method from STRUCT interface.
    *
    */
   public MultiValueMap<String, String> validate(HttpServletRequest request, MessageService messageService) {

MultiValueMap<String, String> errorMap = new LinkedMultiValueMap<String, String>();

try {
    if (StringUtils.isBlank(message.getSubject())) {
	errorMap.add("message.subject", messageService.getMessage("error.subject.required"));
    }
    boolean isTestHarness = Boolean.valueOf(request.getParameter("testHarness"));
    if (!isTestHarness && StringUtils.isBlank(message.getBody())) {
	errorMap.add("message.body", messageService.getMessage("error.body.required"));
    }

    // validate item size
    boolean largeFile = true;
    if (request.getRequestURI().indexOf("/learning/") != -1) {
	if ((this.getAttachmentFile() != null)
		&& FileUtil.isExecutableFile(this.getAttachmentFile().getOriginalFilename())) {
	    errorMap.add("message.attachments", messageService.getMessage("error.attachment.executable"));
	}
	largeFile = false;
    }

    FileValidatorUtil.validateFileSize(this.getAttachmentFile(), largeFile);

} catch (Exception e) {
    MessageForm.logger.error("", e);
}
return errorMap;
   }
 
Example 13
Source Project: xds-ide   File: SdkToolsControl.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * If 'it' is tool and is child - returns its root index in the treeModer. In other case returns -1
 */
private int getRootIdxFor(ModelItem it) {
    if (!it.isRoot() && !StringUtils.isBlank(it.tool.getMenuGroup())) {
        for (int idx = treeModel.indexOf(it); idx >= 0; --idx) {
            if (treeModel.get(idx).isRoot()) {
                return idx;
            }
        }
    }
    return -1;
}
 
Example 14
/**
    * @see org.kuali.rice.krad.service.AttachmentService#createAttachment(GloballyUnique,
    * String, String, int, java.io.InputStream, String)
    */
   @Override
public Attachment createAttachment(GloballyUnique parent, String uploadedFileName, String mimeType, int fileSize, InputStream fileContents, String attachmentTypeCode) throws IOException {
       if ( LOG.isDebugEnabled() ) {
           LOG.debug("starting to create attachment for document: " + parent.getObjectId());
       }
       if (parent == null) {
           throw new IllegalArgumentException("invalid (null or uninitialized) document");
       }
       if (StringUtils.isBlank(uploadedFileName)) {
           throw new IllegalArgumentException("invalid (blank) fileName");
       }
       if (StringUtils.isBlank(mimeType)) {
           throw new IllegalArgumentException("invalid (blank) mimeType");
       }
       if (fileSize <= 0) {
           throw new IllegalArgumentException("invalid (non-positive) fileSize");
       }
       if (fileContents == null) {
           throw new IllegalArgumentException("invalid (null) inputStream");
       }

       String uniqueFileNameGuid = UUID.randomUUID().toString();
       String fullPathUniqueFileName = getDocumentDirectory(parent.getObjectId()) + File.separator + uniqueFileNameGuid;

       writeInputStreamToFileStorage(fileContents, fullPathUniqueFileName);

       // create DocumentAttachment
       Attachment attachment = new Attachment();
       attachment.setAttachmentIdentifier(uniqueFileNameGuid);
       attachment.setAttachmentFileName(uploadedFileName);
       attachment.setAttachmentFileSize(new Long(fileSize));
       attachment.setAttachmentMimeTypeCode(mimeType);
       attachment.setAttachmentTypeCode(attachmentTypeCode);

       if ( LOG.isDebugEnabled() ) {
       	LOG.debug("finished creating attachment for document: " + parent.getObjectId());
       }
       return attachment;
   }
 
Example 15
/**
 * Determines whether or not to create an automatic inquiry widget for this field within the current lifecycle.
 * 
 * @return True if an automatic inquiry widget should be created for this field on the current lifecycle.
 */
protected boolean hasAutoInquiryRelationship() {
    if (getBindingInfo() == null) {
        return false;
    }

    View view = ViewLifecycle.getView();
    Object model = ViewLifecycle.getModel();
    Object object = ViewModelUtils.getParentObjectForMetadata(view, model, this);

    // Do checks for inquiry when read only
    if (Boolean.TRUE.equals(getReadOnly())) {
        String bindingPath = getBindingInfo().getBindingPath();

        if (StringUtils.isBlank(bindingPath) || bindingPath.equals("null")) {
            return false;
        }

        Object propertyValue;

        // do not render the inquiry if the field value is null
        try {
            propertyValue = ObjectPropertyUtils.getPropertyValue(model, bindingPath);

            if ((propertyValue == null) || StringUtils.isBlank(propertyValue.toString())) {
                return false;
            }
        } catch (Exception e) {
            // if we can't get the value just swallow the exception and don't set an inquiry
            return false;
        }

        // do not render the inquiry link if it is the same as its parent
        if (view.getViewTypeName() == UifConstants.ViewType.INQUIRY) {
            InquiryForm inquiryForm = (InquiryForm) model;
            String[] parameterValues = inquiryForm.getInitialRequestParameters().get(propertyName);

            // do not render the inquiry if current data object is the same as its parent and the request parameter
            // contains the parent field value
            if (StringUtils.equals(inquiryForm.getDataObjectClassName(), dictionaryObjectEntry)
                    && ArrayUtils.contains(parameterValues, propertyValue.toString())) {
                return false;
            }
        }
    }

    return object != null && KRADServiceLocatorWeb.getViewDictionaryService().isInquirable(object.getClass());
}
 
Example 16
/**
 * Set tprFile to file or ""
 * Set text in textTprFile
 * Set cboxUseTprFile ON/OFF if file exists/not (and it should reenable ctrls)
 */
private void setAllBySdk() {
    {
        dirsFromSdk = ""; //$NON-NLS-1$
        redFromSdk = ""; //$NON-NLS-1$
        useTemplateFromSdk = false;
        if (projectSdk.isValid()) {
            Sdk sdk = projectSdk.getSelectedSdkInstance();
            if (sdk != null) { // else - int. error?..
                // Red file:
                String trd  = sdk.getTrdFile();
                if (Sdk.isFile(trd)) { 
                    String xc = FilenameUtils.getBaseName(sdk.getCompilerExecutablePath());
                    redFromSdk = xc + ".red"; //$NON-NLS-1$
                    useTemplateFromSdk = true;
                }
                // Dirs:
                dirsFromSdk = StringUtils.trim(sdk.getDirsToCreate());
                if (Sdk.isSet(dirsFromSdk)) {
                    useTemplateFromSdk = true;
                }
                // Prj template:
                if (Sdk.isFile(sdk.getTprFile())) {
                    useTemplateFromSdk = true;
                }
            }
        }
    }

    createDirs = !StringUtils.isBlank(dirsFromSdk);
    textDirs.setText(dirsFromSdk);
    cboxCreateDirs.setSelection(createDirs);
    cboxCreateDirs.setEnabled(createDirs);
    textDirs.setEnabled(createDirs);

    createRedFile = !StringUtils.isBlank(redFromSdk); 
    textRedFile.setText(redFromSdk);
    cboxCreateRedFile.setSelection(createRedFile);
    cboxCreateRedFile.setEnabled(createRedFile);
    textRedFile.setEnabled(createRedFile);

    cboxTemplateFromSdk.setSelection(useTemplateFromSdk);
    cboxTemplateFromSdk.setEnabled(useTemplateFromSdk);

    reenableForUseSdk();
}
 
Example 17
Source Project: Kylin   File: KylinConfig.java    License: Apache License 2.0 4 votes vote down vote up
public String[] getRestServers() {
    String nodes = getOptional(KYLIN_REST_SERVERS);
    if (StringUtils.isBlank(nodes))
        return null;
    return nodes.split("\\s*,\\s*");
}
 
Example 18
@RequestMapping("/logout")
   public String logout(HttpSession session) throws IOException, ServletException {
String logoutURL = (String) session.getAttribute("integratedLogoutURL");
session.invalidate();
return "redirect:" + (StringUtils.isBlank(logoutURL) ? "/index.do" : logoutURL);
   }
 
Example 19
public void setName(String name) {
    if (StringUtils.isBlank(name)) {
        throw new IllegalArgumentException("name was null or blank");
    }
    this.name = name;
}
 
Example 20
Source Project: nfs-client-java   File: Nfs3.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Convenience method to check String parameters that cannot be blank.
 * 
 * @param value The parameter value.
 * @param name The parameter name, for exception messages.
 */
private void checkForBlank(String value, String name) {
    if (StringUtils.isBlank(value)) {
        throw new IllegalArgumentException(name + " cannot be empty");
    }
}