/*
   *
   * (non-Javadoc)
   * @see org.springframework.data.repository.config.RepositoryConfigurationExtension#getRepositoryConfigurations(org.springframework.data.repository.config.RepositoryConfigurationSource, org.springframework.core.io.ResourceLoader, boolean)
   */
  public <T extends RepositoryConfigurationSource>
      Collection<RepositoryConfiguration<T>> getRepositoryConfigurations(
          T configSource, ResourceLoader loader, boolean strictMatchesOnly) {

    Assert.notNull(configSource);
    Assert.notNull(loader);

    Set<RepositoryConfiguration<T>> result = new HashSet<RepositoryConfiguration<T>>();

    for (BeanDefinition candidate : configSource.getCandidates(loader)) {

      RepositoryConfiguration<T> configuration =
          getRepositoryConfiguration(candidate, configSource);

      if (!strictMatchesOnly || configSource.usesExplicitFilters()) {
        result.add(configuration);
        continue;
      }

      Class<?> repositoryInterface = loadRepositoryInterface(configuration, loader);

      if (repositoryInterface == null || isStrictRepositoryCandidate(repositoryInterface)) {
        result.add(configuration);
      }
    }

    return result;
  }
Exemplo n.º 2
0
  @Override
  public PrivateCoachInfoDto getCoachProfile(String coachId) {
    StringBuffer sql = new StringBuffer();

    sql.append("SELECT ")
        .append("s.portrait_photo as portraitPhoto, ")
        .append("CONCAT (s.given_name, ' ' ,s.surname) AS nickname, ")
        .append(
            "(SELECT position_name FROM position_title WHERE position_code = m.position_title_code) as positionTitle, ")
        .append("(CASE (s.gender) when 'F' then 'F' when 'M' then 'M' else 'N' end) as sex, ")
        .append("s.date_of_birth as dateOfBirth, ")
        .append(
            "(SELECT code_display FROM sys_code where category = 'nationality' and code_value = s.nationality) as nationality, ")
        .append("c.personal_info as qualification, ")
        .append("c.speciality ")
        .append("FROM ")
        .append("user_master u ")
        .append("LEFT JOIN ")
        .append("staff_profile s ON (s.user_id = u.user_id) ")
        .append("LEFT JOIN ")
        .append("staff_master m ON (u.user_id = m.user_id) ")
        .append("LEFT JOIN ")
        .append("staff_coach_info c ON (c.user_id = u.user_id) ")
        .append("WHERE ")
        .append("u.user_id = '")
        .append(coachId)
        .append("'");

    List<PrivateCoachInfoDto> dtoList =
        this.getDtoBySql(sql.toString(), null, PrivateCoachInfoDto.class);
    Assert.notEmpty(dtoList, "No such coach");
    Assert.isTrue(dtoList.size() == 1, "More than one coach have the same coach id");
    return dtoList.get(0);
  }
  @Transactional
  @Rollback(true)
  @Test
  public void testUpdateWidgetInstance()
      throws IllegalArgumentException, IllegalAccessException, InvocationTargetException,
          SecurityException, NoSuchMethodException, IOException {
    ObjectMapper objectMapper = new ObjectMapper();

    DefaultWidgetInstance defaultWidgetInstance = prepareData(objectMapper);

    Map<String, String> responsMap = uIService.createOrUpdateWidgetInstance(defaultWidgetInstance);
    Assert.isTrue(
        responsMap.get("widgetInstanceAction").equals("update"),
        "The response action should have been 'updated'");

    Canvas retrievedPerishableCanvas = uIService.getCanvasByName("Perishable Goods Canvas");
    List<DefaultWidgetInstance> retrievedDefaultWidgetInstances =
        retrievedPerishableCanvas.getWidgetInstanceList();

    DefaultWidgetInstance retrievedRefaultWidgetInstance = retrievedDefaultWidgetInstances.get(0);
    Assert.isTrue(
        objectMapper
            .writeValueAsString(actualViewConfig)
            .equals(retrievedRefaultWidgetInstance.getActualViewConfig()));
  }
