public RaptNotSupportedException(String msg) { super(IDGenerator.getUUID(), HttpURLConnection.HTTP_INTERNAL_ERROR, msg); } }
public RaptNotLoggedInException(String msg) { super(IDGenerator.getUUID(), HttpURLConnection.HTTP_UNAUTHORIZED, msg); } }
private String getUniqueId() { return IDGenerator.getUUID(10); }
@Override public synchronized void setConfig(Map<String, String> config) { db = new HashMap<String, String>(); id = IDGenerator.getUUID(); }
public static String getUUIDForDisplayName() { return getUUID().replace("-", ""); }
/** * Do not use hard codes strings. Use rapture.kernel.Messages.getMessage * and put the message in the property file. This ensures consistent error messages * across the product and will ease localization efforts if the need ever arises. */ public static RaptureException create(Integer status, String message, Throwable cause) { String id = IDGenerator.getUUID(); RaptureException e = new RaptureException(id, status, message, cause); if (log.isTraceEnabled()) { log.trace(ExceptionToString.format(e)); } return e; }
public static RaptureException create(Integer status, Formattable message, Throwable cause) { String id = IDGenerator.getUUID(); RaptureException e = new RaptureException(id, status, message.format(), cause); if (log.isTraceEnabled()) { log.trace(ExceptionToString.format(e)); } return e; }
public void initTask() { status = new PipelineTaskStatus(); this.taskId = IDGenerator.getUUID(); status.setTaskId(taskId); } }
@Override public ReflexValue evaluate(IReflexDebugger debugger, Scope scope) { debugger.stepStart(this, scope); String uuid = IDGenerator.getUUID().replaceAll("-", ""); ReflexValue retVal = new ReflexValue(uuid); debugger.stepEnd(this, retVal, scope); return retVal; } }
/** * Check the config for a passed api user to run the kernel as. If so, check that it is in fact a valid API user, and if it is, set the KernelUser in the * ContextFactory to this user. */ public void validateKernelUser() { if (!ConfigLoader.getConf().KernelUser.isEmpty()) { log.debug("Retrieving information for kernel api user passed - " + ConfigLoader.getConf().KernelUser); RaptureUser rootUser = getUserViaName(ConfigLoader.getConf().KernelUser); if (rootUser != null && rootUser.getHasRoot()) { log.debug("User is has root, using this user for kernel activity for this process"); ContextFactory.setKernelUser(rootUser.getUsername(), IDGenerator.getUUID()); } else { log.error("User is not found or does not have root permissions - will not use this user for kernel activity"); } } }
/** * These all manipulate a ReflexREPLSession object */ @Override public String createREPLSession(CallingContext context) { ReflexREPLSession session = new ReflexREPLSession(); session.setId(IDGenerator.getUUID()); session.setLastSeen(new Date()); session.setVars(new ArrayList<REPLVariable>()); ReflexREPLSessionStorage.add(session, context.getUser(), "Created session"); return session.getId(); }
private static void setupMachineID() { RaptureServerInfo info = INSTANCE.environment.getThisServer(ContextFactory.getKernelUser()); if (info == null) { log.info("This server does not have a name, setting one up"); info = new RaptureServerInfo(); info.setName("Rapture"); info.setServerId(IDGenerator.getUUID()); log.info("Saving server ID " + info.getServerId()); INSTANCE.environment.setThisServer(ContextFactory.getKernelUser(), info); } else { log.info(String.format("This server is %s ( %s )", info.getServerId(), info.getName())); } }
/** * Create the standard fanout exchange configuration, and fill it in so it * contains an anonymous queue for this server. This will allow a server to * bind to the fanout exchange and receive broadcast messages * * @param category * @return */ public static RaptureExchange createStandardFanout() { RaptureExchange xFanout = new RaptureExchange(); xFanout.setName(PipelineConstants.FANOUT_EXCHANGE); xFanout.setExchangeType(RaptureExchangeType.FANOUT); xFanout.setDomain(PipelineConstants.DEFAULT_EXCHANGE_DOMAIN); List<RaptureExchangeQueue> qsFanout = new LinkedList<RaptureExchangeQueue>(); RaptureExchangeQueue qBroadcast = new RaptureExchangeQueue(); qBroadcast.setName(PipelineConstants.ANONYMOUS_PREFIX + IDGenerator.getUUID()); qBroadcast.setRouteBindings(new ArrayList<String>()); qsFanout.add(qBroadcast); xFanout.setQueueBindings(qsFanout); return xFanout; }
/** * Create the standard direct exchange configuration, and fill it in so it * contains the 1. category-specific broadcast and 2. category-specific * load-balancer for this category. This will allow this server to receive * these types of messages * * @param category * @return */ public static RaptureExchange createStandardDirect(String category) { RaptureExchange xDirect = new RaptureExchange(); xDirect.setName(PipelineConstants.DIRECT_EXCHANGE); xDirect.setExchangeType(RaptureExchangeType.DIRECT); xDirect.setDomain(PipelineConstants.DEFAULT_EXCHANGE_DOMAIN); List<RaptureExchangeQueue> qsDirect = new LinkedList<RaptureExchangeQueue>(); RaptureExchangeQueue qCategoryBroadcast = new RaptureExchangeQueue(); qCategoryBroadcast.setName(PipelineConstants.ANONYMOUS_PREFIX + IDGenerator.getUUID()); qCategoryBroadcast.setRouteBindings(ImmutableList.<String> of(createBroadcastRoutingKey(category))); qsDirect.add(qCategoryBroadcast); RaptureExchangeQueue qLoadBalance = new RaptureExchangeQueue(); qLoadBalance.setName(category); qLoadBalance.setRouteBindings(ImmutableList.<String> of(createLoadBalancingRoutingKey(category))); qsDirect.add(qLoadBalance); xDirect.setQueueBindings(qsDirect); return xDirect; }
@Override public RaptureApplicationStatus runApplication(CallingContext context, String appName, String queueName, Map<String, String> parameterInput, Map<String, String> parameterOutput) { RaptureApplicationStatus status = new RaptureApplicationStatus(); status.setAppName(appName); status.setInstanceId(IDGenerator.getUUID()); status.setInputConfig(parameterInput); status.setOutputConfig(parameterOutput); status.setStatus(RaptureApplicationStatusStep.INITIATED); return lowerInitiateApp(context, status); }
@Override public String publishNotification(CallingContext context, String referenceId, String content, String contentType) { String uuid = IDGenerator.getUUID(); NotificationInfo info = new NotificationInfo(); info.setId(uuid); info.setWho(context.getUser()); info.setContent(content); info.setReference(referenceId); info.setEpoch(currentEpoch); info.setWhen(new Date()); info.setContentType(contentType); info.setKernelId(context.getContext()); currentEpoch++; notifications.put(info.getEpoch(), info); notificationsById.put(info.getId(), info); return uuid; }
@Override public RaptureApplicationStatus runCustomApplication(CallingContext context, String appName, String queueName, Map<String, String> parameterInput, Map<String, String> parameterOutput, String customApplicationPath) { RaptureApplicationStatus status = new RaptureApplicationStatus(); status.setAppName(appName); status.setInstanceId(IDGenerator.getUUID()); status.setInputConfig(parameterInput); status.setOutputConfig(parameterOutput); status.setStatus(RaptureApplicationStatusStep.INITIATED); status.setOverrideApplicationPath(customApplicationPath); return lowerInitiateApp(context, status); }
@Override public DocumentWithMeta addDocument(String key, String value, String user, String comment, boolean mustBeNew) { String context = IDGenerator.getUUID(); LockHandle lockHandle = lockHandler.acquireLock(context, DEFAULT_STAGE, 5, 5); if (lockHandle != null) { try { // Create a new stage to be consistent createStage(DEFAULT_STAGE); addToStage(DEFAULT_STAGE, key, value, mustBeNew); commitStage(DEFAULT_STAGE, user, comment); cacheKeyStore.put(key, value); } finally { lockHandler.releaseLock(context, DEFAULT_STAGE, lockHandle); } } else { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Could not get lock for write"); } return null; // Deprecated repository so don't do anything special here. }
@Override public RaptureUser generateApiUser(CallingContext context, String prefix, String description) { // Special treatment of prefix "debug" checkParameter("Prefix", prefix); //$NON-NLS-1$ String userId = "zz-" + prefix; //$NON-NLS-1$ if (!prefix.equals("debug")) { //$NON-NLS-1$ userId = prefix + "-" + IDGenerator.getUUID(); //$NON-NLS-1$ } RaptureUser usr = new RaptureUser(); usr.setUsername(userId); usr.setDescription(description); usr.setHashPassword(""); //$NON-NLS-1$ usr.setInactive(false); usr.setApiKey(true); RaptureUserStorage.add(usr, context.getUser(), adminMessageCatalog.getMessage("CreatedApi").toString()); //$NON-NLS-1$ return usr; }
@Override public void addDocuments(List<String> keys, String value, String user, String comment) { // We want to add these displayNames, but point them to the same // document content String context = IDGenerator.getUUID(); LockHandle lockHandle = lockHandler.acquireLock(context, DEFAULT_STAGE, 5, 5); if (lockHandle != null) { try { // Create a new stage to be consistent createStage(DEFAULT_STAGE); addToStage(DEFAULT_STAGE, keys, value, false); commitStage(DEFAULT_STAGE, user, comment); for (String x : keys) { cacheKeyStore.put(x, value); } } finally { lockHandler.releaseLock(context, DEFAULT_STAGE, lockHandle); } } else { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Could not get lock for write"); } }