Activity Service - fix site feed to avoid stacktrace if siteId does not exist

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9484 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2008-06-16 13:57:52 +00:00
parent 8b20de6874
commit bd6c9f3a75

View File

@@ -97,6 +97,8 @@ public class SiteFeedRetrieverWebScript extends DeclarativeWebScript
format = "atomentry"; format = "atomentry";
} }
Map<String, Object> model = new HashMap<String, Object>();
// if site is null then either does not exist or is private (and current user is not admin or a member) - hence return 401 (unauthorised) // if site is null then either does not exist or is private (and current user is not admin or a member) - hence return 401 (unauthorised)
SiteInfo siteInfo = siteService.getSite(siteId); SiteInfo siteInfo = siteService.getSite(siteId);
if (siteInfo == null) if (siteInfo == null)
@@ -104,11 +106,12 @@ public class SiteFeedRetrieverWebScript extends DeclarativeWebScript
String currentUser = AuthenticationUtil.getCurrentUserName(); String currentUser = AuthenticationUtil.getCurrentUserName();
status.setCode(Status.STATUS_UNAUTHORIZED); status.setCode(Status.STATUS_UNAUTHORIZED);
logger.warn("Unable to get site feed entries for '" + siteId + "' (site does not exist or is private) - currently logged in as '" + currentUser +"'"); logger.warn("Unable to get site feed entries for '" + siteId + "' (site does not exist or is private) - currently logged in as '" + currentUser +"'");
return null;
model.put("feedEntries", null);
model.put("siteId", "");
} }
else
Map<String, Object> model = new HashMap<String, Object>(); {
List<String> feedEntries = activityService.getSiteFeedEntries(siteId, format); List<String> feedEntries = activityService.getSiteFeedEntries(siteId, format);
if (format.equals("json")) if (format.equals("json"))
@@ -134,6 +137,7 @@ public class SiteFeedRetrieverWebScript extends DeclarativeWebScript
model.put("feedEntries", activityFeedModels); model.put("feedEntries", activityFeedModels);
model.put("siteId", siteId); model.put("siteId", siteId);
} }
}
return model; return model;
} }