%--
ADOBE CONFIDENTIAL
__________________
Copyright 2011 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 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.
--%><%
%>
<%@page session="false"
import="com.day.cq.replication.ContentBuilder,
org.apache.commons.lang3.StringEscapeUtils,
org.apache.sling.api.resource.Resource,
org.apache.sling.api.resource.ValueMap,
java.io.UnsupportedEncodingException,
java.net.URLEncoder,
java.util.Comparator,
java.util.Map,
java.util.TreeMap" %>
<%
%>
<%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0" %>
<%
%><%
String path = request.getParameter("path");
String agentName = path.substring(path.lastIndexOf("/") + 1);
Resource r = resourceResolver.getResource(path + "/jcr:content");
if (r == null) {
response.sendError(404);
return;
}
ValueMap value = r.adaptTo(ValueMap.class);
boolean defaultAgent = false;
boolean reverseAgent = false;
boolean staticAgent = false;
String agentType = value.get("agentType", String.class);
// CQ contents
// FIXME: is this the proper way? CQ doesn't have agentType property
if (agentType == null) {
if (path.equals("/etc/replication/agents.author/publish") || path.equals("/etc/replication/agents.author/flush")
|| path.equals("/etc/replication/agents.publish/flush") || path.equals("/etc/replication/agents.publish/outbox")) {
defaultAgent = true;
} else if (path.equals("/etc/replication/agents.author/publish_reverse")) {
reverseAgent = true;
} else if (path.equals("/etc/replication/agents.author/static")) {
staticAgent = true;
}
} else {
defaultAgent = agentType.equals("default");
reverseAgent = agentType.equals("reverse");
staticAgent = agentType.equals("static");
}
TreeMap builderOptions = new TreeMap(new Comparator() {
/**
* Special comparator that ensures, that "durbo" comes before "flush" comes before
* all other keys.
*/
public int compare(String o1, String o2) {
if (o1.equals("durbo")) o1 = "!";
if (o2.equals("durbo")) o2 = "!";
if (o1.equals("flush")) o1 = "!!";
if (o2.equals("flush")) o2 = "!!";
return o1.compareTo(o2);
}
});
Object[] builders = sling.getServices(ContentBuilder.class, null);
if (builders != null) {
for (Object o : builders) {
ContentBuilder b = (ContentBuilder) o;
String name = b.getName();
String title = b.getTitle();
if (name.equals("flush")) {
title = "Dispatcher Flush";
} else if (name.equals("durbo")) {
title = "Default";
}
builderOptions.put(name, title);
}
}
String pageId = "g-agent-edit-" + agentName;
String name = StringEscapeUtils.escapeXml((String) value.get("jcr:title"));
if ("".equals(name)) name = agentName;
String escapedName = StringEscapeUtils.escapeHtml4(name);
%>