%@page session="false"
contentType="text/html; charset=utf-8"
import="java.util.Arrays,
java.util.Calendar,
java.util.Collection,
java.util.Iterator,
java.util.List,
java.util.regex.Matcher,
java.util.ResourceBundle,
javax.jcr.Node,
javax.jcr.NodeIterator,
javax.jcr.RepositoryException,
javax.jcr.Session,
javax.jcr.query.QueryManager,
com.adobe.cq.history.api.HistoryEntry,
com.adobe.cq.history.api.HistoryService,
com.adobe.cq.history.filter.ResourceTypesFilter,
com.day.cq.commons.Console,
com.day.cq.commons.ConsoleUtil,
com.adobe.granite.license.ProductInfo,
com.adobe.granite.license.ProductInfoProvider,
com.day.cq.commons.date.RelativeTimeFormat,
com.day.cq.i18n.I18n,
com.day.cq.rewriter.linkchecker.LinkCheckerSettings,
com.day.cq.wcm.api.Page,
com.day.text.Text,
org.apache.commons.lang3.StringEscapeUtils,
org.apache.commons.lang3.StringUtils,
org.apache.jackrabbit.api.security.user.Authorizable,
org.apache.sling.api.SlingHttpServletRequest,
org.apache.sling.api.resource.ResourceUtil,
org.apache.sling.commons.json.io.JSONStringer,
org.apache.sling.featureflags.Features"%><%
%><%@include file="/libs/foundation/global.jsp"%><%
final ResourceBundle resourceBundle = slingRequest.getResourceBundle(null);
final I18n i18n = new I18n(resourceBundle);
final String contextPath = request.getContextPath();
String title = i18n.getVar(properties.get("jcr:title", ResourceUtil.getName(resource)));
Session session = resourceResolver.adaptTo(Session.class);
Authorizable auth = resourceResolver.adaptTo(Authorizable.class);
String name = auth == null ? null : auth.getPrincipal().getName();
if (name == null) {
// workaround if user manager service is not ready yet.
name = session.getUserID();
}
HistoryService history = sling.getService(HistoryService.class);
name = xssAPI.encodeForHTML(name);
String[] searchPath = resourceResolver.getSearchPath();
QueryManager qm = session.getWorkspace().getQueryManager();
ConsoleUtil consoleUtil = new ConsoleUtil(qm, null, searchPath);
String basePath = resource.getPath();
String cssPath = getOverlayCssPath(resource, "/welcome.css");
String ieCssPath = getOverlayCssPath(resource, "/welcome_ie.css");
String mobileCssPath = getOverlayCssPath(resource, "/welcome_touch.css");
%>
<%
String trackingPage = new JSONStringer()
.object()
.key("type").value("collection")
.key("hierarchy").value("classic")
.key("name").value("welcome")
.endObject()
.toString();
%><%
Resource globalHead = resourceResolver.getResource("/mnt/overlay/granite/ui/content/globalhead");
if (globalHead != null) {
for (Iterator it = globalHead.listChildren(); it.hasNext();) {
%><%
}
}
%><%= StringEscapeUtils.escapeHtml4(title) %>
<%
int i = 1;
final RelativeTimeFormat relativeTimeFormat = new RelativeTimeFormat(RelativeTimeFormat.SHORT, resourceBundle);
Features featureManager = sling.getService(Features.class);
for (Console app : consoleUtil.getPaths()) {
if (i > 6) i = 1;
String appPath = app.getVanityPath() != null ? app.getVanityPath() : app.getPath();
String appName = app.getAppName() != null ? i18n.getVar(app.getAppName()) : i18n.get("AEM Console");
String appDesc = app.getDescription() != null ? i18n.getVar(app.getDescription()) : "";
String iconClass = app.getIconClass() != null ? app.getIconClass() : "siteadmin";
ValueMap consoleProps = ResourceUtil.getValueMap(resourceResolver.getResource(app.getPath()));
String feature = consoleProps.get("feature", String.class);
if(StringUtils.isNotBlank(feature) && !featureManager.isEnabled(feature)) {
continue;
}
boolean showHistory = history != null && consoleProps.get("historyShow", false);
Resource appResource = resourceResolver.resolve(appPath);
if (appResource != null && !ResourceUtil.isNonExistingResource(appResource)) {
%>
<%
%>
<%
if (showHistory) {
Collection
filtered = Arrays.asList(consoleProps.get("historyResourceTypes", new String[0]));
Long historyCount = consoleProps.get("historyCount", 10L);
Collection historyEntries = history.readEntries(resourceResolver, session.getUserID(), historyCount.intValue(), new ResourceTypesFilter(filtered));
String historyTitle = consoleProps.get("historyTitle", String.class);
historyTitle = historyTitle != null ? i18n.getVar(historyTitle) : i18n.get("Recently used items");
%><%= xssAPI.encodeForHTML(historyTitle) %><%
%>
<%
if (!historyEntries.isEmpty()) {
String historyLink = consoleProps.get("historyLink", null);
for (HistoryEntry he : historyEntries) {
Resource historyRes = resourceResolver.getResource(he.getResourcePath());
if (historyRes != null) {
String hetTitle = Text.getName(he.getResourcePath());
String actionTitle = he.getAction().equals(HistoryEntry.Action.EDIT)
? i18n.get("Edit", "History action label when resource has been edited")
: i18n.get("View", "History action label when resource has been viewed");
if (he.getResourceTypes().contains("cq:Page")) {
Page historyPage = historyRes.adaptTo(Page.class);
if (historyPage != null) {
hetTitle = historyPage.getTitle();
}
}
%>-
<%
if (historyLink != null) {
%>" title="<%= xssAPI.encodeForHTMLAttr(he.getResourcePath()) %>" target="_blank"><%= xssAPI.encodeForHTML(hetTitle) %><%
} else {
%><%= xssAPI.encodeForHTML(hetTitle) %><%
}
%>
<%= xssAPI.encodeForHTMLAttr(relativeTimeFormat.format(he.getDate().getTimeInMillis(), true)) %><%
%>
<%
}
}
} else {
%>- <%= xssAPI.encodeForHTMLAttr(consoleProps.get("historyEmptyText", i18n.get("No items"))) %>
<%
}
%>
<%
}
%><%
i++;
}
}
consoleUtil.dispose();
String prodName = "";
String prodVersion = "";
ProductInfoProvider piService = sling.getService(ProductInfoProvider.class);
if (piService != null) {
ProductInfo pi = piService.getProductInfo();
prodName = pi.getName();
prodVersion = pi.getVersion().toString();
}
String cq5Info = i18n.get("{0}, Version {1}", "Welcome screen footer: {productName}, Version {productVersion}", prodName, prodVersion);
String licenseInfo = i18n.get("License Information");
String licenseURL = "/system/granite/license/"; // todo: translate
String copyright = i18n.get("© 1997-{0} Adobe Systems Incorporated. All Rights Reserved.", null, ""+Calendar.getInstance().get(Calendar.YEAR));
out.flush();
LinkCheckerSettings.fromRequest(slingRequest).setIgnoreInternals(true);
%>
<%
out.flush();
LinkCheckerSettings.fromRequest(slingRequest).setIgnoreInternals(false);
%>
<%
basePath = basePath.substring(basePath.indexOf("/")+1);
basePath = basePath.substring(basePath.indexOf("/")+1);
Resource features = resource.getResourceResolver().getResource(basePath + "/features");
Resource resources = resource.getResourceResolver().getResource(basePath + "/resources");
Resource docs = resource.getResourceResolver().getResource(basePath + "/docs");
if (showFeatureBox(features, resources, search)) {
/*---< resources >-----------------------------------------------------*/
if (resources != null) {
out.flush();
LinkCheckerSettings.fromRequest(slingRequest).setIgnoreExternals(true);
LinkCheckerSettings.fromRequest(slingRequest).setIgnoreInternals(true);
List
links = getLinks(slingRequest, resources, i18n);
String separator = "";
%><%
for (String[] link : links) {
%><%= separator %><%
%>
<%
if ("".equals(separator)) {
separator = "
";
}
}
out.flush();
LinkCheckerSettings.fromRequest(slingRequest).setIgnoreExternals(false);
LinkCheckerSettings.fromRequest(slingRequest).setIgnoreInternals(false);
%>
<%
}
/*---< docs >-----------------------------------------------------*/
if (docs != null) {
out.flush();
LinkCheckerSettings.fromRequest(slingRequest).setIgnoreExternals(true);
LinkCheckerSettings.fromRequest(slingRequest).setIgnoreInternals(true);
List links = getLinks(slingRequest, docs, i18n);
String separator = "";
%><%
for (String[] link : links) {
%><%= separator %><%
%>
<%
if ("".equals(separator)) {
separator = "
";
}
}
out.flush();
LinkCheckerSettings.fromRequest(slingRequest).setIgnoreExternals(false);
LinkCheckerSettings.fromRequest(slingRequest).setIgnoreInternals(false);
%>
<%
}
/*---< features >-----------------------------------------------------*/
if (features != null) {
out.flush();
LinkCheckerSettings.fromRequest(slingRequest).setIgnoreExternals(true);
LinkCheckerSettings.fromRequest(slingRequest).setIgnoreInternals(true);
List links = getLinks(slingRequest, features, i18n);
String separator = "";
%><%
for (String[] link : links) {
%><%= separator %><%
%>
<%
if ("".equals(separator)) {
separator = "
";
}
}
out.flush();
LinkCheckerSettings.fromRequest(slingRequest).setIgnoreExternals(false);
LinkCheckerSettings.fromRequest(slingRequest).setIgnoreInternals(false);
%>
<%
}
}
%>
<%
Resource globalFooter = resourceResolver.getResource("/mnt/overlay/granite/ui/content/globalfooter");
if (globalFooter != null) {
for (Iterator it = globalFooter.listChildren(); it.hasNext();) {
%><%
}
}
%>
<%
%><%@include file="functions.jsp"%>