org.apache.commons.lang.NullArgumentException Java Examples

The following examples show how to use org.apache.commons.lang.NullArgumentException. 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: LdapConfigCheckMain.java    From ranger with Apache License 2.0 6 votes vote down vote up
private static void retrieveGroups(LdapContext ldapContext, UserSync userSyncObj) throws Throwable {
    String msg;
    if (userSyncObj.getGroupNameAttrName() == null || userSyncObj.getGroupNameAttrName().isEmpty()) {
        msg = "ranger.usersync.group.nameattribute ";
        throw new NullArgumentException(msg);
    }
    if (userSyncObj.getGroupObjClassName() == null || userSyncObj.getGroupObjClassName().isEmpty()) {
        msg = "ranger.usersync.group.objectclass ";
        throw new NullArgumentException(msg);
    }
    if (userSyncObj.getGroupMemberName() == null || userSyncObj.getGroupMemberName().isEmpty()) {
        msg = "ranger.usersync.group.memberattributename ";
        throw new NullArgumentException(msg);
    }
    if ((userSyncObj.getGroupSearchBase() == null || userSyncObj.getGroupSearchBase().isEmpty()) &&
            (userSyncObj.getSearchBase() == null || userSyncObj.getSearchBase().isEmpty())) {
        msg = "ranger.usersync.group.searchbase and " +
                "ranger.usersync.ldap.searchBase ";
        throw new NullArgumentException(msg);
    }
    userSyncObj.getAllGroups(ldapContext);
}
 
Example #2
Source File: ThreadPoolTaskQueuesExecutor.java    From util4j with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(String queueName,List<Task> tasks) {
	if(queueName==null || tasks ==null)
   	{
   		throw new NullArgumentException("queueName is null");
   	}
	if(shutdown)
	{
		for(Task t:tasks)
		{
			rejectTask(t);
		}
	}
   	TaskQueueImpl tasksQueue = getTaskQueue(queueName);
   	if(tasksQueue!=null)
   	{
   		tasksQueue.addAll(tasks);
   	}
}
 
Example #3
Source File: CassandraStorage.java    From copper-engine with Apache License 2.0 6 votes vote down vote up
public CassandraStorage(final CassandraSessionManager sessionManager, final Executor executor, final RuntimeStatisticsCollector runtimeStatisticsCollector, final ConsistencyLevel consistencyLevel) {
    if (sessionManager == null)
        throw new NullArgumentException("sessionManager");

    if (consistencyLevel == null)
        throw new NullArgumentException("consistencyLevel");

    if (executor == null)
        throw new NullArgumentException("executor");

    if (runtimeStatisticsCollector == null)
        throw new NullArgumentException("runtimeStatisticsCollector");

    this.executor = executor;
    this.consistencyLevel = consistencyLevel;
    this.session = sessionManager.getSession();
    this.cluster = sessionManager.getCluster();
    this.runtimeStatisticsCollector = runtimeStatisticsCollector;

}
 
Example #4
Source File: SimpleRequestBuilder.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
private SimpleRequestBuilder addParameterInt(String parameterKey, String parameterValue) {
    if (allRight()) {
        if (parameterKey == null) {
            throw new NullArgumentException("parameterKey");
        }
        if (parameterValue != null) {
            if (!parameterIsAdded) {
                parameterIsAdded = true;
                request = request + "?" + parameterKey + "=" + parameterValue;
            } else {
                request = request + "&" + parameterKey + "=" + parameterValue;
            }
        }
    }
    return this;
}
 
Example #5
Source File: FixedThreadPoolQueuesExecutor.java    From util4j with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(String queueName, Task task) {
   	if(shutdown)
   	{
   		rejectTask(task);
   	}
   	if(queueName==null || task ==null)
   	{
   		throw new NullArgumentException("queueName is null");
   	}
   	TaskQueueImpl tasksQueue = getTaskQueue(queueName);
   	if(tasksQueue!=null)
   	{
   		tasksQueue.offer(task);
   	}
}
 
Example #6
Source File: FixedThreadPoolQueuesExecutor.java    From util4j with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(String queueName,List<Task> tasks) {
	if(shutdown)
	{
		for(Task t:tasks)
		{
			rejectTask(t);
		}
	}
	if(queueName==null || tasks ==null)
   	{
   		throw new NullArgumentException("queueName is null");
   	}
   	TaskQueueImpl tasksQueue = getTaskQueue(queueName);
   	if(tasksQueue!=null)
   	{
   		tasksQueue.addAll(tasks);
   	}
}
 
