check author or publish instance from java

Avatar

Avatar
Boost 3
Level 3
kiranc13433869
Level 3

Likes

3 likes

Total Posts

60 posts

Correct reply

2 solutions
Top badges earned
Boost 3
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile

Avatar
Boost 3
Level 3
kiranc13433869
Level 3

Likes

3 likes

Total Posts

60 posts

Correct reply

2 solutions
Top badges earned
Boost 3
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile
kiranc13433869
Level 3

21-09-2020

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.

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
Nupur_Jain
MVP

Likes

165 likes

Total Posts

186 posts

Correct reply

76 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Establish
MVP
Nupur_Jain
MVP

Likes

165 likes

Total Posts

186 posts

Correct reply

76 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 25
View profile
Nupur_Jain
MVP

21-09-2020

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

Answers (1)

Answers (1)

Avatar

Avatar
Give Back 5
Employee
vanegi
Employee

Likes

392 likes

Total Posts

378 posts

Correct reply

148 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 50
View profile

Avatar
Give Back 5
Employee
vanegi
Employee

Likes

392 likes

Total Posts

378 posts

Correct reply

148 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 50
View profile
vanegi
Employee

21-09-2020

You can check the runmodes from http://localhost:6530/system/console/status-slingsettings

or

directly from tools->operation->system overview

 

Capture.JPG