Exemplo n.º 4
0
  @Test
  public void test_ml_always_return_true() {

    Assert.isInstanceOf(BeanJarImpl.class, beanJar);
    String resp = beanJar.saludaJar("eduardo");
    Assert.isTrue("Hola eduardo Saludando desde jar".equals(resp));
  }
Exemplo n.º 5
0
 public void generateSong(OutputStream outputStream, String filterName)
     throws IOException, InvalidMidiDataException {
   Assert.notNull(outputStream);
   Assert.notNull(filterName);
   Assert.isTrue(isValidGenerator(filterName));
   generators.get(filterName).generateSong(outputStream);
 }
Exemplo n.º 6
0
 private File convertToFile(String folder) {
   Assert.notNull(folder, "LocalResourcePackFile pack points to an null folder");
   File result = new File(folder);
   Assert.isTrue(
       result.exists(), "LocalResourcePackFile pack points to an unknown folder : " + folder);
   return result;
 }
  /**
   * Get the CompassQuery.SortDirection for the given property and optional order/direction Map
   * entry
   *
   * @param property either CompassQuery.SortImplicitType.SCORE or a class property name (String)
   * @param options a Map containg
   * @return
   */
  public CompassQuery.SortDirection getSortDirection(Object property, Map options) {
    Assert.notNull(property, "sort property cannot be null");
    Assert.notNull(options, "options Map cannot be null");
    if (!options.containsKey(ORDER) && !options.containsKey(DIRECTION)) {
      return CompassQuery.SortDirection.AUTO;
    }

    Assert.isTrue(
        (options.containsKey(ORDER) && !options.containsKey(DIRECTION))
            || (!options.containsKey(ORDER) && options.containsKey(DIRECTION)),
        "Either specify a sort '" + ORDER + "' or '" + DIRECTION + "' or neither but not both");
    String value = (String) options.get(DIRECTION);
    if (value == null) {
      value = (String) options.get(ORDER);
    }
    Assert.isTrue(
        VALID_SORT_DIRECTION_VALUES.contains(value),
        "The sort order/direction '" + value + "' is not a valid value");
    return property.equals(CompassQuery.SortImplicitType.SCORE)
        ? value.equals("asc") || value.equals("reverse")
            ? CompassQuery.SortDirection.REVERSE
            : CompassQuery.SortDirection.AUTO
        : value.equals("asc") || value.equals("auto")
            ? CompassQuery.SortDirection.AUTO
            : CompassQuery.SortDirection.REVERSE;
  }
 public void declareRoles(String... roleNames) {
   Assert.notNull(roleNames, "Role names array must not be null");
   for (String roleName : roleNames) {
     Assert.hasLength(roleName, "Role name must not be empty");
     this.declaredRoles.add(roleName);
   }
 }
Exemplo n.º 9
0
  /**
   * Saves a user.
   *
   * @param user the user to save
   * @param currentUser the user performing the save operation
   */
  public void saveUser(User user, User currentUser) throws IOException {
    Assert.notNull(user);
    Assert.notNull(currentUser);

    ILockedRepository repo = null;
    try {
      repo = globalRepositoryManager.getProjectCentralRepository(REPOSITORY_NAME, false);
      Map<String, Object> userMap = new HashMap<String, Object>();
      userMap.put("loginName", user.getLoginName()); // $NON-NLS-1$
      userMap.put("password", user.getPassword()); // $NON-NLS-1$
      userMap.put("email", user.getEmail()); // $NON-NLS-1$
      userMap.put("disabled", Boolean.valueOf(user.isDisabled())); // $NON-NLS-1$
      if (!user.getOpenIds().isEmpty()) {
        userMap.put("openIds", user.getOpenIds()); // $NON-NLS-1$
      }

      Gson gson = new GsonBuilder().enableComplexMapKeySerialization().create();
      String json = gson.toJson(userMap);
      File workingDir = RepositoryUtil.getWorkingDir(repo.r());
      File workingFile = new File(workingDir, user.getLoginName() + USER_SUFFIX);
      FileUtils.write(workingFile, json, Charsets.UTF_8);

      Git git = Git.wrap(repo.r());
      git.add().addFilepattern(user.getLoginName() + USER_SUFFIX).call();
      PersonIdent ident = new PersonIdent(currentUser.getLoginName(), currentUser.getEmail());
      git.commit().setAuthor(ident).setCommitter(ident).setMessage(user.getLoginName()).call();
    } catch (GitAPIException e) {
      throw new IOException(e);
    } finally {
      Util.closeQuietly(repo);
    }
  }
