repos.jspf revision aabc6c87d90e439be4440430ee6439d43cc393ed
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.
d8d744ec4741226cba1ed387037d5f8dafc3d813Kryštof Tulinger<%@page import="org.json.simple.JSONArray"%>
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger<%@page import="org.opensolaris.opengrok.configuration.messages.Message"%>
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger<%@page import="java.util.SortedSet"%>
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger<%@page import="java.util.SortedSet"%>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger<%@page import="java.util.Set"%>
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger<%@page import="java.util.ArrayList"%>
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger<%@page import="java.util.Date"%>
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"%>
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger<script src="<%=request.getContextPath()%>/js/repos.js" type="text/javascript"></script>
6c5588deac931d8ca1d9f09fe9a5db32155d7f4cKryštof Tulinger PageConfig cfg = PageConfig.get(request);
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger Util.printMessages(out, cfg.getMessages());
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 ) {
d8d744ec4741226cba1ed387037d5f8dafc3d813Kryš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 --><%
d8d744ec4741226cba1ed387037d5f8dafc3d813Kryštof Tulinger for (Group x : pHelper.getSubgroups(group)) {
d8d744ec4741226cba1ed387037d5f8dafc3d813Kryštof Tulinger if (cfg.isAllowed(x) || pHelper.hasAllowedSubgroup(x)) {
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger %><div class="panel">
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <div class="panel-heading-accordion">
aabc6c87d90e439be4440430ee6439d43cc393edKryštof Tulinger <h4 class="clearfix">
94459811a242df1339dc440122d58e30a5ec6695Kryštof Tulinger <span class="pull-left">
94459811a242df1339dc440122d58e30a5ec6695Kryštof Tulinger <span class="name"><%= Util.htmlize(group.getName())%></span>
aabc6c87d90e439be4440430ee6439d43cc393edKryštof Tulinger [<a href="#" class="projects_select_all">select all</a>]
aabc6c87d90e439be4440430ee6439d43cc393edKryštof Tulinger (<span title="Number of groups directly in this group"><%= pHelper.getSubgroups(group).size() %></span> +
aabc6c87d90e439be4440430ee6439d43cc393edKryštof Tulinger <span title="Number of repositories directly in this group"><%= pHelper.getRepositories(group).size() %></span>)
94459811a242df1339dc440122d58e30a5ec6695Kryštof Tulinger <span class="pull-right">
94459811a242df1339dc440122d58e30a5ec6695Kryštof Tulinger <span class="fold <%= pHelper.hasFavourite(group) ? "fold-up" : "fold-down"%>"></span>
aabc6c87d90e439be4440430ee6439d43cc393edKryštof Tulinger <div class="panel-body-accordion<% if (pHelper.hasFavourite(group)) { %> favourite<% } %>"
aabc6c87d90e439be4440430ee6439d43cc393edKryštof Tulinger <% if (pHelper.hasFavourite(group) || pHelper.getRepositories(group).size() < 5) { %>data-accordion-visible="true"<% } %>>
d8d744ec4741226cba1ed387037d5f8dafc3d813Kryš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) {
d8d744ec4741226cba1ed387037d5f8dafc3d813Kryš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) %>
d8d744ec4741226cba1ed387037d5f8dafc3d813Kryštof Tulinger JSONArray messages = Util.messagesToJson(project.getDescription());
d8d744ec4741226cba1ed387037d5f8dafc3d813Kryštof Tulinger <span class="important-note important-note-rounded" data-messages='<%= messages %>'>!</span>
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">
d8d744ec4741226cba1ed387037d5f8dafc3d813Kryš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">
d8d744ec4741226cba1ed387037d5f8dafc3d813Kryštof Tulinger <% if (groups.size() > 0) {%>
d470e59c0405a31b7e5f194bd9b705e91b12bf0aKryštof Tulinger <div class="panel-heading-accordion">
aabc6c87d90e439be4440430ee6439d43cc393edKryštof Tulinger <h4 class="clearfix">
94459811a242df1339dc440122d58e30a5ec6695Kryštof Tulinger <span class="pull-left">
94459811a242df1339dc440122d58e30a5ec6695Kryštof Tulinger <span class="name">Other</span>
aabc6c87d90e439be4440430ee6439d43cc393edKryštof Tulinger [<a href="#" class="projects_select_all">select all</a>]
aabc6c87d90e439be4440430ee6439d43cc393edKryštof Tulinger (<span title="Number of repositories inside"><%= repositories.size() %></span>)
94459811a242df1339dc440122d58e30a5ec6695Kryštof Tulinger <span class="pull-right">
94459811a242df1339dc440122d58e30a5ec6695Kryštof Tulinger <span class="fold <%= pHelper.hasUngroupedFavourite() ? "fold-up" : "fold-down"%>"></span>
d8d744ec4741226cba1ed387037d5f8dafc3d813Kryštof Tulinger <div class="panel-body<% if (groups.size() > 0) {%>-accordion<% } %> <% if (pHelper.hasUngroupedFavourite()) { %> favourite<% } %>"
d8d744ec4741226cba1ed387037d5f8dafc3d813Kryš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) {
d8d744ec4741226cba1ed387037d5f8dafc3d813Kryš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) %>
d8d744ec4741226cba1ed387037d5f8dafc3d813Kryštof Tulinger JSONArray messages = Util.messagesToJson(proj.getDescription());
d8d744ec4741226cba1ed387037d5f8dafc3d813Kryštof Tulinger <span class="important-note important-note-rounded" data-messages='<%= messages %>'>!</span>
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><%