final String connectorName,
final String objectTypeName,
final long facetId,
final FacetMetaDataOperation operation) {
// Try to find the connector by pretty name, and then if that fails the find by actual name
Connector connector = ConnectorUtils.findConnectorByPrettyName(guestService, uid, connectorName);
if (connector == null) {
connector = Connector.getConnector(connectorName);
}
if (connector != null) {
// Check authorization: is the logged-in user the same as the UID in the key? If not, does the logged-in user
// have coaching access AND access to the FluxtreamCapture connector?
boolean accessAllowed = false;
Long loggedInUserId = null;
try {
loggedInUserId = AuthHelper.getGuestId();
accessAllowed = isOwnerOrAdmin(uid);
if (!accessAllowed) {
final CoachingBuddy coachee = buddiesService.getTrustingBuddy(loggedInUserId, uid);
if (coachee != null) {
accessAllowed = coachee.hasAccessToConnector(connector.getName());
}
}
}
catch (Exception e) {
LOG.error("BodyTrackController.setFacetMetadata(): Exception while trying to check authorization.", e);