Exemplo n.º 10
0
 /** 取得对象的主键值,辅助函数. */
 @SuppressWarnings("unchecked")
 public PK getId(Class<T> entityClass, T entity)
     throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
   Assert.notNull(entity);
   Assert.notNull(entityClass);
   return (PK) PropertyUtils.getProperty(entity, getIdName(entityClass));
 }
 @Override
 protected void onInit() throws Exception {
   messagingTemplate.afterPropertiesSet();
   Assert.notNull(this.configuration, "'configuration' can't be null");
   this.twitter = this.configuration.getTwitter();
   Assert.notNull(this.twitter, "'twitter' instance can't be null");
 }
Exemplo n.º 12
0
 /**
  * 分页查询函数,使用已设好查询条件与排序的<code>Criteria</code>.
  *
  * @param pageNo 页号,从1开始.
  * @return 含总记录数和当前页数据的Page对象.
  */
 @SuppressWarnings("unchecked")
 public Page<T> pagedQuery(Criteria criteria, int pageNo, int pageSize) {
   Assert.notNull(criteria);
   Assert.isTrue(pageNo >= 1, "pageNo should start from 1");
   CriteriaImpl impl = (CriteriaImpl) criteria;
   // 先把Projection和OrderBy条件取出来,清空两者来执行Count操作
   Projection projection = impl.getProjection();
   List<CriteriaImpl.OrderEntry> orderEntries;
   try {
     orderEntries = (List) BeanUtils.forceGetProperty(impl, "orderEntries");
     BeanUtils.forceSetProperty(impl, "orderEntries", new ArrayList());
   } catch (Exception e) {
     throw new InternalError(" Runtime Exception impossibility throw ");
   }
   // 执行查询
   long totalCount = (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
   // 将之前的Projection和OrderBy条件重新设回去
   criteria.setProjection(projection);
   if (projection == null) {
     criteria.setResultTransformer(CriteriaSpecification.ROOT_ENTITY);
   }
   try {
     BeanUtils.forceSetProperty(impl, "orderEntries", orderEntries);
   } catch (Exception e) {
     throw new InternalError(" Runtime Exception impossibility throw ");
   }
   // 返回分页对象
   if (totalCount < 1) return new Page<T>();
   int startIndex = Page.getStartOfPage(pageNo, pageSize);
   ;
   List<T> list = criteria.setFirstResult(startIndex).setMaxResults(pageSize).list();
   return new Page(startIndex, totalCount, pageSize, list);
 }
  @Override
  public void executeRule(final TableInteRule rule) throws RuleException {
    Assert.notNull(rule, "整合规则对象rule为空");
    Assert.notNull(rule.getRuleId(), "整合规则对象主键Id的rule.ruleid为空");
    Assert.notNull(
        rule.getRuleType(), "整合规则对象规则类型rule.ruleType为空,可选值为['clean','rebuild','unique','merge']");
    try {
      ruleExecuter.execute(
          new RuleSetter() {
            @Override
            public String getRuleId() {
              return rule.getRuleId();
            }

            @Override
            public String getRuleType() {
              return rule.getRuleType();
            }
          });
    } catch (RuleException e) {
      // 李广彬:2014-7-11 新加入【不管是java出错 还是存储过程 将整合日志状态更新为失败状态】
      Map<String, Object> params = new HashMap<String, Object>();
      params.put("ruleId", rule.getRuleId());
      List<DataInteLog> items = this.dataInteLog.find(params);
      if (items.size() > 0) {
        DataInteLog dil = items.get(0);
        dil.setOpStats(DataLogState.LOG_FAILURE.getState());
        this.dataInteLog.update(dil);
      }
      throw e;
    }
  }
Exemplo n.º 14
0
 public JythonScriptFactory(String scriptSourceLocator, Class[] scriptInterfaces) {
   Assert.hasText(scriptSourceLocator);
   Assert.notEmpty(scriptInterfaces);
   this.scriptSourceLocator = scriptSourceLocator;
   this.scriptInterfaces = scriptInterfaces;
   this.arguments = null;
 }
Exemplo n.º 15
0
  public static UserAccount getPrincipal() {
    UserAccount result;
    SecurityContext context;
    Authentication authentication;
    Object principal;

    // If the asserts in this method fail, then you're
    // likely to have your Tomcat's working directory
    // corrupt. Please, clear your browser's cache, stop
    // Tomcat, update your Maven's project configuration,
    // clean your project, clean Tomcat's working directory,
    // republish your project, and start it over.

    context = SecurityContextHolder.getContext();
    Assert.notNull(context);
    authentication = context.getAuthentication();
    Assert.notNull(authentication);
    principal = authentication.getPrincipal();
    Assert.isTrue(principal instanceof UserAccount);
    result = (UserAccount) principal;
    Assert.notNull(result);
    Assert.isTrue(result.getId() != 0);

    return result;
  }
Exemplo n.º 16
0
  /**
   * Saves a role.
   *
   * @param role the role to save
   * @param currentUser the user performing the save operation
   */
  public void saveRole(Role role, User currentUser) throws IOException {
    Assert.notNull(role);
    Assert.notNull(currentUser);

    ILockedRepository repo = null;
    try {
      repo = globalRepositoryManager.getProjectCentralRepository(REPOSITORY_NAME, false);

      Map<String, Object> roleMap = new HashMap<String, Object>();
      roleMap.put("name", role.getName()); // $NON-NLS-1$
      Set<String> permissions = Sets.newHashSet();
      for (Permission permission : role.getPermissions()) {
        permissions.add(permission.name());
      }
      roleMap.put("permissions", permissions); // $NON-NLS-1$

      Gson gson = new GsonBuilder().enableComplexMapKeySerialization().create();
      String json = gson.toJson(roleMap);
      File workingDir = RepositoryUtil.getWorkingDir(repo.r());
      File workingFile = new File(workingDir, role.getName() + ROLE_SUFFIX);
      FileUtils.write(workingFile, json, Charsets.UTF_8);

      Git git = Git.wrap(repo.r());
      git.add().addFilepattern(role.getName() + ROLE_SUFFIX).call();
      PersonIdent ident = new PersonIdent(currentUser.getLoginName(), currentUser.getEmail());
      git.commit().setAuthor(ident).setCommitter(ident).setMessage(role.getName()).call();
    } catch (GitAPIException e) {
      throw new IOException(e);
    } finally {
      Util.closeQuietly(repo);
    }
  }
Exemplo n.º 17
0
  // @Async should be async
  public String connectPeer(Peer peer, String fingerprint) {
    Assert.notNull(peer);
    Assert.notNull(fingerprint);

    // call webservice
    return null;
  }
Exemplo n.º 18
0
  public void renameRole(String roleName, String newRoleName, User currentUser) throws IOException {
    Assert.hasLength(roleName);
    Assert.hasLength(newRoleName);
    Assert.notNull(currentUser);
    // check that role exists by trying to load it
    getRole(roleName);
    // check that new role does not exist by trying to load it
    try {
      getRole(newRoleName);
      throw new IllegalArgumentException("role already exists: " + newRoleName); // $NON-NLS-1$
    } catch (RoleNotFoundException e) {
      // okay
    }

    log.info("renaming role: {} -> {}", roleName, newRoleName); // $NON-NLS-1$

    ILockedRepository repo = null;
    try {
      repo = globalRepositoryManager.getProjectCentralRepository(REPOSITORY_NAME, false);

      File workingDir = RepositoryUtil.getWorkingDir(repo.r());

      File file = new File(workingDir, roleName + ROLE_SUFFIX);
      File newFile = new File(workingDir, newRoleName + ROLE_SUFFIX);
      FileUtils.copyFile(file, newFile);
      Git git = Git.wrap(repo.r());
      git.rm().addFilepattern(roleName + ROLE_SUFFIX).call();
      git.add().addFilepattern(newRoleName + ROLE_SUFFIX).call();

      List<String> users = listUsers(repo);
      users.add(ANONYMOUS_USER_LOGIN_NAME);
      for (String user : users) {
        List<RoleGrantedAuthority> authorities = getUserAuthorities(user, repo);
        Set<RoleGrantedAuthority> newAuthorities = Sets.newHashSet();
        for (Iterator<RoleGrantedAuthority> iter = authorities.iterator(); iter.hasNext(); ) {
          RoleGrantedAuthority rga = iter.next();
          if (rga.getRoleName().equals(roleName)) {
            RoleGrantedAuthority newRga = new RoleGrantedAuthority(rga.getTarget(), newRoleName);
            newAuthorities.add(newRga);
            iter.remove();
          }
        }
        if (!newAuthorities.isEmpty()) {
          authorities.addAll(newAuthorities);
          saveUserAuthorities(user, Sets.newHashSet(authorities), repo, currentUser, false);
        }
      }

      PersonIdent ident = new PersonIdent(currentUser.getLoginName(), currentUser.getEmail());
      git.commit()
          .setAuthor(ident)
          .setCommitter(ident)
          .setMessage("rename role " + roleName + " to " + newRoleName) // $NON-NLS-1$ //$NON-NLS-2$
          .call();
    } catch (GitAPIException e) {
      throw new IOException(e);
    } finally {
      Util.closeQuietly(repo);
    }
  }
 /** 按属性查找唯一对象 */
 @Override
 @SuppressWarnings("unchecked")
 public T findUniqueByProperty(String property, Object value) {
   Assert.hasText(property);
   Assert.notNull(value);
   return (T) createCriteria(Restrictions.eq(property, value)).uniqueResult();
 }
 public void uploadApplication(
     String appName, ApplicationArchive archive, UploadStatusCallback callback)
     throws IOException {
   Assert.notNull(appName, "AppName must not be null");
   Assert.notNull(archive, "Archive must not be null");
   if (callback == null) {
     callback = UploadStatusCallback.NONE;
   }
   CloudResources knownRemoteResources = getKnownRemoteResources(archive);
   callback.onCheckResources();
   callback.onMatchedFileNames(knownRemoteResources.getFilenames());
   UploadApplicationPayload payload = new UploadApplicationPayload(archive, knownRemoteResources);
   callback.onProcessMatchedResources(payload.getTotalUncompressedSize());
   HttpEntity<?> entity = generatePartialResourceRequest(payload, knownRemoteResources);
   String url = getUrl("apps/{appName}/application");
   try {
     getRestTemplate().put(url, entity, appName);
   } catch (HttpServerErrorException hsee) {
     if (HttpStatus.INTERNAL_SERVER_ERROR.equals(hsee.getStatusCode())) {
       // this is for supporting legacy Micro Cloud Foundry 1.1 and older
       uploadAppUsingLegacyApi(url, entity, appName);
     } else {
       throw hsee;
     }
   }
 }
  /**
   * Invokes all {@link ResourceProcessor} instances registered for the type of the given value and
   * reference type.
   *
   * @param value must not be {@literal null}.
   * @param referenceType must not be {@literal null}.
   * @return
   */
  @SuppressWarnings("unchecked")
  public <T extends ResourceSupport> T invokeProcessorsFor(T value, ResolvableType referenceType) {

    Assert.notNull(value, "Value must not be null!");
    Assert.notNull(referenceType, "Reference type must not be null!");

    // For Resources implementations, process elements first
    if (ResourceProcessorHandlerMethodReturnValueHandler.RESOURCES_TYPE.isAssignableFrom(
        referenceType)) {

      Resources<?> resources = (Resources<?>) value;
      ResolvableType elementTargetType =
          ResolvableType.forClass(Resources.class, referenceType.getRawClass()).getGeneric(0);
      List<Object> result = new ArrayList<Object>(resources.getContent().size());

      for (Object element : resources) {

        ResolvableType elementType = ResolvableType.forClass(element.getClass());

        if (!getRawType(elementTargetType).equals(elementType.getRawClass())) {
          elementTargetType = elementType;
        }

        result.add(invokeProcessorsFor(element, elementTargetType));
      }

      ReflectionUtils.setField(
          ResourceProcessorHandlerMethodReturnValueHandler.CONTENT_FIELD, resources, result);
    }

    return (T) invokeProcessorsFor((Object) value, referenceType);
  }
Exemplo n.º 22
0
  public void createWorkspaceWithTags(
      String workspaceName, String description, String username, String origin, String tags) {
    Assert.notNull(workspaceName);
    Assert.notNull(username);
    if (checkNameAvailability(workspaceName, username)) {
      Workspace ws = new Workspace();
      ws.setDownloads(0);
      ws.setDescription(description);
      ws.setLastMod(Calendar.getInstance().getTime());
      ws.setLaunches(0);
      ws.setWsVersion(1);
      ws.setName(workspaceName);
      UserAccount ua = uar.findByUsername(username);
      Researcher rese = researcherRepository.findByUserAccountId(ua.getId());
      ws.setOwner(rese);

      String[] array = tags.split("\\s+");
      Collection<Tag> wsTags = new ArrayList<>();

      for (String a : array) {
        if (a.length() > 1) {
          if (tagRepository.findByName(a) != null) wsTags.add(tagRepository.findByName(a));
          else {
            Tag newTag = new Tag();
            newTag.setName(a);
            wsTags.add(tagRepository.save(newTag));
          }
        }
      }
      ws.setWorkspaceTags(wsTags);

      workspaceRepository.saveAndFlush(ws);
    }
  }
Exemplo n.º 23
0
  private Server startWebServer(File webAppContextPath, String applicationContext) {
    Assert.isTrue(
        webAppContextPath.exists(),
        "The context path you have specified does not exist: " + webAppContextPath);
    Assert.notNull(applicationContext, "You must specify the context path of the application");

    int startPort = 0;
    if (this.port != null) {
      startPort = this.port;
    }

    if (!applicationContext.startsWith("/")) {
      applicationContext = "/" + applicationContext;
    }

    Server server = new Server(startPort);
    try {
      WebAppContext webAppContext =
          new WebAppContext(webAppContextPath.getCanonicalPath(), applicationContext);
      setUpClassPath(webAppContext);
      server.setHandler(webAppContext);
      server.start();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    return server;
  }
Exemplo n.º 24
0
 @Transactional
 public void addSystemUser(SystemUser systemUser) {
   Assert.hasText(systemUser.getEmpId(), "empId不能为空!");
   Assert.hasText(systemUser.getLastName(), "lastName不能为空!");
   Assert.hasText(systemUser.getNickName(), "nickName不能为空!");
   systemUserDao.addSystemUser(systemUser);
 }
 @Override
 public void afterPropertiesSet() throws ServletException {
   super.afterPropertiesSet();
   Assert.notNull(cacheOperationSource, "cacheOperationSource is required");
   Assert.notNull(expressionEvaluator, "expressionEvaluator is required");
   Assert.notNull(keyGenerator, "keyGenerator is required");
 }
Exemplo n.º 26
0
 public void updateSystemUser(SystemUser systemUser) {
   Assert.notNull(systemUser.getId(), "id数据不能为空");
   Assert.hasText(systemUser.getEmpId(), "empId不能为空!");
   Assert.hasText(systemUser.getLastName(), "lastName不能为空!");
   Assert.hasText(systemUser.getNickName(), "nickName不能为空!");
   systemUserDao.updateSystemUser(systemUser);
 }
  @Ignore
  @Test
  public void testGetSearchUserGridWidgetDefinitionWithoutAuthentication()
      throws IllegalArgumentException, IllegalAccessException, InvocationTargetException,
          SecurityException, NoSuchMethodException, IOException {
    AbstractLicensableWidget searchUserGridWidget =
        uIService.getWidgetDefinition(SearchUserGridWidgetName);
    SecurityContext securityContext = SecurityContextHolder.getContext();
    securityContext.setAuthentication(null);
    Assert.notNull(searchUserGridWidget);
    Assert.notNull(searchUserGridWidget.getDataURL());

    Assert.isTrue(
        searchUserGridWidget.getActionConfig().getActionConfig().size() == 2,
        "Search user grid widget action config does not have expected # of permissions values");

    Assert.isTrue(
        searchUserGridWidget
                .getActionConfig()
                .getActionConfig()
                .get("widget-actions")
                .get(new Permission("delete-user"))
            == Boolean.FALSE,
        "Search user grid widget action config does not have delete-user permission false");

    Assert.isTrue(
        searchUserGridWidget
                .getActionConfig()
                .getActionConfig()
                .get("widget-actions")
                .get(new Permission("disable-user"))
            == Boolean.FALSE,
        "Search user grid widget action config does not have disable-user permission false");
  }
Exemplo n.º 28
0
  @SuppressWarnings("unchecked")
  @HideFromClient
  private <T extends Resource> T getResource(String name, Class<T> resourceType) {
    Assert.notNull(name, "Name must not be null");
    Assert.notNull(resourceType, "ResourceType must not be null");

    Folder root;
    String resourceName;
    if (name.equals("/common")) {
      root = this.fileSystem.getCommonFolder();
      resourceName = "";
    } else if (name.startsWith("/common/")) {
      root = this.fileSystem.getCommonFolder();
      resourceName = name.substring("/common/".length());
    } else {
      root = this.projectManager.getCurrentProject().getRootFolder();
      resourceName = name;
    }

    if (resourceName.length() == 0) {
      Assert.isInstanceOf(resourceType, root);
      return (T) root;
    }

    return root.jail().get(resourceName, resourceType);
  }
 protected void assertUri(URI uri) {
   Assert.notNull(uri, "uri must not be null");
   String scheme = uri.getScheme();
   Assert.isTrue(
       scheme != null && ("ws".equals(scheme) || "wss".equals(scheme)),
       "Invalid scheme: " + scheme);
 }
  /**
   * Specify the number of concurrent consumers to create. Default is 1.
   *
   * <p>Raising the number of concurrent consumers is recommended in order to scale the consumption
   * of messages coming in from a queue. However, note that any ordering guarantees are lost once
   * multiple consumers are registered. In general, stick with 1 consumer for low-volume queues.
   * Cannot be less than {@link #maxConcurrentConsumers} (if set).
   *
   * @see #setMaxConcurrentConsumers(int)
   * @param concurrentConsumers the minimum number of consumers to create.
   */
  public void setConcurrentConsumers(final int concurrentConsumers) {
    Assert.isTrue(concurrentConsumers > 0, "'concurrentConsumers' value must be at least 1 (one)");
    if (this.maxConcurrentConsumers != null) {
      Assert.isTrue(
          concurrentConsumers <= this.maxConcurrentConsumers,
          "'concurrentConsumers' cannot be more than 'maxConcurrentConsumers'");
    }
    synchronized (consumersMonitor) {
      if (logger.isDebugEnabled()) {
        logger.debug(
            "Changing consumers from " + this.concurrentConsumers + " to " + concurrentConsumers);
      }
      int delta = this.concurrentConsumers - concurrentConsumers;
      this.concurrentConsumers = concurrentConsumers;
      if (isActive() && this.consumers != null) {
        if (delta > 0) {
          Iterator<Entry<BlockingQueueConsumer, Boolean>> entryIterator =
              consumers.entrySet().iterator();
          while (entryIterator.hasNext() && delta > 0) {
            Entry<BlockingQueueConsumer, Boolean> entry = entryIterator.next();
            if (entry.getValue()) {
              BlockingQueueConsumer consumer = entry.getKey();
              consumer.setQuiesce(this.shutdownTimeout);
              this.consumers.put(consumer, false);
              delta--;
            }
          }

        } else {
          addAndStartConsumers(-delta);
        }
      }
    }
  }