public String deleteSelectedRepoSubscriptions() {
    Subject subject = EnterpriseFacesContextUtility.getSubject();
    String[] selected = getSelectedRepoSubscriptions();
    int repoId = Integer.valueOf(FacesContextUtility.getRequiredRequestParameter("id"));
    int[] resourceIds = getIntegerArray(selected);

    if ((resourceIds != null) && (resourceIds.length > 0)) {
      try {
        RepoManagerLocal manager = LookupUtil.getRepoManagerLocal();

        // TODO: we should have a SLSB method that takes a list of resources
        for (int resourceId : resourceIds) {
          manager.unsubscribeResourceFromRepos(subject, resourceId, new int[] {repoId});
        }

        FacesContextUtility.addMessage(
            FacesMessage.SEVERITY_INFO,
            "Unsubscribed [" + resourceIds.length + "] resources from repository");
      } catch (Exception e) {
        FacesContextUtility.addMessage(
            FacesMessage.SEVERITY_ERROR,
            "Failed to unsubscribe one or more resources from repository",
            e);
      }
    }

    return "success";
  }
  public String associateSelectedContentSourcesWithRepo() {
    Subject subject = EnterpriseFacesContextUtility.getSubject();
    String[] selected = getSelectedRepoUnsubscriptions();
    int repoId = Integer.valueOf(FacesContextUtility.getRequiredRequestParameter("id"));
    int[] resourceIds = getIntegerArray(selected);

    if ((resourceIds != null) && (resourceIds.length > 0)) {
      try {
        RepoManagerLocal manager = LookupUtil.getRepoManagerLocal();

        for (int resourceId : resourceIds) {
          manager.subscribeResourceToRepos(subject, resourceId, new int[] {repoId});
        }

        FacesContextUtility.addMessage(
            FacesMessage.SEVERITY_INFO,
            "Subscribed [" + resourceIds.length + "] resources with repository");
      } catch (Exception e) {
        FacesContextUtility.addMessage(
            FacesMessage.SEVERITY_ERROR,
            "Failed to subscribe one or more resources with repository",
            e);
      }
    }

    return "success";
  }
    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;
    }
    public PageList<Resource> fetchDataForPage(PageControl pc) {
      Subject subject = EnterpriseFacesContextUtility.getSubject();
      int id = Integer.valueOf(FacesContextUtility.getRequiredRequestParameter("id"));
      RepoManagerLocal manager = LookupUtil.getRepoManagerLocal();

      PageList<Resource> results = manager.findSubscribedResources(subject, id, pc);
      return results;
    }
Exemplo n.º 5
0
 public Agent getAgent() {
   if (agent == null) {
     hasPermission();
     int agentId = FacesContextUtility.getRequiredRequestParameter("agentId", Integer.class);
     agent = agentManager.getAgentByID(agentId);
   }
   return agent;
 }
    @Override
    public PageList<Server> fetchPage(PageControl pc) {
      int affinityGroupId =
          FacesContextUtility.getRequiredRequestParameter("affinityGroupId", Integer.class);
      PageList<Server> results =
          affinityGroupManager.getServerMembers(getSubject(), affinityGroupId, pc);

      return results;
    }
  public String unsubscribeServers() {
    Subject subject = EnterpriseFacesContextUtility.getSubject();
    String[] selectedServerIdStrings =
        FacesContextUtility.getRequest().getParameterValues("selectedServersToUnsubscribe");

    // Parse the server IDs to ints
    Integer[] selectedServerIds = new Integer[selectedServerIdStrings.length];
    for (int ii = 0; ii < selectedServerIdStrings.length; ii++) {
      selectedServerIds[ii] = Integer.parseInt(selectedServerIdStrings[ii]);
    }

    // Update the group
    affinityGroupManager.removeServersFromGroup(subject, selectedServerIds);

    return "successOrFailure";
  }
  private void loadTree() {
    int searchId;
    Resource currentResource = EnterpriseFacesContextUtility.getResourceIfExists();
    if (currentResource == null) {
      searchId = Integer.parseInt(FacesContextUtility.getOptionalRequestParameter("parent"));
    } else {
      searchId = currentResource.getId();
    }

    Subject user = EnterpriseFacesContextUtility.getSubject();

    long start = System.currentTimeMillis();
    long monitorId = HibernatePerformanceMonitor.get().start();
    Resource rootResource = resourceManager.getRootResourceForResource(searchId);
    long end = System.currentTimeMillis();
    HibernatePerformanceMonitor.get().stop(monitorId, "ResourceTree root resource");
    log.debug("Found root resource in " + (end - start));

    Agent agent =
        agentManager.getAgentByResourceId(
            LookupUtil.getSubjectManager().getOverlord(), rootResource.getId());

    start = System.currentTimeMillis();
    monitorId = HibernatePerformanceMonitor.get().start();
    List<ResourceFlyweight> resources =
        resourceManager.findResourcesByAgent(
            user, agent.getId(), PageControl.getUnlimitedInstance());
    end = System.currentTimeMillis();
    HibernatePerformanceMonitor.get().stop(monitorId, "ResourceTree agent resource");
    log.debug("Loaded " + resources.size() + " raw resources in " + (end - start));

    start = System.currentTimeMillis();
    monitorId = HibernatePerformanceMonitor.get().start();
    rootNode = load(rootResource.getId(), resources);
    end = System.currentTimeMillis();
    HibernatePerformanceMonitor.get().stop(monitorId, "ResourceTree tree construction");
    log.debug("Constructed tree in " + (end - start));
  }
 private String[] getSelectedRepoSubscriptions() {
   return FacesContextUtility.getRequest().getParameterValues("selectedRepoSubscriptions");
 }