Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
SOLVED

check author or publish instance from java

Avatar

Level 4

Hi,

 

I am currently using AEM 6.5

My requirement is to check whether instance is author or publish instance.

As I have to disable one functionality on front end html.

i dont want to know from WCM MODE.

 

can anyone help me with appropriate solution.

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @kiranc13433869 

 

You can use SlingSettingService to check author or publish mode. Check this sample java code if it helps:

import com.day.cq.commons.Externalizer;

// If using in sling model
    @Inject
    SlingSettingsService slingSettingsService;

private boolean isAuthorRunMode() {
    Set<String> runModes = slingSettingsService.getRunModes();
    return runModes.contains(Externalizer.AUTHOR);
}

 

Hope it helps!

Thanks!

Nupur

View solution in original post

0 Replies

Avatar

Correct answer by
Community Advisor

Hi @kiranc13433869 

 

You can use SlingSettingService to check author or publish mode. Check this sample java code if it helps:

import com.day.cq.commons.Externalizer;

// If using in sling model
    @Inject
    SlingSettingsService slingSettingsService;

private boolean isAuthorRunMode() {
    Set<String> runModes = slingSettingsService.getRunModes();
    return runModes.contains(Externalizer.AUTHOR);
}

 

Hope it helps!

Thanks!

Nupur