/** * Returns the actual repository to which all JCR Repository interface * methods implemented by this class are delegated. * * @return The delegated repository. */ protected final Repository getRepository() { return this.getSlingRepositoryManager().getRepository(); }
/** * Returns the default workspace to login to if any of the {@code login} and * {@code createSession} methods is called without an explicit workspace * name. * <p> * This method may return {@code null} in which case the actual default * workspace used depends on the underlying JCR Repository implementation. */ @Override public final String getDefaultWorkspace() { return this.getSlingRepositoryManager().getDefaultWorkspace(); }
@Override public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) { AbstractSlingRepositoryManager.this.destroy((AbstractSlingRepository2) service); } }, props);
/** * Login as an administrative user. This method is deprecated and its use * can be completely disabled by setting {@code disableLoginAdministrative} * to {@code true}. * <p> * This implementation cannot be overwritten but, unless disabled, forwards * to the {@link #createAdministrativeSession(String)} method. * * @param workspace The workspace to access or {@code null} to access the * {@link #getDefaultWorkspace() default workspace} * @return An administrative session * @throws RepositoryException If the login fails or has been disabled */ @Override public final Session loginAdministrative(final String workspace) throws RepositoryException { final boolean whitelisted = getSlingRepositoryManager().allowLoginAdministrativeForBundle(usingBundle); if(!whitelisted) { final String symbolicName = usingBundle.getSymbolicName(); logger.error("Bundle {} is NOT whitelisted to use SlingRepository.loginAdministrative", symbolicName); throw new LoginException("Bundle " + symbolicName +" is NOT whitelisted"); } else if (this.getSlingRepositoryManager().isDisableLoginAdministrative()) { logger.error("SlingRepository.loginAdministrative is disabled. Please use SlingRepository.loginService."); throw new LoginException("SlingRepository.loginAdministrative is disabled."); } logger.debug("SlingRepository.loginAdministrative is deprecated. Please use SlingRepository.loginService."); return createAdministrativeSession(workspace); }
/** * Creates a new service-session. This method is used by {@link #loginService(String, String)} * and {@link #impersonateFromService(String, Credentials, String)} to avoid * code duplication. * * @param usingBundle The bundle using a service session. * @param subServiceName The optional name of the subservice. * @param workspaceName The JCR workspace name or {@code null}. * @return A new service session or {@code null} if neither a user-name nor a * principal names mapping has been defined. * @throws RepositoryException If an error occurs while creating the service session. */ private Session createServiceSession(Bundle usingBundle, String subServiceName, String workspaceName) throws RepositoryException { final ServiceUserMapper serviceUserMapper = this.getSlingRepositoryManager().getServiceUserMapper(); if (serviceUserMapper != null) { final Iterable<String> principalNames = serviceUserMapper.getServicePrincipalNames(usingBundle, subServiceName); if (principalNames != null) { return createServiceSession(principalNames, workspaceName); } final String userName = serviceUserMapper.getServiceUserID(usingBundle, subServiceName); if (userName != null) { return createServiceSession(userName, workspaceName); } } return null; }
@Override public String[] getDescriptorKeys() { Repository repo = getRepository(); if (repo != null) { return repo.getDescriptorKeys(); } logger.error("getDescriptorKeys: Repository not available"); return new String[0]; }
final Dictionary<String, Object> props = getServiceRegistrationProperties(); final String[] interfaces = getServiceRegistrationInterfaces();
/** * This method must be called if overwritten by implementations !! * * @param componentContext */ @Deactivate private void deactivate(final ComponentContext componentContext) { super.stop(); this.adminUserName = null; this.componentContext = null; this.namespaceMapperRefs.clear(); this.namespaceMappers = null; }
/** * Registers node types from the CND file read from the <code>source</code> * with the node type manager available from the given <code>session</code>. * <p> * The <code>NodeTypeManager</code> returned by the <code>session</code>'s * workspace is expected to be of type * <code>org.apache.jackrabbit.api.JackrabbitNodeTypeManager</code> for * the node type registration to succeed. * <p> * This method is not synchronized. It is up to the calling method to * prevent paralell execution. * * @param session The <code>Session</code> providing the node type manager * through which the node type is to be registered. * @param source The <code>InputStream</code> from which the CND file is * read. * @return <code>true</code> if registration of all node types succeeded. * @throws IOException if there is an error parsing the input stream * @throws RepositoryException if another error occurs */ public static boolean registerNodeType(Session session, InputStream source) throws IOException, RepositoryException { return registerNodeType(session, "cnd input stream", new InputStreamReader(source), false); }
/** * This method must be called if overwritten by implementations !! */ @Activate private void activate(final ComponentContext componentContext) throws Exception { this.componentContext = componentContext; @SuppressWarnings("unchecked") Dictionary<String, Object> properties = componentContext.getProperties(); final String defaultWorkspace = PropertiesUtil.toString(properties.get(PROPERTY_DEFAULT_WORKSPACE), null); final boolean disableLoginAdministrative = !PropertiesUtil.toBoolean( properties.get(PROPERTY_LOGIN_ADMIN_ENABLED), DEFAULT_LOGIN_ADMIN_ENABLED); this.adminUserName = PropertiesUtil.toString(properties.get(PROPERTY_ADMIN_USER), DEFAULT_ADMIN_USER); super.start(componentContext.getBundleContext(), defaultWorkspace, disableLoginAdministrative); }
/** * Same as calling {@code login(credentials, null)}. * <p> * This method may be overwritten. * * @param credentials The {@code Credentials} to use to login. * @return the result of calling {@link #login(Credentials, String) * login(credentials, null)}. * @throws LoginException If login is not possible * @throws RepositoryException If another error occurrs during login * @see #login(Credentials, String) */ @Override public Session login(final Credentials credentials) throws LoginException, RepositoryException { return this.login(credentials, null); }
@Override public Object getService(Bundle bundle, ServiceRegistration registration) { return AbstractSlingRepositoryManager.this.create(bundle); }
public final Session loginService(final String subServiceName, final String workspace) throws LoginException, RepositoryException { Session s = createServiceSession(usingBundle, subServiceName, workspace); if (s != null) { return s;
@Override public boolean isStandardDescriptor(String key) { Repository repo = getRepository(); if (repo != null) { return repo.isStandardDescriptor(key); } logger.error("isStandardDescriptor: Repository not available"); return false; } }
/** * Same as calling {@code login(null, null)}. * <p> * This method may be overwritten. * * @return the result of calling {@link #login(Credentials, String) * login(null, null)}. * @throws LoginException If login is not possible * @throws RepositoryException If another error occurrs during login * @see #login(Credentials, String) */ @Override public Session login() throws LoginException, RepositoryException { return this.login(null, null); }
@Override public String getDescriptor(String name) { Repository repo = getRepository(); if (repo != null) { return repo.getDescriptor(name); } logger.error("getDescriptor: Repository not available"); return null; }
/** * Same as calling {@code login(null, workspace)}. * <p> * This method may be overwritten. * * @param workspace The workspace to access or {@code null} to access the * {@link #getDefaultWorkspace() default workspace} * @return the result of calling {@link #login(Credentials, String) * login(null, workspace)}. * @throws LoginException If login is not possible * @throws RepositoryException If another error occurrs during login * @see #login(Credentials, String) */ @Override public Session login(final String workspace) throws LoginException, NoSuchWorkspaceException, RepositoryException { return this.login(null, workspace); }
@Override public Value getDescriptorValue(String key) { Repository repo = getRepository(); if (repo != null) { return repo.getDescriptorValue(key); } logger.error("getDescriptorValue: Repository not available"); return null; }
@Override public boolean isSingleValueDescriptor(String key) { Repository repo = getRepository(); if (repo != null) { return repo.isSingleValueDescriptor(key); } logger.error("isSingleValueDescriptor: Repository not available"); return false; }
@Override public Value[] getDescriptorValues(String key) { Repository repo = getRepository(); if (repo != null) { return repo.getDescriptorValues(key); } logger.error("getDescriptorValues: Repository not available"); return null; }