Example #7
Source File: ThreadPoolTaskQueuesExecutor.java    From util4j with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(String queueName, Task task) {
   	if(queueName==null || task ==null)
   	{
   		throw new NullArgumentException("queueName is null");
   	}
   	if(shutdown)
   	{
   		rejectTask(task);
   	}
   	TaskQueueImpl tasksQueue = getTaskQueue(queueName);
   	if(tasksQueue!=null)
   	{
   		tasksQueue.offer(task);
   	}
}
 
Example #8
Source File: FileUtil.java    From util4j with Apache License 2.0 6 votes vote down vote up
/**
 * 寻找目录下面的jar
 * @param dir
 * @return
 */
public static final File[] findJarFileByDir(File dir)
{
	if(dir==null)
	{
		throw new NullArgumentException("dir ==null");
	}
	if(dir.isFile())
	{
		throw new IllegalArgumentException("dir "+dir+" is not a dir");
	}
	if(!dir.exists())
	{
		throw new IllegalArgumentException("dir "+dir+" not found");
	}
	File[] jarFiles = dir.listFiles(new FileFilter() {
		@Override
		public boolean accept(File pathname) 
			{
				return pathname.getName().endsWith(".jar");
			}
		});
	return jarFiles;
}
 
Example #9
Source File: SummonController.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onDie(final Creature lastAttacker) {
	if (lastAttacker == null) {
		throw new NullArgumentException("lastAttacker");
	}
	super.onDie(lastAttacker);
	SummonsService.release(getOwner(), UnsummonType.UNSPECIFIED, isAttacked);
	Summon owner = getOwner();
	final Player master = getOwner().getMaster();
	PacketSendUtility.broadcastPacket(owner, new SM_EMOTION(owner, EmotionType.DIE, 0, lastAttacker.equals(owner) ? 0 : lastAttacker.getObjectId()));

	if (!master.equals(lastAttacker) && !owner.equals(lastAttacker) && !master.getLifeStats().isAlreadyDead() && !lastAttacker.getLifeStats().isAlreadyDead()) {
		ThreadPoolManager.getInstance().schedule(new Runnable() {

			@Override
			public void run() {
				lastAttacker.getAggroList().addHate(master, 1);
			}
		}, 1000);
	}
}
 
Example #10
Source File: SimpleRequestBuilder.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
private SimpleRequestBuilder addFunctionInt(String functionKey) {
    if (!classIsChosen) {
        throw new IllegalArgumentException(ExeptionConstants.NO_CLASS_ADDED);
    }
    if (!functionIsChosen) {
        if (functionKey != null) {
            functionIsChosen = true;
            request = request + functionKey;
        } else {
            throw new NullArgumentException("functionKey");
        }
    } else {
        throw new IllegalArgumentException(ExeptionConstants.FUNCTION_ALLREADY_ADDED);
    }
    return this;
}
 
Example #11
Source File: LdapConfigCheckMain.java    From ranger with Apache License 2.0 6 votes vote down vote up
private static void retrieveUsers(LdapContext ldapContext, UserSync userSyncObj) throws Throwable {
    String msg;
    if (userSyncObj.getUserNameAttribute() == null || userSyncObj.getUserNameAttribute().isEmpty()) {
        msg = "ranger.usersync.ldap.user.nameattribute ";
        throw new NullArgumentException(msg);
    }
    if (userSyncObj.getUserObjClassName() == null || userSyncObj.getUserObjClassName().isEmpty()) {
        msg = "ranger.usersync.ldap.user.objectclass ";
        throw new NullArgumentException(msg);
    }
    if ((userSyncObj.getUserSearchBase() == null || userSyncObj.getUserSearchBase().isEmpty()) &&
            (userSyncObj.getSearchBase() == null || userSyncObj.getSearchBase().isEmpty())) {
        msg = "ranger.usersync.ldap.user.searchbase and " +
                "ranger.usersync.ldap.searchBase ";
        throw new NullArgumentException(msg);
    }
    userSyncObj.getAllUsers(ldapContext);
}
 
Example #12
Source File: LdapConfigCheckMain.java    From ranger with Apache License 2.0 6 votes vote down vote up
private static void retrieveUsersGroups(LdapContext ldapContext, UserSync userSyncObj,
                                        String retrieve) throws Throwable {
    String msg;
    if (retrieve == null || userSyncObj == null || ldapContext == null) {
        msg = "Input validation failed while retrieving Users or Groups";
        throw new NullArgumentException(msg);
    }

    if (retrieve.equalsIgnoreCase("users")) {
        retrieveUsers(ldapContext, userSyncObj);
    } else if (retrieve.equalsIgnoreCase("groups")){
        retrieveGroups(ldapContext, userSyncObj);
    } else {
        // retrieve both
        retrieveUsers(ldapContext, userSyncObj);
        retrieveGroups(ldapContext, userSyncObj);
    }
}
 
