Java Code Examples for org.datanucleus.util.StringUtils

The following examples show how to use org.datanucleus.util.StringUtils. 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
Source Project: seldon-server   Source File: ExternalRpcServer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public <ReqT, RespT> Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers,ServerCallHandler<ReqT, RespT> next) {
	logger.info("Call intercepted "+headers.toString());
	String token = headers.get(authKey);
	if (StringUtils.notEmpty(token))
	{
		try
		{
			logger.info("Token "+token);
			ConsumerBean consumer = resourceServer.validateResourceFromToken(token);
			logger.info("Setting call to client "+consumer.getShort_name());
			return new SeldonServerCallListener<ReqT>(next.startCall(call, headers),consumer.getShort_name(),this);
		}
		catch (APIException e)
		{
			logger.warn("API exception on getting token ",e);
			return next.startCall(call, headers);
		}
	}
	else
	{
		logger.warn("Empty token ignoring call");
		return next.startCall(call, headers);
	}
}
 
Example 2
Source Project: seldon-server   Source File: ExternalRpcServer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void classify(ClassificationRequest request, StreamObserver<ClassificationReply> responseObserver)
{
	final String client = clientThreadLocal.get();
	if (StringUtils.notEmpty(client))
	{
		clientThreadLocal.set(null);
		ClassificationReply reply = predictionService.predict(client, request);
		responseObserver.onNext(reply);
		responseObserver.onCompleted();
		predictLogger.log(client, request, reply);
	}
	else
	{
		logger.info("Failed to get token");
		responseObserver.onError(new StatusException(io.grpc.Status.PERMISSION_DENIED.withDescription("Could not determine client from oauth_token")));
	}
}
 
Example 3
Source Project: streamline   Source File: TopologyTestRunResource.java    License: Apache License 2.0 6 votes vote down vote up
private Response getEventsOfTestRunTopologyHistory(Long topologyId, Long historyId, String componentName,
                                                   SecurityContext securityContext) throws IOException {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER,
            Topology.NAMESPACE, topologyId, READ);

    File eventLogFile = getEventLogFile(topologyId, historyId);
    Stream<EventInformation> eventsStream = eventLogFileReader.loadEventLogFileAsStream(eventLogFile);

    if (!StringUtils.isEmpty(componentName)) {
        eventsStream = eventsStream.filter(event -> {
            String eventComponentName = event.getComponentName();
            return eventComponentName != null && eventComponentName.equals(componentName);
        });
    }

    return WSUtils.respondEntities(eventsStream.collect(toList()), OK);
}
 
Example 4
Source Project: incubator-sentry   Source File: CommandUtil.java    License: Apache License 2.0 6 votes vote down vote up
private static String createCmdForRoleAddOrDeleteGroup(String roleName,
String groups,
     boolean isAddGroup) {
   StringBuilder sb = new StringBuilder();
   if (isAddGroup) {
     sb.append("GRANT ROLE ");
   } else {
     sb.append("REVOKE ROLE ");
   }
   sb.append(roleName);
   if (isAddGroup) {
     sb.append(" TO ");
   } else {
     sb.append(" FROM ");
   }

   if (!StringUtils.isEmpty(groups)) {
     sb.append("GROUP ").append(groups);
   } else {
     sb = new StringBuilder("Missing group information.");
   }

   return sb.toString();
 }