private boolean isAuthor() { return slingSettings.getRunModes().contains("author"); } }
private boolean isAuthor() { return slingSettings.getRunModes().contains("author"); } }
@Override public boolean isOnAuthor() { return settingsService.getRunModes().contains(RUNMODE_AUTHOR); }
private boolean isAuthor() { return slingSettings.getRunModes().contains("author"); }
@Override public boolean isOnAuthor() { return settingsService.getRunModes().contains(RUNMODE_AUTHOR); }
@Activate public void activate(MyServiceConfiguration config) { author = settings.getRunModes().contains("author"); }
@Activate public void activate() { runmodes = slingSettingsService.getRunModes(); author = runmodes.contains("author"); publish = runmodes.contains("publish"); }
//quickfix //FrameworkUtil.getBundle(NodeManageDAO.class).getBundleContext() BundleContext bundleContext = FrameworkUtil.getBundle(PhotoNodeManagerDAO.class).getBundleContext(); ServiceReference serviceReference = bundleContext.getServiceReference(SlingSettingsService.class.getName( )); SlingSettingsService slingSettingsService = (SlingSettingsService)bundleContext.getService(serviceReference); Set<String> runmode= slingSettingsService.getRunModes(); //just in author mode if(runmode.contains("author")) { //attention replication from author is not working without nullable / delete the cq:distribute property node.setProperty("cq:distribute", (Value)null); }
public static synchronized void configure(SlingSettingsService slingSettings) throws ConfigurationException { runmodes = slingSettings.getRunModes(); isAuthor = runmodes.contains(Externalizer.AUTHOR); isPublish = runmodes.contains(Externalizer.PUBLISH); if (isAuthor && isPublish) { throw new ConfigurationException(null, "Either 'author' or 'publish' run modes may be specified, not both."); } }
public static synchronized void configure(SlingSettingsService slingSettings) throws ConfigurationException { runmodes = slingSettings.getRunModes(); isAuthor = runmodes.contains(Externalizer.AUTHOR); isPublish = runmodes.contains(Externalizer.PUBLISH); if (isAuthor && isPublish) { throw new ConfigurationException(null, "Either 'author' or 'publish' run modes may be specified, not both."); } }
import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; import org.apache.felix.scr.annotations.Reference; @Component public class FooImpl implements IFoo{ @Reference private SlingSettingsService settingsService; private ServiceRegistration reg; @Activate public void activate(BundleContext context, Map<String, ?> conf){ if(settingsService.getRunModes().contains("author")){ reg = context.registerService(IFoo.class.getName(), this, null); } } @Deactivate private void deactivate(){ if (reg != null){ reg.unregister(); } } }
@SuppressWarnings("deprecation") @Activate private void activate(ComponentContext componentContext, Config config) { // Activate only in author mode, and check enabled status in service configuration as well enabled = !RunMode.disableIfNotAuthor(slingSettings.getRunModes(), componentContext, log) && config.enabled(); }
emailParams.put("success", resultToPlainText("Successful Health Checks", success)); emailParams.put("executedAt", Calendar.getInstance().getTime().toString()); emailParams.put("runModes", StringUtils.join(slingSettingsService.getRunModes(), ", ")); emailParams.put("mode", ModeUtil.isAuthor() ? "Author" : "Publish"); emailParams.put("hostname", hostname);
@SuppressWarnings("null") private String getResourceUrlPrefix(UrlMode urlMode, Resource targetResource) { UrlMode mode = ObjectUtils.defaultIfNull(urlMode, urlHandlerConfig.getDefaultUrlMode()); return mode.getResourceUrlPrefix(self, slingSettings.getRunModes(), currentPage, targetResource); }
@SuppressWarnings("null") private String getLinkUrlPrefix(UrlMode urlMode, Page targetPage) { UrlMode mode = ObjectUtils.defaultIfNull(urlMode, urlHandlerConfig.getDefaultUrlMode()); return mode.getLinkUrlPrefix(self, slingSettings.getRunModes(), currentPage, targetPage); }
/** * Check if a given page is valid and acceptable to link upon. * @param page Page * @param options Options * @return true if link is acceptable */ @SuppressWarnings("deprecation") public boolean acceptPage(@Nullable Page page, @NotNull InternalLinkResolverOptions options) { if (page == null) { return false; } // check for jcr:content node if (!page.hasContent()) { return false; } // check if page is valid concerning on/off-time (only in publish environment) if (RunMode.isPublish(slingSettings.getRunModes()) && !page.isValid()) { return false; } // check if page is acceptable based on link handler config if (!linkHandlerConfig.isValidLinkTarget(page)) { return false; } return true; }
SimpleCredentials administrator = new SimpleCredentials("username", "password".toCharArray()); try { java.util.Set<String> runModes = slingSettingsService.getRunModes(); session = repository.login(administrator);