Пример #1
0
  /**
   * Gets all the items recursively contained in this collection in a read-only view.
   *
   * <p>The default implementation recursively adds the items of all contained Views in case this
   * view implements {@link ViewGroup}, which should be enough for most cases.
   *
   * @since 1.520
   */
  public Collection<TopLevelItem> getAllItems() {

    if (this instanceof ViewGroup) {
      final Collection<TopLevelItem> items = new LinkedHashSet<TopLevelItem>(getItems());

      for (View view : ((ViewGroup) this).getViews()) {
        items.addAll(view.getAllItems());
      }
      return Collections.unmodifiableCollection(items);
    } else {
      return getItems();
    }
  }
Пример #2
0
 public static View createViewFromXML(String name, InputStream xml) throws IOException {
   InputStream in = new BufferedInputStream(xml);
   try {
     View v = (View) Jenkins.XSTREAM.fromXML(in);
     v.name = name;
     return v;
   } catch (StreamException e) {
     throw new IOException2("Unable to read", e);
   } catch (ConversionException e) {
     throw new IOException2("Unable to read", e);
   } catch (Error e) { // mostly reflection errors
     throw new IOException2("Unable to read", e);
   } finally {
     in.close();
   }
 }
Пример #3
0
  public static View create(StaplerRequest req, StaplerResponse rsp, ViewGroup owner)
      throws FormException, IOException, ServletException {
    String name = req.getParameter("name");
    checkGoodName(name);
    if (owner.getView(name) != null)
      throw new FormException(Messages.Hudson_ViewAlreadyExists(name), "name");

    String mode = req.getParameter("mode");
    if (mode == null || mode.length() == 0)
      throw new FormException(Messages.View_MissingMode(), "mode");

    // create a view
    View v = all().findByName(mode).newInstance(req, req.getSubmittedForm());
    v.owner = owner;

    // redirect to the config screen
    rsp.sendRedirect2(req.getContextPath() + '/' + v.getUrl() + v.getPostConstructLandingPage());

    return v;
  }
Пример #4
0
  public static View create(StaplerRequest req, StaplerResponse rsp, ViewGroup owner)
      throws FormException, IOException, ServletException {
    String requestContentType = req.getContentType();
    if (requestContentType == null) throw new Failure("No Content-Type header set");

    boolean isXmlSubmission =
        requestContentType.startsWith("application/xml")
            || requestContentType.startsWith("text/xml");

    String name = req.getParameter("name");
    checkGoodName(name);
    if (owner.getView(name) != null)
      throw new FormException(Messages.Hudson_ViewAlreadyExists(name), "name");

    String mode = req.getParameter("mode");
    if (mode == null || mode.length() == 0) {
      if (isXmlSubmission) {
        View v;
        v = createViewFromXML(name, req.getInputStream());
        v.owner = owner;
        rsp.setStatus(HttpServletResponse.SC_OK);
        return v;
      } else throw new FormException(Messages.View_MissingMode(), "mode");
    }

    // create a view
    View v = all().findByName(mode).newInstance(req, req.getSubmittedForm());
    v.owner = owner;

    // redirect to the config screen
    rsp.sendRedirect2(req.getContextPath() + '/' + v.getUrl() + v.getPostConstructLandingPage());

    return v;
  }
Пример #5
0
 public int compare(View lhs, View rhs) {
   return lhs.getViewName().compareTo(rhs.getViewName());
 }
Пример #6
0
 public People(View parent) {
   this.parent = parent;
   this.users = toList(getUserInfo(parent.getItems()));
 }
Пример #7
0
 /** @see View#getAsynchPeople */
 public AsynchPeople(View parent) {
   this.parent = parent;
   items = parent.getItems();
   unknown = null;
 }