Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*************************************************************************
*
* ADOBE CONFIDENTIAL
* __________________
*
* Copyright 2012 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
package com.adobe.cq.social.ugcbase.core;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.adobe.cq.social.scf.utilities.internal.InternalSCFUtilities;
import com.adobe.cq.social.srp.SocialResource;
import com.adobe.cq.social.srp.SocialResourceProvider;
import com.adobe.cq.social.srp.config.SRPConfigurationFactory;
import com.adobe.cq.social.ugcbase.SocialUtils;
import com.adobe.granite.security.user.UserProperties;
import com.day.cq.wcm.webservicesupport.Configuration;
/**
* Static social utilities.
*/
@Deprecated
public final class SocialResourceUtils implements BundleActivator {
public static String GRAVATAR_PREFIX = com.adobe.cq.social.srp.internal.SocialResourceUtils.GRAVATAR_PREFIX;
/**
* Where config definitions are stored. TODO: Temporary This will change once the config location settles down.
*/
public static final String SRP_CONFIGURATION_ROOT =
com.adobe.cq.social.srp.internal.SocialResourceUtils.SRP_CONFIGURATION_ROOT;
public static final String SRP_DEFAULT_CONFIG_PATH =
com.adobe.cq.social.srp.internal.SocialResourceUtils.SRP_DEFAULT_CONFIG_PATH;
private static final Logger LOG = LoggerFactory.getLogger(SocialResourceUtils.class);
private static ServiceTracker tracker;
/**
* Don't ever instantiate this class.
*/
private SocialResourceUtils() {
}
/**
* Checks a path and an action based on the passed in resolver.
* @param resolver the resource resolver to use to evaluate the permissions
* @param path the path to the resource to check
* @param action the action to check
* @return True if the resolver is allowed to take the requested action, otherwise false
*/
public static Boolean checkPermission(final ResourceResolver resolver, final String path, final String action) {
return com.adobe.cq.social.srp.internal.SocialResourceUtils.checkPermission(resolver, path, action);
}
/**
* Gets the first cloud storage provider. Note: Caller must have read access to configuration storage.
* @param resolver the resolver to use
* @return the configuration
* @deprecated No longer using cloud storage, will return the default configuration.
*/
@Deprecated
public static Configuration getFirstCloudStorageConfig(final ResourceResolver resolver) {
return com.adobe.cq.social.srp.internal.SocialResourceUtils.getFirstCloudStorageConfig(resolver);
}
/**
* Returns the user properties denoted by the given userId. The user props are looked for using the
* provided resource resolver, so as to ensure that the user properties are only accessible to users having the
* necessary access rights on the requested user properties.
* @param resolver The {@link ResourceResolver}.
* @param userId The user id for which to retrieve the user properties.
* @return The {@link UserProperties} or null if not found.
*/
public static UserProperties getUserProperties(final ResourceResolver resolver, final String userId) {
return com.adobe.cq.social.srp.internal.SocialResourceUtils.getUserProperties(resolver, userId);
}
/**
* Returns the userProperties avatar URL or {@link InternalSCFUtilities#DEFAULT_AVATAR} if profile has no avatar defined.
* @param userProperties The userProperties (may be null)
* @param absoluteDefaultAvatar The absolute default avatar
* @param size The avatar size (for example, 32x48)
* @return the avatar URL or the default one.
*/
public static String getAvatar(final UserProperties userProperties, final String absoluteDefaultAvatar,
final SocialUtils.AVATAR_SIZE size) {
return com.adobe.cq.social.srp.internal.SocialResourceUtils.getAvatar(userProperties, absoluteDefaultAvatar,
size.toString());
}
/**
* Returns the userProperties avatar URL or {@link InternalSCFUtilities#DEFAULT_AVATAR} if profile has no avatar defined.
* @param userProperties The userProperties (may be null)
* @param absoluteDefaultAvatar The absolute default avatar
* @param size The avatar size (for example, 32)
* @return the avatar URL or the default one.
*/
public static String getAvatar(final UserProperties userProperties, final String absoluteDefaultAvatar,
final String size) {
return com.adobe.cq.social.srp.internal.SocialResourceUtils.getAvatar(userProperties, absoluteDefaultAvatar,
size);
}
/**
* Check if path is non JCR based. Assume that all alternate storage paths have prefix
* {@link SocialUtils#ASI_UGC_PREFIX}, which is enforced in the cloudconfig UI.
* @param path the path to the ugc resource
* @return true if path is of alternate storage type (non jcr)
*/
public static boolean isCloudUGC(final String path) {
return com.adobe.cq.social.srp.internal.SocialResourceUtils.isCloudUGC(path);
}
/**
* Check if a given resource is an instance of SocialResource.
* @param res the resource to check
* @return true if resource is a SocialResource
*/
public static boolean isSocialResource(final Resource res) {
return com.adobe.cq.social.srp.internal.SocialResourceUtils.isSocialResource(res);
}
/**
* Check if a resource is a wrapped resource, and unwrap until a SocialResource is found.
* @param res resource to unwrap
* @return an unwrap resource or null if no SocialResource found
*/
public static SocialResource getSocialResource(final Resource res) {
return com.adobe.cq.social.srp.internal.SocialResourceUtils.getSocialResource(res);
}
/**
* Check to see if the specified exception caused by a jcr InvalidItemStateException. This exception is thrown if
* any of the changes to be persisted conflicts with a change already persisted through another session and the
* implementation is such that this conflict can only be detected at save-time and therefore was not detected
* earlier, at change-time.
* @param e The exception
* @return if caused by InvalidItemStateException
*/
public static boolean causeByInvalidItemStateException(final Exception e) {
return com.adobe.cq.social.srp.internal.SocialResourceUtils.causeByInvalidItemStateException(e);
}
@Override
public void start(final BundleContext context) throws Exception {
synchronized (SocialResourceUtils.class) {
if (tracker == null) {
tracker = new ServiceTracker(context, SRPConfigurationFactory.class.getName(), null);
tracker.open();
}
}
}
public static String getUniqueUGCResourceName(final ResourceResolver resourceResolver, final String ugcPath,
final SocialResourceProvider resourceProvider, final String nodeName) {
return com.adobe.cq.social.srp.internal.SocialResourceUtils.getUniqueUGCResourceName(resourceResolver,
ugcPath, resourceProvider, nodeName);
}
@Override
public synchronized void stop(final BundleContext context) throws Exception {
synchronized (SocialResourceUtils.class) {
if (tracker != null) {
tracker.close();
}
}
}
}