Example #13
Source File: LdapConfigCheckMain.java    From ranger with Apache License 2.0 6 votes vote down vote up
private static void authenticate(UserSync userSyncObj, LdapConfig config,
                                 PrintStream logFile, PrintStream ambariProps,
                                 PrintStream installProps) throws Throwable{
    AuthenticationCheck auth = new AuthenticationCheck(config.getLdapUrl(), userSyncObj, logFile, ambariProps, installProps);

    auth.discoverAuthProperties();

    String msg;
    if (config.getAuthUsername() == null || config.getAuthUsername().isEmpty()) {
        msg = "ranger.admin.auth.sampleuser ";
        throw new NullArgumentException(msg);
    }

    if (config.getAuthPassword() == null || config.getAuthPassword().isEmpty()) {
        msg = "ranger.admin.auth.samplepassword ";
        throw new NullArgumentException(msg);
    }

    if (auth.isAuthenticated(config.getLdapUrl(), config.getLdapBindDn(), config.getLdapBindPassword(),
            config.getAuthUsername(), config.getAuthPassword())) {
        logFile.println("INFO: Authentication verified successfully");
    } else {
        logFile.println("ERROR: Failed to authenticate " + config.getAuthUsername());
    }
}
 
Example #14
Source File: OlapUtils.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @param member
 * @return
 */
public Member getTopLevelRaggedMember(Member member) {
	if (member == null) {
		throw new NullArgumentException("member");
	}

	Member topMember;

	if (member instanceof RaggedMemberWrapper) {
		topMember = ((RaggedMemberWrapper) member).getTopMember();
	} else {
		topMember = getParentMember(member);
	}

	return topMember;
}
 
Example #15
Source File: OlapUtils.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @param member
 * @return
 */
public Member getBaseRaggedMember(Member member) {
	if (member == null) {
		throw new NullArgumentException("member");
	}

	Member baseMember;

	if (member instanceof RaggedMemberWrapper) {
		baseMember = ((RaggedMemberWrapper) member).getBaseMember();
	} else {
		baseMember = member;
	}

	return baseMember;
}
 
Example #16
Source File: OlapUtils.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @param property
 * @param level
 * @return
 */
public static Property wrapProperty(Property property, Level level) {
	if (property == null) {
		throw new NullArgumentException("property");
	}

	if (level == null) {
		throw new NullArgumentException("level");
	}

	if (property instanceof PropertyWrapper) {
		return property;
	}

	return new PropertyWrapper(property, level);
}
 
Example #17
Source File: CacheManager.java    From j2cache with Apache License 2.0 6 votes vote down vote up
/**
 * 可以指定缓存提供者的方式获取或创建缓存
 * @param stategy    缓存策略类
 * @param cacheName  缓存名
 * @param keyClass   键的类类型
 * @param valueCalss 值的类类型
 * @param maxSize    最大缓存大小(0表示不限制)
 * @param maxLieftime缓存过期时间(0表示不过期)
 * @return 缓存对象
 * @throws Exception 如果stategy为空时会抛出异常
 */
@SuppressWarnings("unchecked")
public static synchronized <T extends ICache<?,?>> T  getOrCreateCache(
		String stategy, String cacheName, Class<?> keyClass, Class<?> valueCalss, 
		long maxSize, long maxLifetime) throws Exception {
	if (stategy == null) {
		throw new NullArgumentException("stategy");
	}
	
	CacheObject cacheObj = caches.get(cacheName);
    if (cacheObj != null) {
        return (T) cacheObj.getCache();
    }
	ICacheStrategy starategy = (ICacheStrategy) Class.forName(stategy).newInstance();
    T cache = (T) starategy.createCache(cacheName, keyClass, valueCalss, maxSize, maxLifetime);
    caches.put(cacheName, new CacheObject(starategy, cache));
	return cache;
}
 
Example #18
Source File: ReentrantLockHelper.java    From ymate-platform-v2 with Apache License 2.0 6 votes vote down vote up
public static <K, V> V putIfAbsent(ConcurrentMap<K, V> target, K key, V value) {
    if (target == null) {
        throw new NullArgumentException("target");
    }
    if (key == null) {
        throw new NullArgumentException("key");
    }
    V _value = target.get(key);
    if (_value == null) {
        if (value != null) {
            _value = value;
            V _previous = target.putIfAbsent(key, value);
            if (_previous != null) {
                _value = _previous;
            }
        }
    }
    return _value;
}
 
