repos.jspf revision e40020b8ff95cd2a2680d1d651f6f8e40f1c35df
888273610a036b1d0d39339d0057352922648a5bVladimir KotalCDDL HEADER START
888273610a036b1d0d39339d0057352922648a5bVladimir KotalThe contents of this file are subject to the terms of the
888273610a036b1d0d39339d0057352922648a5bVladimir KotalCommon Development and Distribution License (the "License").
888273610a036b1d0d39339d0057352922648a5bVladimir KotalYou may not use this file except in compliance with the License.
888273610a036b1d0d39339d0057352922648a5bVladimir KotalSee LICENSE.txt included in this distribution for the specific
888273610a036b1d0d39339d0057352922648a5bVladimir Kotallanguage governing permissions and limitations under the License.
888273610a036b1d0d39339d0057352922648a5bVladimir KotalWhen distributing Covered Code, include this CDDL HEADER in each
888273610a036b1d0d39339d0057352922648a5bVladimir Kotalfile and include the License file at LICENSE.txt.
888273610a036b1d0d39339d0057352922648a5bVladimir KotalIf applicable, add the following below this CDDL HEADER, with the
888273610a036b1d0d39339d0057352922648a5bVladimir Kotalfields enclosed by brackets "[]" replaced with your own identifying
888273610a036b1d0d39339d0057352922648a5bVladimir Kotalinformation: Portions Copyright [yyyy] [name of copyright owner]
888273610a036b1d0d39339d0057352922648a5bVladimir KotalCDDL HEADER END
ab9ed8040a4ac7d3d58f162b8e40b3b6309f33b7Knut Anders HatlenCopyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
ab9ed8040a4ac7d3d58f162b8e40b3b6309f33b7Knut Anders Hatlen<script src="<%=request.getContextPath()%>/repos.js" type="text/javascript"></script>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger<%@page import="java.util.Set"%>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger<%@page import="org.opensolaris.opengrok.web.Prefix"%>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger<%@page import="org.opensolaris.opengrok.web.ProjectHelper"%>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger<%@page import="java.util.LinkedList"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="java.util.Collections"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="java.util.Comparator"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="java.util.Collection"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="java.io.File"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="org.opensolaris.opengrok.configuration.RuntimeEnvironment"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="org.opensolaris.opengrok.history.RepositoryInfo"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="org.opensolaris.opengrok.history.Repository"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="org.opensolaris.opengrok.web.Util"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="org.opensolaris.opengrok.configuration.Project"%>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger<%@page import="org.opensolaris.opengrok.configuration.Group"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="java.util.List"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="org.opensolaris.opengrok.web.PageConfig"%>
6c5588deac931d8ca1d9f09fe9a5db32155d7f4cKryštof Tulinger PageConfig cfg = PageConfig.get(request);
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal Comparator<RepositoryInfo> comparatorRepo = new Comparator<RepositoryInfo>() {
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal public int compare(RepositoryInfo r1, RepositoryInfo r2) {
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal return r1.getDirectoryName().compareTo(r2.getDirectoryName());
6c5588deac931d8ca1d9f09fe9a5db32155d7f4cKryštof Tulinger ProjectHelper pHelper = cfg.getProjectHelper();
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger if (pHelper.getAllProjects().size() > 0) {
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger Set<Group> groups = pHelper.getGroups();
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger Set<Project> repositories = pHelper.getUngroupedRepositories();
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger // recursively print all groups
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <div class="panel-group projects">
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <div class="toggle-buttons">
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <a href="#" class="accordion_show_all">
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <button>Show all</button>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <a href="#" class="accordion_hide_all">
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <button>Hide all</button>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger LinkedList<Group> stack = new LinkedList<Group>();
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger for ( Group x : groups ) {
6c5588deac931d8ca1d9f09fe9a5db32155d7f4cKryštof Tulinger if(x.getParent() == null && (pHelper.hasAllowedSubgroup(x) || cfg.isAllowed(x))) {
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger Group group = stack.element();
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger // already processed
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger %></div><!-- body -->
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger </div><!-- panel --><%
6c5588deac931d8ca1d9f09fe9a5db32155d7f4cKryštof Tulinger for ( Group x : pHelper.getSubgroups(group)) {
6c5588deac931d8ca1d9f09fe9a5db32155d7f4cKryštof Tulinger if(cfg.isAllowed(x) || pHelper.hasAllowedSubgroup(x)) {
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger %><div class="panel">
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <div class="panel-heading-accordion">
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <h2><span class="name"><%= Util.htmlize(group.getName()) %></span> <small>[<a href="#" class="projects_select_all">select all</a>]</small></h2>
89989c595bf242f405e3f7986ba8d6f64a243272Kryštof Tulinger <div class="panel-body-accordion <% if(pHelper.hasFavourite(group)) { %> favourite<% } %>"
6c5588deac931d8ca1d9f09fe9a5db32155d7f4cKryštof Tulinger <% if(pHelper.hasFavourite(group)) { %>data-accordion-visible="true"<% } %>>
6c5588deac931d8ca1d9f09fe9a5db32155d7f4cKryštof Tulinger if(pHelper.getRepositories(group).size() > 0 ) {
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <td><b>Mirror</b></td>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <td><b>SCM type</b></td>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <td><b>Parent (branch)</b></td>
6c5588deac931d8ca1d9f09fe9a5db32155d7f4cKryštof Tulinger for ( Project project : pHelper.getRepositories(group)) {
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger List<RepositoryInfo> repos = pHelper.getRepositoryInfo(project);
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger String projDesc = project.getDescription();
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger Integer cnt = 0;
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger Collections.sort(repos, comparatorRepo);
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger for (RepositoryInfo ri : repos) {
e40020b8ff95cd2a2680d1d651f6f8e40f1c35dfKryštof Tulinger if(cnt > 0 && ri.getParent() == null)
e40020b8ff95cd2a2680d1d651f6f8e40f1c35dfKryštof Tulinger // discard repositories without a parent url
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger if (cnt != 0) {
e40020b8ff95cd2a2680d1d651f6f8e40f1c35dfKryštof Tulinger .replace(cfg.getSourceRootPath() + File.separator, "");
e40020b8ff95cd2a2680d1d651f6f8e40f1c35dfKryštof Tulinger <td class="name <%= cnt > 0 ? "subrepository" : "repository" %>">
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <a href="<%= request.getContextPath() + Prefix.XREF_P + "/" + projDesc%>"
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger title="Xref for project <%= Util.htmlize(projDesc) %>">
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <%= Util.htmlize(projDesc) %>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger String parent = ri.getParent();
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger if (parent == null) {
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger parent = "N/A";
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger String type = ri.getType();
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger if (type == null) {
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger type = "N/A";
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger String branch = ri.getBranch();
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger if (branch == null) {
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger branch = "N/A";
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger %><td><%= Util.htmlize(type) %></td><%
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger %><td><%= Util.htmlize(parent) %> (<%= Util.htmlize(branch) %>)</td><%
6c5588deac931d8ca1d9f09fe9a5db32155d7f4cKryštof Tulinger } else if ( pHelper.getRepositories(group).size() <= 0 && !pHelper.hasAllowedSubgroup(group) ) {
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger %>No projects<%
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger // print the rest of projects which don't have a group
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <div class="panel-group projects">
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <% if(groups.size() > 0) { %>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <div class="toggle-buttons">
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <a href="#" class="accordion_show_all">
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <button>Show all</button>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <a href="#" class="accordion_hide_all">
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <button>Hide all</button>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <div class="panel">
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <% if(groups.size() > 0) {%>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <div class="panel-heading-accordion">
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <h2><span class="name">Other</span>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <small>[<a href="#" class="projects_select_all">select all</a>]</small>
89989c595bf242f405e3f7986ba8d6f64a243272Kryštof Tulinger <div class="panel-body<% if(groups.size() > 0) {%>-accordion<% } %> <% if(pHelper.hasUngroupedFavourite()) { %> favourite<% } %>"
89989c595bf242f405e3f7986ba8d6f64a243272Kryštof Tulinger <% if(pHelper.hasUngroupedFavourite()) { %>data-accordion-visible="true"<% } %>>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <td><b>Mirror</b></td>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <td><b>SCM type</b></td>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <td><b>Parent (branch)</b></td>
6c5588deac931d8ca1d9f09fe9a5db32155d7f4cKryštof Tulinger for (Project proj : repositories) {
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger List<RepositoryInfo> repos = pHelper.getRepositoryInfo(proj);
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger String projDesc = proj.getDescription();
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger Integer cnt = 0;
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger Collections.sort(repos, comparatorRepo);
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger for (RepositoryInfo ri : repos) {
e40020b8ff95cd2a2680d1d651f6f8e40f1c35dfKryštof Tulinger if(cnt > 0 && ri.getParent() == null)
e40020b8ff95cd2a2680d1d651f6f8e40f1c35dfKryštof Tulinger // discard repositories without a parent url
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger if (cnt != 0) {
e40020b8ff95cd2a2680d1d651f6f8e40f1c35dfKryštof Tulinger .replace(cfg.getSourceRootPath() + File.separator, "");
e40020b8ff95cd2a2680d1d651f6f8e40f1c35dfKryštof Tulinger <tr><td class="name <%= cnt > 0 ? "subrepository" : "repository" %>">
e40020b8ff95cd2a2680d1d651f6f8e40f1c35dfKryštof Tulinger <a href="<%= request.getContextPath() + Prefix.XREF_P + "/" + projDesc %>"
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger title="Xref for project <%= Util.htmlize(projDesc) %>">
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <%= Util.htmlize(projDesc) %>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger String parent = ri.getParent();
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger if (parent == null) {
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger parent = "N/A";
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger String type = ri.getType();
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger if (type == null) {
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger type = "N/A";
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger String branch = ri.getBranch();
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger if (branch == null) {
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger branch = "N/A";
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger %><td><%= Util.htmlize(type) %></td><%
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger %><td><%= Util.htmlize(parent) %> (<%= Util.htmlize(branch) %>)</td><%