本文整理匯總了Java中org.alfresco.service.cmr.subscriptions.PrivateSubscriptionListException類的典型用法代碼示例。如果您正苦於以下問題:Java PrivateSubscriptionListException類的具體用法?Java PrivateSubscriptionListException怎麽用?Java PrivateSubscriptionListException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PrivateSubscriptionListException類屬於org.alfresco.service.cmr.subscriptions包,在下文中一共展示了PrivateSubscriptionListException類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkRead
import org.alfresco.service.cmr.subscriptions.PrivateSubscriptionListException; //導入依賴的package包/類
/**
* Checks if the current user is allowed to get subscription data.
*/
protected void checkRead(String userId, boolean checkPrivate)
{
if (userId == null)
{
throw new IllegalArgumentException("User Id may not be null!");
}
if (!checkPrivate)
{
return;
}
String currentUser = AuthenticationUtil.getRunAsUser();
if (currentUser == null)
{
throw new IllegalArgumentException("No current user!");
}
if (currentUser.equalsIgnoreCase(userId) || authorityService.isAdminAuthority(currentUser)
|| AuthenticationUtil.isRunAsUserTheSystemUser() || !isSubscriptionListPrivate(userId))
{
return;
}
throw new PrivateSubscriptionListException("subscription_service.err.private-list");
}
示例2: testPrivateList
import org.alfresco.service.cmr.subscriptions.PrivateSubscriptionListException; //導入依賴的package包/類
public void testPrivateList() throws Exception
{
final String userId1 = USER_BOB;
final String userId2 = USER_TOM;
assertFalse(subscriptionService.isSubscriptionListPrivate(userId1));
subscriptionService.setSubscriptionListPrivate(userId1, false);
assertFalse(subscriptionService.isSubscriptionListPrivate(userId1));
subscriptionService.setSubscriptionListPrivate(userId1, true);
assertTrue(subscriptionService.isSubscriptionListPrivate(userId1));
subscriptionService.setSubscriptionListPrivate(userId1, false);
assertFalse(subscriptionService.isSubscriptionListPrivate(userId1));
subscriptionService.setSubscriptionListPrivate(userId1, true);
assertTrue(subscriptionService.isSubscriptionListPrivate(userId1));
subscriptionService.follow(userId1, userId2);
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
{
@Override
public Object doWork() throws Exception
{
assertNotNull(subscriptionService.getFollowing(userId1, new PagingRequest(100000, null)));
return null;
}
}, userId1);
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
{
@Override
public Object doWork() throws Exception
{
assertNotNull(subscriptionService.getFollowing(userId1, new PagingRequest(100000, null)));
return null;
}
}, AuthenticationUtil.getAdminUserName());
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
{
@Override
public Object doWork() throws Exception
{
try
{
subscriptionService.getFollowing(userId1, new PagingRequest(100000, null));
fail("Expected PrivateSubscriptionListException!");
} catch (PrivateSubscriptionListException psle)
{
// expected
}
return null;
}
}, userId2);
}
示例3: execute
import org.alfresco.service.cmr.subscriptions.PrivateSubscriptionListException; //導入依賴的package包/類
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
{
if (!subscriptionService.isActive())
{
res.setStatus(404);
return;
}
try
{
String userId = req.getServiceMatch().getTemplateVars().get("userid");
Object obj = executeImpl(userId, req, res);
if (obj instanceof JSONObject || obj instanceof JSONArray)
{
res.setContentEncoding(Charset.defaultCharset().displayName());
res.setContentType(Format.JSON.mimetype() + ";charset=UTF-8");
Writer writer = res.getWriter();
if (obj instanceof JSONObject)
{
((JSONObject) obj).writeJSONString(writer);
} else
{
((JSONArray) obj).writeJSONString(writer);
}
writer.flush();
} else
{
res.setStatus(204);
}
} catch (SubscriptionsDisabledException sde)
{
throw new WebScriptException(404, "Subscription service is disabled!", sde);
} catch (NoSuchPersonException nspe)
{
throw new WebScriptException(404, "Unknown user '" + nspe.getUserName() + "'!", nspe);
} catch (PrivateSubscriptionListException psle)
{
throw new WebScriptException(403, "Subscription list is private!", psle);
} catch (ParseException pe)
{
throw new WebScriptException(400, "Unable to parse JSON!", pe);
} catch (ClassCastException cce)
{
throw new WebScriptException(400, "Unable to parse JSON!", cce);
} catch (IOException ioe)
{
throw new WebScriptException(500, "Unable to serialize JSON!", ioe);
}
}