Example #19
Source File: ReentrantLockHelper.java    From ymate-platform-v2 with Apache License 2.0 6 votes vote down vote up
/**
 * @param target      目标映射
 * @param key         键名
 * @param valueGetter 键值回调接口
 * @param <K>         键名类型
 * @param <V>         键值类型
 * @return 返回键值对象
 * @throws Exception 可能产生的任何异常
 * @since 2.0.7
 */
public static <K, V> V putIfAbsentAsync(ConcurrentMap<K, V> target, K key, ValueGetter<V> valueGetter) throws Exception {
    if (target == null) {
        throw new NullArgumentException("target");
    }
    if (key == null) {
        throw new NullArgumentException("key");
    }
    V v = target.get(key);
    if (v == null) {
        v = valueGetter.getValue();
        if (v != null) {
            V previous = target.putIfAbsent(key, v);
            if (previous != null) {
                v = previous;
            }
        }
    }
    return v;
}
 
Example #20
Source File: StringUtils.java    From Poseidon with Apache License 2.0 6 votes vote down vote up
/**
 *  Joins the array of values with a given separator and returns the .
 */
public static String join(String[] arrayOfStrings, String separator) {
	boolean appendSeparator = false;
	if(arrayOfStrings!=null) {
		StringBuilder stringBuilder = new StringBuilder();
		for(String string : arrayOfStrings) {
			if(appendSeparator) {
				stringBuilder.append(separator);
			}
			else {
				appendSeparator=true;
			}
			stringBuilder.append(string);
		}
		return stringBuilder.toString();
	}
	else {
		throw new NullArgumentException("arrayOfStrings");
	}
}
 
Example #21
Source File: FileUtils.java    From ymate-platform-v2 with Apache License 2.0 6 votes vote down vote up
/**
 * @param filePath 目标文件路径
 * @return 将文件路径转换成URL对象, 返回值可能为NULL, 若想将jar包中文件,必须使用URL.toString()方法生成filePath参数—即以"jar:"开头
 */
public static URL toURL(String filePath) {
    if (StringUtils.isBlank(filePath)) {
        throw new NullArgumentException("filePath");
    }
    try {
        if (!filePath.startsWith("jar:")
                && !filePath.startsWith("file:")
                && !filePath.startsWith("zip:")
                && !filePath.startsWith("http:")
                && !filePath.startsWith("ftp:")) {

            return new File(filePath).toURI().toURL();
        }
        return new URL(filePath);
    } catch (MalformedURLException e) {
        // DO NOTHING...
    }
    return null;
}
 
Example #22
Source File: SimpleRequestBuilder.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns a {@link SimpleRequestBuilder} with the given intefaceKey as chosen request-interface.
 *
 * @param interfaceKey must not be null
 * @return simpleRequestBuilder with chosen interface
 * @throws NullArgumentException if the interfaceKey is null
 */
public static SimpleRequestBuilder buildNewRequest(String interfaceKey) throws NullArgumentException {
    if (builder == null) {
        builder = new SimpleRequestBuilder();
    }
    LOCK.lock();
    return builder.buildNewRequestInt(interfaceKey);
}
 
Example #23
Source File: SimpleRequestBuilder.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
private SimpleRequestBuilder buildNewRequestInt(String interfaceKey) {
    if (interfaceKey == null) {
        throw new NullArgumentException("interfaceKey");
    }
    request = "/" + interfaceKey + "/";
    classIsChosen = false;
    functionIsChosen = false;
    parameterIsAdded = false;
    return this;
}
 
Example #24
Source File: LdapConfig.java    From ranger with Apache License 2.0 5 votes vote down vote up
public String getLdapUrl() throws Throwable {
    String val = prop.getProperty(LGSYNC_LDAP_URL);
    if (val == null || val.trim().isEmpty()) {
        throw new NullArgumentException(LGSYNC_LDAP_URL);
    }
    return val;
}
 
Example #25
Source File: CookieUtils.java    From ache with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a new okhttp3 cookie from given cookie values
 * 
 * @param cookie
 * @return okhttp3 cookie
 * @throws NullArgumentException if argument cookie is null;
 */
public static okhttp3.Cookie asOkhttp3Cookie(Cookie cookie) {
    if (cookie == null) {
        throw new NullArgumentException("cookie can't be null");
    }
    Builder builder = new Builder();
    builder.name(cookie.getName());
    builder.value(cookie.getValue());
    builder.expiresAt(cookie.getExpiresAt());
    if (cookie.getDomain() != null && cookie.getDomain().startsWith(".")) {
        cookie.setDomain(cookie.getDomain().replaceFirst(".", ""));
    }
    if (cookie.getDomain() != null) {
        builder.domain(cookie.getDomain());
    } else {
        builder.domain("");
    }

    builder.path(cookie.getPath());
    if (cookie.isSecure()) {
        builder.secure();
    }
    if (cookie.isHttpOnly()) {
        builder.httpOnly();
    }
    return builder.build();
}
 
