本文整理汇总了Java中com.day.cq.wcm.api.WCMMode类的典型用法代码示例。如果您正苦于以下问题:Java WCMMode类的具体用法?Java WCMMode怎么用?Java WCMMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WCMMode类属于com.day.cq.wcm.api包,在下文中一共展示了WCMMode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-samples,代码行数:17,代码来源:SampleSlingIncludeFilter.java
示例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);
}
开发者ID:wcm-io,项目名称:wcm-io-cq5,代码行数:17,代码来源:AemObjectInjectorRequestTest.java
示例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));
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:17,代码来源:WCMModeFunctionsTest.java
示例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));
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:17,代码来源:WCMModeFunctionsTest.java
示例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));
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:17,代码来源:WCMModeFunctionsTest.java
示例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));
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:17,代码来源:WCMModeFunctionsTest.java
示例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;
}
开发者ID:steeleforge,项目名称:ironsites,代码行数:20,代码来源:SetModeTag.java
示例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);
}
}
开发者ID:steeleforge,项目名称:ironsites,代码行数:27,代码来源:ModeHelperTag.java
示例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);
}
开发者ID:DantaFramework,项目名称:AEM,代码行数:34,代码来源:InitScriptHelperFunction.java
示例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);
}
开发者ID:headwirecom,项目名称:aem-solr-search,代码行数:12,代码来源:WcmModeTag.java
示例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);
}
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:39,代码来源:WCMViewsFilter.java
示例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;
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:17,代码来源:WCMViewsFilter.java
示例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();
}
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:10,代码来源:AbstractMode.java
示例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;
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:12,代码来源:SetWCMMode.java
示例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;
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:16,代码来源:SetWCMMode.java
示例16: isDesign
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
/**
* Determine if the current WCMMode is design mode.
*
* @param pageContext the current page context
* @return true if the WCMMode is design
*/
@Function
public static boolean isDesign(PageContext pageContext) {
if (pageContext == null) {
return false;
}
final ServletRequest request = pageContext.getRequest();
if (request == null) {
return false;
}
return WCMMode.fromRequest(request) == WCMMode.DESIGN;
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:18,代码来源:WCMModeFunctions.java
示例17: isDisabled
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
/**
* Determine if the current WCMMode is disabled mode.
*
* @param pageContext the current page context
* @return true if the WCMMode is disabled
*/
@Function
public static boolean isDisabled(PageContext pageContext) {
if (pageContext == null) {
return true;
}
final ServletRequest request = pageContext.getRequest();
if (request == null) {
return true;
}
return WCMMode.fromRequest(request) == WCMMode.DISABLED;
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:18,代码来源:WCMModeFunctions.java
示例18: isEdit
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
/**
* Determine if the current WCMMode is edit mode.
*
* @param pageContext the current page context
* @return true if the WCMMode is edit
*/
@Function
public static boolean isEdit(PageContext pageContext) {
if (pageContext == null) {
return false;
}
final ServletRequest request = pageContext.getRequest();
if (request == null) {
return false;
}
return WCMMode.fromRequest(request) == WCMMode.EDIT;
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:18,代码来源:WCMModeFunctions.java
示例19: isPreview
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
/**
* Determine if the current WCMMode is preview mode.
*
* @param pageContext the current page context
* @return true if the WCMMode is preview
*/
@Function
public static boolean isPreview(PageContext pageContext) {
if (pageContext == null) {
return false;
}
final ServletRequest request = pageContext.getRequest();
if (request == null) {
return false;
}
return WCMMode.fromRequest(request) == WCMMode.PREVIEW;
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:18,代码来源:WCMModeFunctions.java
示例20: doFilter
import com.day.cq.wcm.api.WCMMode; //导入依赖的package包/类
@Override
public final void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
FilterChain chain) throws IOException, ServletException {
// We are in a Sling Filter, so these request/response objects are guarenteed to be of type Sling...
final SlingHttpServletRequest request = (SlingHttpServletRequest) servletRequest;
final SlingHttpServletResponse response = (SlingHttpServletResponse) servletResponse;
if (!this.accepts(request, response)) {
chain.doFilter(request, response);
return;
}
final SlingHttpServletRequest slingRequest = (SlingHttpServletRequest) request;
final SlingHttpServletResponse slingResponse = (SlingHttpServletResponse) response;
if (editModeEnabled
&& (componentHelper.isEditMode(slingRequest)
|| componentHelper.isDesignMode(slingRequest)
|| WCMMode.ANALYTICS.equals(WCMMode.fromRequest(slingRequest)))) {
// Edit Modes
this.doFilterWithErrorHandling(slingRequest, slingResponse, chain, editErrorHTMLPath);
} else if (previewModeEnabled
&& (componentHelper.isPreviewMode(slingRequest)
|| componentHelper.isReadOnlyMode(slingRequest))) {
// Preview Modes
this.doFilterWithErrorHandling(slingRequest, slingResponse, chain, previewErrorHTMLPath);
} else if (publishModeEnabled
&& componentHelper.isDisabledMode(slingRequest)
&& !this.isFirstInChain(slingRequest)) {
// Publish Modes; Requires special handling in Published Modes - do not process first filter chain
this.doFilterWithErrorHandling(slingRequest, slingResponse, chain, publishErrorHTMLPath);
} else {
// Normal Behavior
chain.doFilter(request, response);
}
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:38,代码来源:ComponentErrorHandlerImpl.java
注:本文中的com.day.cq.wcm.api.WCMMode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论