예제 #1
0
  private void setTitle(HttpServletRequest request, Portal portal, String titleName)
      throws Exception {
    Resource resource = RequestUtils.getResource(request);
    ResourceGroup group = RequestUtils.getResourceGroupIfExists(request);
    ResourceType type;
    if (resource != null) {
      // resource alert definition
      type = resource.getResourceType();
    } else if (group != null) {
      // group alert definition
      type = group.getResourceType();
    } else {
      // template alert definition
      type = RequestUtils.getResourceType(request);
    }

    ResourceCategory category = type.getCategory();

    titleName = StringUtil.replace(titleName, "platform", category.toString().toLowerCase());

    portal.setName(titleName);

    // if there's an alert definition available, set our second
    // title parameter to its name
    try {
      AlertDefinition alertDef = AlertDefUtil.getAlertDefinition(request);
      request.setAttribute(Constants.TITLE_PARAM2_ATTR, alertDef.getName());
    } catch (ParameterNotFoundException e) {
      // it's okay
      log.trace("couldn't find alert definition: " + e.getMessage());
    }
  }
    public PageList<Resource> fetchDataForPage(PageControl pc) {
      Subject subject = EnterpriseFacesContextUtility.getSubject();
      ResourceManagerLocal manager = LookupUtil.getResourceManager();
      int repoId = Integer.parseInt(FacesContextUtility.getRequiredRequestParameter("id"));
      String search =
          FacesContextUtility.getOptionalRequestParameter(
              "repoUnsubscriptionsListForm:searchStringFilter");
      String category =
          FacesContextUtility.getOptionalRequestParameter(
              "repoUnsubscriptionsListForm:searchCategoryFilter");
      ResourceCategory categoryEnum = ResourceCategory.PLATFORM;

      if (search != null && search.trim().equals("")) {
        search = null;
      }

      if (category != null) {
        categoryEnum = ResourceCategory.valueOf(category);
      }

      PageList<Resource> results =
          manager.findAvailableResourcesForRepo(subject, repoId, search, categoryEnum, pc);

      // PageList<ResourceComposite> results = manager.findResourceComposites(subject, categoryEnum,
      // null, null, search, pc);

      return results;
    }
 @Override
 public ResourceType findResourceType(String name, String pluginType, String resourceCategory) {
   ResourceTypeCriteria crit = new ResourceTypeCriteria();
   crit.addFilterName(name);
   crit.addFilterCategory(ResourceCategory.valueOf(resourceCategory));
   crit.addFilterPluginName(pluginType);
   crit.fetchMetricDefinitions(true);
   crit.setStrict(true);
   List<ResourceType> resourceTypes =
       resourceTypeManagerRemote.findResourceTypesByCriteria(baseRemote.getSubject(), crit);
   if (resourceTypes.size() > 1) {
     throw new IllegalStateException(
         "More than one resource type found. Expected only one resource type");
   }
   return resourceTypes.get(0);
 }