Example #26
Source File: ApiParameterMetadata.java    From springmvc-raml-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Default constructor that creates a metadata object from a Raml parameter
 * 
 * @param name
 *            The name of this parameter if different in annotation
 * @param param
 *            Java Parameter representation
 * @param codeModel
 *            JCodeModel to use
 */
public ApiParameterMetadata(String name, RamlAbstractParam param, JCodeModel codeModel) {
	super();

	if (param == null) {
		throw new NullArgumentException("param");
	}

	if (param instanceof RamlUriParameter) {
		this.resourceId = true;
	} else {
		this.resourceId = false;
	}
	this.nullable = !param.isRequired();

	this.name = name;
	this.displayName = param.getDisplayName();

	this.format = param.getFormat();
	this.type = SchemaHelper.mapSimpleType(param.getType(), this.format, param.getRawType());

	// If it's a repeatable parameter simply convert to an array of type
	if (param.isRepeat()) {
		this.type = Array.newInstance(this.type, 0).getClass();
	}

	this.example = StringUtils.hasText(param.getExample()) ? param.getExample() : null;
	this.setRamlParam(param);
	this.codeModel = codeModel;
}
 
Example #27
Source File: AbstractConfigurationProvider.java    From ymate-platform-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public void load(String cfgFileName) throws Exception {
    if (StringUtils.isBlank(cfgFileName)) {
        throw new NullArgumentException("cfgFileName");
    }
    __cfgFileName = cfgFileName;
    //
    ReentrantLock _locker = __LOCK.getLocker(__cfgFileName);
    try {
        _locker.lock();
        __doLoad(false);
    } finally {
        __LOCK.unlock(_locker);
    }
}
 
Example #28
Source File: CreatureLifeStats.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
/**
 * This method is called whenever caller wants to absorb creatures's HP
 *
 * @param value
 * @param attacker
 *            attacking creature or self
 * @return currentHp
 */
public int reduceHp(int value, @Nonnull Creature attacker) {
	if (attacker == null) {
		throw new NullArgumentException("attacker");
	}

	boolean isDied = false;
	hpLock.lock();
	try {
		if (!alreadyDead) {
			int newHp = this.currentHp - value;

			if (newHp < 0) {
				newHp = 0;
				this.currentMp = 0;
				alreadyDead = true;
				isDied = true;
			}
			this.currentHp = newHp;
		}
	}
	finally {
		hpLock.unlock();
	}
	if (value != 0) {
		onReduceHp();
	}
	if (isDied) {
		getOwner().getController().onDie(attacker);
	}
	return currentHp;
}
 
Example #29
Source File: AbstractSessionManager.java    From ymate-platform-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public void init(IServ owner) throws Exception {
    synchronized (__locker) {
        if (__server == null) {
            __server = doBuildServer(owner, __serverCfg, __codec);
            if (__server == null) {
                throw new NullArgumentException("server");
            }
        }
    }
    __server.start();
    if (__speedometer != null && !__speedometer.isStarted()) {
        __speedometer.start(new DefaultSpeedListener(__speedometer));
    }
    //
    if (__idleTimeInMillis > 0) {
        if (__idleChecker == null) {
            __idleChecker = new DefaultSessionIdleChecker<SESSION_WRAPPER, SESSION_ID, MESSAGE_TYPE>();
        }
        if (!__idleChecker.isInited()) {
            __idleChecker.init(this);
        }
        //
        __idleCheckExecutorService = ThreadUtils.newScheduledThreadPool(1, ThreadUtils.createFactory("SessionIdleChecker-"));
        __idleCheckExecutorService.scheduleWithFixedDelay(new Runnable() {
            @Override
            public void run() {
                __idleChecker.processIdleSession(__sessions, __idleTimeInMillis);
            }
        }, DateTimeUtils.SECOND, DateTimeUtils.SECOND, TimeUnit.MILLISECONDS);
    }
}
 
Example #30
Source File: CassandraSessionManagerPojo.java    From copper-engine with Apache License 2.0 5 votes vote down vote up
public CassandraSessionManagerPojo(final Session session, final Cluster cluster) {
    if (session == null)
        throw new NullArgumentException("session");
    if (cluster == null)
        throw new NullArgumentException("cluster");
    this.session = session;
    this.cluster = cluster;
}