Skip to content

Commit

Permalink
SAK-50754 sitearchive Cleanup some code and add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish committed Dec 13, 2024
1 parent 1e038f4 commit 8f033cb
Show file tree
Hide file tree
Showing 12 changed files with 589 additions and 248 deletions.
43 changes: 43 additions & 0 deletions common/archive-impl/impl2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,51 @@
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.kernel</groupId>
<artifactId>sakai-kernel-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources />
<testResources>
<testResource>
<directory>${basedir}/src/webapp</directory>
</testResource>
<testResource>
<directory>${basedir}/src/test/resources</directory>
</testResource>
</testResources>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public String archive(String siteId, String m_storagePath, String fromSystem)

dir.mkdirs();

// for each registered ResourceService, give it a chance to archve
// for each registered EntityProducer, give it a chance to archive
Collection<EntityProducer> producers = m_entityManager.getEntityProducers();
for (EntityProducer producer : producers) {
if (producer == null) continue;
Expand Down Expand Up @@ -240,8 +240,8 @@ public String archive(String siteId, String m_storagePath, String fromSystem)
results.append("<===== End =====>\n\n");

stack.pop();
Xml.writeDocument(doc, m_storagePath + siteId + "-archive/site.xml");

Xml.writeDocument(doc, m_storagePath + siteId + "-archive/site.xml");

// *** Users
doc = Xml.createDocument();
Expand Down Expand Up @@ -285,14 +285,13 @@ public String archive(String siteId, String m_storagePath, String fromSystem)


/**
* Archive the site definition.
* @param site the site.
* @param doc The document to contain the xml.
* @param stack The stack of elements, the top of which will be the containing
* element of the "site" element.
*/

protected String archiveSite(Site site, Document doc, Stack stack, String fromSystem)
* Archive the site definition.
* @param site the site.
* @param doc The document to contain the xml.
* @param stack The stack of elements, the top of which will be the containing
* element of the "site" element.
*/
private String archiveSite(Site site, Document doc, Stack stack, String fromSystem)
{
Element element = doc.createElement(SiteService.APPLICATION_ID);
((Element)stack.peek()).appendChild(element);
Expand All @@ -314,7 +313,7 @@ protected String archiveSite(Site site, Document doc, Stack stack, String fromSy

if ( pattern != null ) {
NodeList nl = siteNode.getElementsByTagName("property");
List<Element> toRemove = new ArrayList<Element>();
List<Element> toRemove = new ArrayList<>();

for(int i = 0; i < nl.getLength(); i++) {
Element proptag = (Element)nl.item(i);
Expand Down Expand Up @@ -389,11 +388,11 @@ protected String archiveSite(Site site, Document doc, Stack stack, String fromSy
}
catch(Exception any)
{
log.warn("archve: exception archiving site: {}: {}", site.getId(), any);
log.warn("Exception archiving site: {}: {}", site.getId(), any.toString());
}

stack.pop();

return "archiving Site: " + site.getId() + "\n";

} // archiveSite
Expand Down
Loading

0 comments on commit 8f033cb

Please sign in to comment.