%--
ADOBE CONFIDENTIAL
Copyright 2013 Adobe Systems Incorporated
All Rights Reserved.
NOTICE: All information contained herein is, and remains
the property of Adobe Systems Incorporated and its suppliers,
if any. The intellectual and technical concepts contained
herein are proprietary to Adobe Systems Incorporated and its
suppliers and may be covered by U.S. and Foreign Patents,
patents in process, and are protected by trade secret or copyright law.
Dissemination of this information or reproduction of this material
is strictly forbidden unless prior written permission is obtained
from Adobe Systems Incorporated.
The script to render a single version event.
--%><%@page session="false" import="java.util.Locale,
java.awt.Dimension,
java.io.InputStream,
java.net.URI,
java.util.ResourceBundle,
java.util.Date,
java.util.Calendar,
java.util.regex.Pattern,
java.text.SimpleDateFormat,
java.text.ParseException,
javax.jcr.Node,
javax.jcr.PathNotFoundException,
javax.jcr.Session,
javax.jcr.version.Version,
javax.jcr.version.VersionHistory,
javax.jcr.version.VersionManager,
org.apache.jackrabbit.JcrConstants,
org.apache.jackrabbit.api.security.user.Authorizable,
org.apache.commons.lang.StringUtils,
org.apache.jackrabbit.util.Text,
com.adobe.granite.timeline.TimelineEvent,
com.day.cq.dam.api.Asset,
com.day.cq.dam.api.Rendition,
com.day.cq.dam.api.checkout.AssetCheckoutService,
com.day.cq.dam.commons.util.DamUtil,
com.day.cq.dam.commons.util.UIHelper,
com.adobe.granite.security.user.UserProperties,
com.adobe.granite.security.user.UserPropertiesManager,
static com.day.cq.dam.api.DamConstants.ORIGINAL_FILE,
com.adobe.granite.security.user.UserPropertiesService"%>
<%
%><%@include file="/libs/granite/ui/global.jsp" %><%
UserPropertiesManager userPropertiesManager = resourceResolver.adaptTo(UserPropertiesManager.class);
TimelineEvent event = (TimelineEvent) request.getAttribute("cq.gui.common.admin.timeline.event");
boolean isCurrent = false;
if ("jcr:rootVersion".equals(event.getDescription())) {
isCurrent = true;
}
Session session = resourceResolver.adaptTo(Session.class);
String path = slingRequest.getRequestParameter("item").getString("UTF-8");
if (path == null) {
log.warn("Unable to display event {}, missing content path", event);
}
Node node = session.getNode(path);
Resource rsc = resourceResolver.getResource(path);
Asset asset = rsc.adaptTo(Asset.class);
String mimeType = asset.getMimeType();
String versionablePath = path; // the versionable path
// determine if node itself (e.g. asset) or jcr:content (e.g. page) is versionable
if (!node.isNodeType(JcrConstants.MIX_VERSIONABLE)) {
try {
if (node.getNode(JcrConstants.JCR_CONTENT).isNodeType(JcrConstants.MIX_VERSIONABLE)) {
versionablePath += "/" + JcrConstants.JCR_CONTENT;
} else {
// resource not versionable
return;
}
} catch (PathNotFoundException e) {
return;
}
}
String imgPath = "/libs/cq/ui/widgets/themes/default/icons/240x180/page.png";
String preview = null;
Resource previewVersionRenditions = null;
Date date = new Date();
String label = null;
boolean scheduled = false;
String creator = null;
String userName = null;
String comment = null;
String dateText = null;
Version version = null;
Resource versionedResource = null;
if (isCurrent) {
label = "Current";
Resource renditionResource = resourceResolver.getResource(path + "/jcr:content/renditions/cq5dam.thumbnail.48.48.png");
if (renditionResource != null) {
imgPath = renditionResource.getPath();
}
previewVersionRenditions = resourceResolver.getResource(path + "/jcr:content/renditions/");
Resource jcrContent = resourceResolver.getResource(path + "/jcr:content");
ValueMap properties = jcrContent.adaptTo(ValueMap.class);
if (properties != null) {
Calendar lastModified = properties.get(JcrConstants.JCR_LASTMODIFIED, Calendar.class);
if (lastModified != null) {
dateText = new Date(lastModified.getTimeInMillis()).toInstant().toString();
dateText = "