Skip to content

Commit

Permalink
SAK-29427: Add properties to it if webdav-copying a reading list (sak…
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaswilson100 authored and ottenhoff committed Apr 26, 2016
1 parent ff2755e commit 212f819
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.osid.repository.Asset;
import org.sakaiproject.entity.api.Entity;
import org.sakaiproject.entity.api.EntityProducer;
import org.sakaiproject.entity.api.Reference;
import org.sakaiproject.exception.IdUnusedException;

import org.sakaiproject.citation.api.Citation;
Expand Down Expand Up @@ -190,6 +191,11 @@ public interface CitationService extends EntityProducer
* @param citation
*/
public void save(Citation citation);
/**
* This method copies a collection and all the citations it contains.
* @param reference The reference of the content resource to copy
*/
public void copyCitationCollection(Reference reference);

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5703,7 +5703,7 @@ public void setAttemptToMatchSchema(boolean attemptToMatchSchema)
/**
* @param reference
*/
private void copyCitationCollection(Reference reference)
public void copyCitationCollection(Reference reference)
{
ContentHostingService contentService = (ContentHostingService) ComponentManager.get(ContentHostingService.class);
try
Expand Down
4 changes: 4 additions & 0 deletions dav/dav/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
<groupId>org.sakaiproject</groupId>
<artifactId>sakai-dav-common</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject</groupId>
<artifactId>sakai-citations-api</artifactId>
</dependency>
<!-- in tomcat common, so no need to bundle -->
<!--
<dependency>
Expand Down
26 changes: 25 additions & 1 deletion dav/dav/src/java/org/sakaiproject/dav/DavServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@

import org.apache.catalina.util.DOMWriter;
import org.apache.tomcat.util.buf.UDecoder;
import org.sakaiproject.citation.api.CitationService;
import org.sakaiproject.content.api.ContentHostingService;
import org.sakaiproject.dav.MD5Encoder;
import org.apache.catalina.util.XMLWriter;
import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -547,6 +549,10 @@ private SimpleDateFormat[] dateFormats()

private ContentHostingService contentHostingService;

private CitationService citationService;

private org.sakaiproject.entity.api.EntityManager entityManager;

private AliasService aliasService;

// --------------------------------------------------------- Public Methods
Expand All @@ -557,6 +563,8 @@ private SimpleDateFormat[] dateFormats()
public void init() throws ServletException
{
contentHostingService = (ContentHostingService) ComponentManager.get(ContentHostingService.class.getName());
citationService = ComponentManager.get(CitationService.class);
entityManager = ComponentManager.get(org.sakaiproject.entity.api.EntityManager.class);
aliasService = ComponentManager.get(AliasService.class);

// Set our properties from the initialization parameters
Expand Down Expand Up @@ -1879,7 +1887,9 @@ private String doContent(String id, HttpServletRequest req, HttpServletResponse
else
{
// Similar to handleAccessResource() in BaseContentService.java


req.getSession().setAttribute("resourceType", resource.getResourceType());

contentStream = resource.streamContent();

if (contentStream == null || len == 0)
Expand Down Expand Up @@ -2777,6 +2787,13 @@ protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws Se
if (newfile)
{
edit = contentHostingService.addResource(resourcePath);

String resourceType = (String) req.getSession().getAttribute("resourceType");
if ("org.sakaiproject.citation.impl.CitationList".equalsIgnoreCase(resourceType))
{
edit.setResourceType(resourceType);
edit.getProperties().addProperty(ContentHostingService.PROP_ALTERNATE_REFERENCE, "/citation");
}
final ResourcePropertiesEdit p = edit.getPropertiesEdit();
p.addProperty(ResourceProperties.PROP_DISPLAY_NAME, name);

Expand All @@ -2800,6 +2817,13 @@ protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws Se
// commit the change
contentHostingService.commitResource(edit, NotificationService.NOTI_NONE);

if ("org.sakaiproject.citation.impl.CitationList".equalsIgnoreCase(edit.getResourceType()))
{
Reference reference = entityManager.newReference(edit.getReference());
citationService.copyCitationCollection(reference);
}


}
catch (IdUsedException e)
{
Expand Down

0 comments on commit 212f819

Please sign in to comment.