本文整理汇总了Java中com.day.cq.wcm.api.WCMMode类的典型用法代码示例。如果您正苦于以下问题:Java WCMMode类的具体用法?Java WCMMode怎么用?Java WCMMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WCMMode类属于com.day.cq.wcm.api包,在下文中一共展示了WCMMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doFilter
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
@Override
public final void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
ServletException {
final WCMMode mode = WCMMode.fromRequest(request);
final IncludeOptions includeOptions = IncludeOptions.getOptions(request, true);
// Only execute in Publish mode
if (false && includeOptions != null && ((mode == null || WCMMode.DISABLED.equals(mode)))) {
// Disable CQ Decoration on cq:includes or sling:includes, only in Publish mode
includeOptions.setDecorationTagName("");
}
// Finally, proceed with the the Filter chain
chain.doFilter(request, response);
}
示例2: setUp
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
@Before
public void setUp() {
when(this.request.getResource()).thenReturn(this.resource);
when(this.request.getResourceResolver()).thenReturn(this.resourceResolver);
when(this.request.getAttribute(ComponentContext.CONTEXT_ATTR_NAME)).thenReturn(this.componentContext);
when(this.request.getAttribute(WCMMode.REQUEST_ATTRIBUTE_NAME)).thenReturn(WCMMode.PREVIEW);
when(this.request.adaptTo(XSSAPI.class)).thenReturn(this.xssApi);
when(this.resource.getResourceResolver()).thenReturn(this.resourceResolver);
when(this.resourceResolver.adaptTo(PageManager.class)).thenReturn(this.pageManager);
when(this.resourceResolver.adaptTo(Designer.class)).thenReturn(this.designer);
when(this.componentContext.getPage()).thenReturn(this.currentPage);
when(this.componentContext.getCell()).thenReturn(this.cell);
when(this.pageManager.getContainingPage(this.resource)).thenReturn(this.resourcePage);
when(this.designer.getDesign(any(Page.class))).thenReturn(this.design);
when(this.design.getStyle(this.cell)).thenReturn(this.style);
}
示例3: testIsDesign
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
@Test
public void testIsDesign() {
assertFalse(WCMModeFunctions.isDesign(null));
// null request
assertFalse(WCMModeFunctions.isDesign(pageContext));
when(pageContext.getRequest()).thenReturn(request);
assertFalse(WCMModeFunctions.isDesign(pageContext));
when(request.getAttribute(WCMMode.REQUEST_ATTRIBUTE_NAME)).thenReturn(WCMMode.DESIGN);
assertTrue(WCMModeFunctions.isDesign(pageContext));
when(request.getAttribute(WCMMode.REQUEST_ATTRIBUTE_NAME)).thenReturn(WCMMode.EDIT);
assertFalse(WCMModeFunctions.isDesign(pageContext));
}
示例4: testIsDisabled
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
@Test
public void testIsDisabled() {
assertTrue(WCMModeFunctions.isDisabled(null));
// null request
assertTrue(WCMModeFunctions.isDisabled(pageContext));
when(pageContext.getRequest()).thenReturn(request);
assertTrue(WCMModeFunctions.isDisabled(pageContext));
when(request.getAttribute(WCMMode.REQUEST_ATTRIBUTE_NAME)).thenReturn(WCMMode.DISABLED);
assertTrue(WCMModeFunctions.isDisabled(pageContext));
when(request.getAttribute(WCMMode.REQUEST_ATTRIBUTE_NAME)).thenReturn(WCMMode.EDIT);
assertFalse(WCMModeFunctions.isDisabled(pageContext));
}
示例5: testIsEdit
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
@Test
public void testIsEdit() {
assertFalse(WCMModeFunctions.isEdit(null));
// null request
assertFalse(WCMModeFunctions.isEdit(pageContext));
when(pageContext.getRequest()).thenReturn(request);
assertFalse(WCMModeFunctions.isEdit(pageContext));
when(request.getAttribute(WCMMode.REQUEST_ATTRIBUTE_NAME)).thenReturn(WCMMode.EDIT);
assertTrue(WCMModeFunctions.isEdit(pageContext));
when(request.getAttribute(WCMMode.REQUEST_ATTRIBUTE_NAME)).thenReturn(WCMMode.DISABLED);
assertFalse(WCMModeFunctions.isEdit(pageContext));
}
示例6: testIsPreview
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
@Test
public void testIsPreview() {
assertFalse(WCMModeFunctions.isPreview(null));
// null request
assertFalse(WCMModeFunctions.isPreview(pageContext));
when(pageContext.getRequest()).thenReturn(request);
assertFalse(WCMModeFunctions.isPreview(pageContext));
when(request.getAttribute(WCMMode.REQUEST_ATTRIBUTE_NAME)).thenReturn(WCMMode.PREVIEW);
assertTrue(WCMModeFunctions.isPreview(pageContext));
when(request.getAttribute(WCMMode.REQUEST_ATTRIBUTE_NAME)).thenReturn(WCMMode.DISABLED);
assertFalse(WCMModeFunctions.isPreview(pageContext));
}
示例7: doStartTag
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
@Override
public int doStartTag() throws JspException {
try {
if (StringUtils.isBlank(getMode())) {
return EVAL_BODY_BUFFERED;
}
this.wcmmode = WCMMode.fromRequest(WCMUtil.getSlingRequest(pageContext));
for (WCMMode candidate : WCMMode.values()) {
if (StringUtils.equalsIgnoreCase(getMode(), candidate.toString())) {
candidate.toRequest(WCMUtil.getSlingRequest(pageContext));
break;
}
}
} catch(RuntimeException re) {
LOG.debug(re.getMessage());
throw new JspException(re);
}
return EVAL_BODY_BUFFERED;
}
示例8: setupModeMap
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
protected void setupModeMap() {
if (null == pageContext.getAttribute(getMapName(), PageContext.REQUEST_SCOPE)) {
Map<String, Boolean> modeMap = new HashMap<String, Boolean>();
// DISABLED, EDIT, PREVIEW, ANALYTICS, READ_ONLY, DESIGN
modeMap.put(PROPERTY_DISABLED, WCMMode.DISABLED.equals(mode));
modeMap.put(PROPERTY_DISABLED.toLowerCase(), WCMMode.DISABLED.equals(mode));
modeMap.put(PROPERTY_EDIT, WCMMode.EDIT.equals(mode));
modeMap.put(PROPERTY_EDIT.toLowerCase(), WCMMode.EDIT.equals(mode));
modeMap.put(PROPERTY_PREVIEW, WCMMode.PREVIEW.equals(mode));
modeMap.put(PROPERTY_PREVIEW.toLowerCase(), WCMMode.PREVIEW.equals(mode));
modeMap.put(PROPERTY_ANALYTICS, WCMMode.ANALYTICS.equals(mode));
modeMap.put(PROPERTY_ANALYTICS.toLowerCase(), WCMMode.ANALYTICS.equals(mode));
modeMap.put(PROPERTY_READ_ONLY, WCMMode.READ_ONLY.equals(mode));
modeMap.put(PROPERTY_READ_ONLY.toLowerCase(), WCMMode.READ_ONLY.equals(mode));
modeMap.put(PROPERTY_DESIGN, WCMMode.DESIGN.equals(mode));
modeMap.put(PROPERTY_DESIGN.toLowerCase(), WCMMode.DESIGN.equals(mode));
pageContext.setAttribute(getMapName(), modeMap, PageContext.PAGE_SCOPE);
}
}
示例9: execute
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
@Override
public CharSequence execute(final Object valueObj)
throws Exception {
StringBuffer buffer = new StringBuffer();
TemplateContentModelImpl contentModel = contentModel();
SlingHttpServletRequest slingRequest = contentModel.request();
WCMMode wcmMode = WCMMode.fromRequest(slingRequest);
ClientLibraryUtil clientLibUtil = new ClientLibraryUtil(htmlLibraryManager, slingRequest);
clientLibUtil.setOptions(true, true, false, false, false, BLANK);
if (wcmMode != WCMMode.DISABLED) {
ComponentContext componentContext = WCMUtils.getComponentContext(slingRequest);
EditContext editContext = componentContext.getEditContext();
String dlgPath = null;
if (editContext != null && editContext.getComponent() != null) {
dlgPath = editContext.getComponent().getDialogPath();
}
if (AuthoringUIMode.fromRequest(slingRequest) == AuthoringUIMode.TOUCH) {
buffer.append(clientLibUtil.generateClientLibrariesPristine("cq.authoring.page"));
} else
if (AuthoringUIMode.fromRequest(slingRequest) == AuthoringUIMode.CLASSIC) {
buffer.append(clientLibUtil.generateClientLibrariesPristine("cq.wcm.edit"));
boolean isEditMode = (wcmMode == WCMMode.EDIT) ? true : false;
String dialogPath = dlgPath == null ? "" : dlgPath;
buffer.append(this.getJavaScript(slingRequest, isEditMode, dialogPath));
}
}
return new Handlebars.SafeString(buffer);
}
示例10: doTag
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
@Override
public void doTag() throws JspException, IOException {
wcmEdit = WCMMode.fromRequest(getRequest()) == WCMMode.EDIT;
wcmDesign = WCMMode.fromRequest(getRequest()) == WCMMode.DESIGN;
wcmAuthor = !(WCMMode.fromRequest(getRequest()) == WCMMode.DISABLED);
getPageContext().setAttribute(JSP_ATTR_WCM_EDIT, wcmEdit);
getPageContext().setAttribute(JSP_ATTR_WCM_DESIGN, wcmDesign);
getPageContext().setAttribute(JSP_ATTR_WCM_AUTHOR, wcmAuthor);
}
示例11: doFilter
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
@Override
public final void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
ServletException {
final SlingHttpServletRequest slingRequest = (SlingHttpServletRequest) request;
final WCMMode requestMode = this.getOrSetFirstWCMMode(slingRequest);
final List<String> requestViews = this.getRequestViews(slingRequest);
final List<String> componentViews = this.getComponentViews(slingRequest);
if (!this.accepts(slingRequest)) {
log.trace("WCM Filters does NOT accept [ {} ]", slingRequest.getResource().getPath());
chain.doFilter(request, response);
} else if ((CollectionUtils.isEmpty(requestViews) && CollectionUtils.isNotEmpty(componentViews))
|| (CollectionUtils.isNotEmpty(requestViews) && CollectionUtils.isEmpty(componentViews))
|| (CollectionUtils.isNotEmpty(requestViews)
&& CollectionUtils.isNotEmpty(componentViews)
&& !CollectionUtils.containsAny(requestViews, componentViews))) {
log.trace("WCMView Empty/Not Empty -- Setting WCMMode [ {} ] for [ {} ]", WCMMode.DISABLED.name(),
slingRequest.getResource().getPath());
this.processChain(slingRequest, response, chain, WCMMode.DISABLED, requestMode);
} else if (CollectionUtils.containsAny(requestViews, componentViews)) {
log.debug("WCMView Match -- Setting WCMMode [ {} ] for [ {} ]", requestMode.name(),
slingRequest.getResource().getPath());
this.processChain(slingRequest, response, chain, requestMode, requestMode);
} else {
chain.doFilter(request, response);
}
}
示例12: getOrSetFirstWCMMode
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
/**
* Gets or sets and gets the original WCMMode for the Request.
*
* @param request the Request
* @return the original WCMMode for the Request
*/
private WCMMode getOrSetFirstWCMMode(final SlingHttpServletRequest request) {
WCMMode wcmMode = (WCMMode) request.getAttribute(ATTR_FILTER);
if (wcmMode == null) {
wcmMode = WCMMode.fromRequest(request);
request.setAttribute(ATTR_FILTER, wcmMode);
}
return wcmMode;
}
示例13: isRequestInMode
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
private boolean isRequestInMode() {
final ServletRequest request = pageContext.getRequest();
if (not) {
return WCMMode.fromRequest(request) != getMode();
} else {
return WCMMode.fromRequest(request) == getMode();
}
}
示例14: doStartTag
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public int doStartTag() throws JspException {
final WCMMode toSet = WCMMode.valueOf(mode);
final ServletRequest request = pageContext.getRequest();
this.oldMode = WCMMode.fromRequest(request);
toSet.toRequest(request);
return EVAL_BODY_INCLUDE;
}
示例15: doEndTag
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public int doEndTag() throws JspException {
if (restore) {
if (oldMode != null) {
oldMode.toRequest(pageContext.getRequest());
} else {
WCMMode.DISABLED.toRequest(pageContext.getRequest());
}
}
reset();
return EVAL_PAGE;
}