Skip to content

Commit

Permalink
LPS-27741 Sort methods
Browse files Browse the repository at this point in the history
  • Loading branch information
brianchandotcom committed Jun 14, 2012
1 parent 1d8ba57 commit b2a65f0
Showing 1 changed file with 104 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,94 @@ public void processTemplate(
pageContext, null, velocityTemplateId, velocityTemplateContent);
}

public void processTemplate(
PageContext pageContext, String portletId,
String velocityTemplateId, String velocityTemplateContent)
throws Exception {

doDispatch(
pageContext, portletId, velocityTemplateId, velocityTemplateContent,
true);
}

public String processXML(
HttpServletRequest request, String content,
RuntimeLogic runtimeLogic)
throws Exception {

if (Validator.isNull(content)) {
return StringPool.BLANK;
}

int index = content.indexOf(runtimeLogic.getOpenTag());

if (index == -1) {
return content;
}

Portlet renderPortlet = (Portlet)request.getAttribute(
WebKeys.RENDER_PORTLET);

Boolean renderPortletResource = (Boolean)request.getAttribute(
WebKeys.RENDER_PORTLET_RESOURCE);

String outerPortletId = (String)request.getAttribute(
WebKeys.OUTER_PORTLET_ID);

if (outerPortletId == null) {
request.setAttribute(
WebKeys.OUTER_PORTLET_ID, renderPortlet.getPortletId());
}

try {
request.setAttribute(WebKeys.RENDER_PORTLET_RESOURCE, Boolean.TRUE);

StringBundler sb = new StringBundler();

int x = 0;
int y = index;

while (y != -1) {
sb.append(content.substring(x, y));

int close1 = content.indexOf(runtimeLogic.getClose1Tag(), y);
int close2 = content.indexOf(runtimeLogic.getClose2Tag(), y);

if ((close2 == -1) || ((close1 != -1) && (close1 < close2))) {
x = close1 + runtimeLogic.getClose1Tag().length();
}
else {
x = close2 + runtimeLogic.getClose2Tag().length();
}

sb.append(runtimeLogic.processXML(content.substring(y, x)));

y = content.indexOf(runtimeLogic.getOpenTag(), x);
}

if (y == -1) {
sb.append(content.substring(x));
}

return sb.toString();
}
finally {
if (outerPortletId == null) {
request.removeAttribute(WebKeys.OUTER_PORTLET_ID);
}

request.setAttribute(WebKeys.RENDER_PORTLET, renderPortlet);

if (renderPortletResource == null) {
request.removeAttribute(WebKeys.RENDER_PORTLET_RESOURCE);
}
else {
request.setAttribute(
WebKeys.RENDER_PORTLET_RESOURCE, renderPortletResource);
}
}
}

protected Object buildVelocityTaglib(
HttpServletRequest request, HttpServletResponse response,
PageContext pageContext)
Expand Down Expand Up @@ -214,44 +302,6 @@ protected void doProcessCustomizationSettings(
}
}

protected LayoutTemplate getLayoutTemlpate(String velocityTemplateId) {
String separator = LayoutTemplateConstants.CUSTOM_SEPARATOR;
boolean standard = false;

if (velocityTemplateId.contains(
LayoutTemplateConstants.STANDARD_SEPARATOR)) {

separator = LayoutTemplateConstants.STANDARD_SEPARATOR;
standard = true;
}

String layoutTemplateId = null;

String themeId = null;

int pos = velocityTemplateId.indexOf(separator);

if (pos != -1) {
layoutTemplateId = velocityTemplateId.substring(
pos + separator.length());

themeId = velocityTemplateId.substring(0, pos);
}

return LayoutTemplateLocalServiceUtil.getLayoutTemplate(
layoutTemplateId, standard, themeId);
}

public void processTemplate(
PageContext pageContext, String portletId,
String velocityTemplateId, String velocityTemplateContent)
throws Exception {

doDispatch(
pageContext, portletId, velocityTemplateId, velocityTemplateContent,
true);
}

protected void doProcessTemplate(
PageContext pageContext, String portletId,
String velocityTemplateId, String velocityTemplateContent,
Expand Down Expand Up @@ -402,82 +452,32 @@ request, new PipingServletResponse(response, unsyncStringWriter),
sb.writeTo(pageContext.getOut());
}

public String processXML(
HttpServletRequest request, String content,
RuntimeLogic runtimeLogic)
throws Exception {

if (Validator.isNull(content)) {
return StringPool.BLANK;
}

int index = content.indexOf(runtimeLogic.getOpenTag());

if (index == -1) {
return content;
}

Portlet renderPortlet = (Portlet)request.getAttribute(
WebKeys.RENDER_PORTLET);

Boolean renderPortletResource = (Boolean)request.getAttribute(
WebKeys.RENDER_PORTLET_RESOURCE);
protected LayoutTemplate getLayoutTemlpate(String velocityTemplateId) {
String separator = LayoutTemplateConstants.CUSTOM_SEPARATOR;
boolean standard = false;

String outerPortletId = (String)request.getAttribute(
WebKeys.OUTER_PORTLET_ID);
if (velocityTemplateId.contains(
LayoutTemplateConstants.STANDARD_SEPARATOR)) {

if (outerPortletId == null) {
request.setAttribute(
WebKeys.OUTER_PORTLET_ID, renderPortlet.getPortletId());
separator = LayoutTemplateConstants.STANDARD_SEPARATOR;
standard = true;
}

try {
request.setAttribute(WebKeys.RENDER_PORTLET_RESOURCE, Boolean.TRUE);

StringBundler sb = new StringBundler();

int x = 0;
int y = index;

while (y != -1) {
sb.append(content.substring(x, y));

int close1 = content.indexOf(runtimeLogic.getClose1Tag(), y);
int close2 = content.indexOf(runtimeLogic.getClose2Tag(), y);

if ((close2 == -1) || ((close1 != -1) && (close1 < close2))) {
x = close1 + runtimeLogic.getClose1Tag().length();
}
else {
x = close2 + runtimeLogic.getClose2Tag().length();
}
String layoutTemplateId = null;

sb.append(runtimeLogic.processXML(content.substring(y, x)));
String themeId = null;

y = content.indexOf(runtimeLogic.getOpenTag(), x);
}
int pos = velocityTemplateId.indexOf(separator);

if (y == -1) {
sb.append(content.substring(x));
}
if (pos != -1) {
layoutTemplateId = velocityTemplateId.substring(
pos + separator.length());

return sb.toString();
themeId = velocityTemplateId.substring(0, pos);
}
finally {
if (outerPortletId == null) {
request.removeAttribute(WebKeys.OUTER_PORTLET_ID);
}

request.setAttribute(WebKeys.RENDER_PORTLET, renderPortlet);

if (renderPortletResource == null) {
request.removeAttribute(WebKeys.RENDER_PORTLET_RESOURCE);
}
else {
request.setAttribute(
WebKeys.RENDER_PORTLET_RESOURCE, renderPortletResource);
}
}
return LayoutTemplateLocalServiceUtil.getLayoutTemplate(
layoutTemplateId, standard, themeId);
}

protected void parallelyRenderPortlets(
Expand Down

0 comments on commit b2a65f0

Please sign in to comment.