ALF-9799 Avoid links and wiki container node wrapping, and handle the case of a listing before any writes (so the container has yet to be created)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29627 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2011-08-09 11:32:14 +00:00
parent 422e1e7f20
commit ed3e2125e5
5 changed files with 40 additions and 26 deletions

View File

@@ -1516,8 +1516,8 @@
<property name="nodeService" ref="NodeService"/> <property name="nodeService" ref="NodeService"/>
<property name="siteService" ref="SiteService"/> <property name="siteService" ref="SiteService"/>
<property name="linksService" ref="LinksService"/> <property name="linksService" ref="LinksService"/>
<property name="personService" ref="PersonService"/>
<property name="activityService" ref="activityService"/> <property name="activityService" ref="activityService"/>
<property name="serviceRegistry" ref="ServiceRegistry"/>
</bean> </bean>
<!-- Lists the Links for a site --> <!-- Lists the Links for a site -->
@@ -1538,8 +1538,8 @@
<property name="nodeService" ref="NodeService"/> <property name="nodeService" ref="NodeService"/>
<property name="siteService" ref="SiteService"/> <property name="siteService" ref="SiteService"/>
<property name="wikiService" ref="WikiService"/> <property name="wikiService" ref="WikiService"/>
<property name="personService" ref="PersonService"/>
<property name="activityService" ref="activityService"/> <property name="activityService" ref="activityService"/>
<property name="serviceRegistry" ref="ServiceRegistry"/>
</bean> </bean>
<!-- Fetches the details of one wiki page --> <!-- Fetches the details of one wiki page -->

View File

@@ -24,13 +24,12 @@ import java.util.Map;
import org.alfresco.query.PagingRequest; import org.alfresco.query.PagingRequest;
import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.jscript.ScriptNode;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.activities.ActivityService; import org.alfresco.service.cmr.activities.ActivityService;
import org.alfresco.service.cmr.links.LinkInfo; import org.alfresco.service.cmr.links.LinkInfo;
import org.alfresco.service.cmr.links.LinksService; import org.alfresco.service.cmr.links.LinksService;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.site.SiteInfo; import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.service.cmr.site.SiteService; import org.alfresco.service.cmr.site.SiteService;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@@ -58,8 +57,8 @@ public abstract class AbstractLinksWebScript extends DeclarativeWebScript
protected NodeService nodeService; protected NodeService nodeService;
protected SiteService siteService; protected SiteService siteService;
protected LinksService linksService; protected LinksService linksService;
protected PersonService personService;
protected ActivityService activityService; protected ActivityService activityService;
protected ServiceRegistry serviceRegistry;
public void setNodeService(NodeService nodeService) public void setNodeService(NodeService nodeService)
{ {
@@ -76,16 +75,16 @@ public abstract class AbstractLinksWebScript extends DeclarativeWebScript
this.linksService = linksService; this.linksService = linksService;
} }
public void setPersonService(PersonService personService)
{
this.personService = personService;
}
public void setActivityService(ActivityService activityService) public void setActivityService(ActivityService activityService)
{ {
this.activityService = activityService; this.activityService = activityService;
} }
public void setServiceRegistry(ServiceRegistry serviceRegistry)
{
this.serviceRegistry = serviceRegistry;
}
protected String getOrNull(JSONObject json, String key) throws JSONException protected String getOrNull(JSONObject json, String key) throws JSONException
{ {
@@ -193,8 +192,8 @@ public abstract class AbstractLinksWebScript extends DeclarativeWebScript
} }
else else
{ {
NodeRef person = serviceRegistry.getPersonService().getPerson(creator); NodeRef person = personService.getPerson(creator);
creatorO = new ScriptNode(person, serviceRegistry); creatorO = person;
} }
res.put("creator", creatorO); res.put("creator", creatorO);

View File

@@ -26,13 +26,11 @@ import java.util.Map;
import org.alfresco.query.PagingRequest; import org.alfresco.query.PagingRequest;
import org.alfresco.query.PagingResults; import org.alfresco.query.PagingResults;
import org.alfresco.repo.jscript.ScriptNode;
import org.alfresco.repo.links.LinksServiceImpl; import org.alfresco.repo.links.LinksServiceImpl;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.links.LinkInfo; import org.alfresco.service.cmr.links.LinkInfo;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.site.SiteInfo; import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.util.ScriptPagingDetails;
import org.json.JSONObject; import org.json.JSONObject;
import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.Status;
@@ -137,15 +135,24 @@ public class LinksListGet extends AbstractLinksWebScript
} }
else else
{ {
// Find the container (if it's been created yet)
container = siteService.getContainer( container = siteService.getContainer(
site.getShortName(), LinksServiceImpl.LINKS_COMPONENT site.getShortName(), LinksServiceImpl.LINKS_COMPONENT
); );
if(container == null)
{
// Brand new site, no write operations on links have happened
// Fudge it for now with the site itself, the first write call
// will have the container created
container = site.getNodeRef();
}
} }
// All done // All done
Map<String, Object> model = new HashMap<String, Object>(); Map<String, Object> model = new HashMap<String, Object>();
model.put("data", data); model.put("data", data);
model.put("links", new ScriptNode(container, serviceRegistry)); model.put("links", container);
model.put("siteId", site.getShortName()); model.put("siteId", site.getShortName());
model.put("site", site); model.put("site", site);
return model; return model;

View File

@@ -24,12 +24,11 @@ import java.util.Map;
import org.alfresco.query.PagingRequest; import org.alfresco.query.PagingRequest;
import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.jscript.ScriptNode;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.activities.ActivityService; import org.alfresco.service.cmr.activities.ActivityService;
import org.alfresco.service.cmr.links.LinkInfo; import org.alfresco.service.cmr.links.LinkInfo;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.site.SiteInfo; import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.service.cmr.site.SiteService; import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.cmr.wiki.WikiPageInfo; import org.alfresco.service.cmr.wiki.WikiPageInfo;
@@ -64,8 +63,8 @@ public abstract class AbstractWikiWebScript extends DeclarativeWebScript
protected NodeService nodeService; protected NodeService nodeService;
protected SiteService siteService; protected SiteService siteService;
protected WikiService wikiService; protected WikiService wikiService;
protected PersonService personService;
protected ActivityService activityService; protected ActivityService activityService;
protected ServiceRegistry serviceRegistry;
public void setNodeService(NodeService nodeService) public void setNodeService(NodeService nodeService)
{ {
@@ -82,16 +81,16 @@ public abstract class AbstractWikiWebScript extends DeclarativeWebScript
this.wikiService = wikiService; this.wikiService = wikiService;
} }
public void setPersonService(PersonService personService)
{
this.personService = personService;
}
public void setActivityService(ActivityService activityService) public void setActivityService(ActivityService activityService)
{ {
this.activityService = activityService; this.activityService = activityService;
} }
public void setServiceRegistry(ServiceRegistry serviceRegistry)
{
this.serviceRegistry = serviceRegistry;
}
protected String getOrNull(JSONObject json, String key) throws JSONException protected String getOrNull(JSONObject json, String key) throws JSONException
{ {
@@ -195,9 +194,9 @@ public abstract class AbstractWikiWebScript extends DeclarativeWebScript
return ""; return "";
} }
// Script Node needed of the person // Will turn into a Script Node needed of the person
NodeRef person = serviceRegistry.getPersonService().getPerson(username); NodeRef person = personService.getPerson(username);
return new ScriptNode(person, serviceRegistry); return person;
} }
protected Map<String, Object> renderWikiPage(WikiPageInfo page) protected Map<String, Object> renderWikiPage(WikiPageInfo page)

View File

@@ -142,9 +142,18 @@ public class WikiPageListGet extends AbstractWikiWebScript
} }
else else
{ {
// Find the container (if it's been created yet)
container = siteService.getContainer( container = siteService.getContainer(
site.getShortName(), WikiServiceImpl.WIKI_COMPONENT site.getShortName(), WikiServiceImpl.WIKI_COMPONENT
); );
if(container == null)
{
// Brand new site, no write operations on links have happened
// Fudge it for now with the site itself, the first write call
// will have the container created
container = site.getNodeRef();
}
} }
// All done // All done