Skip to content

Commit

Permalink
Restore groups in the import and leave settings alone
Browse files Browse the repository at this point in the history
  • Loading branch information
csev committed Feb 5, 2025
1 parent 978633d commit b65b6d1
Showing 1 changed file with 8 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -828,19 +828,14 @@ private static void patchArchive(CCConfig ccConfig, String path) {
if ( changed) Xml.writeDocument(doc, contentXml);
}

// Remove roles / groups / providers data from site.xml
// Remove roles / providers data from site.xml
String siteXml = path + "site.xml";
doc = Xml.readDocument(siteXml);
if ( doc != null ) {
boolean changed = false;
nodeList = doc.getElementsByTagName("roles");
while (nodeList.getLength() > 0) {
Node node = nodeList.item(0);
node.getParentNode().removeChild(node);
changed = true;
}

nodeList = doc.getElementsByTagName("groups");
// Remove ability tags from roles as they include user ids
nodeList = doc.getElementsByTagName("ability");
while (nodeList.getLength() > 0) {
Node node = nodeList.item(0);
node.getParentNode().removeChild(node);
Expand All @@ -853,17 +848,17 @@ private static void patchArchive(CCConfig ccConfig, String path) {
node.getParentNode().removeChild(node);
changed = true;
}
if ( changed) Xml.writeDocument(doc, siteXml);
if (changed) Xml.writeDocument(doc, siteXml);
}

// Patch assignments.xml
// Patch assignments.xml- remove any submissions because it is user data
String assignmentXml = path + "assignment.xml";
doc = Xml.readDocument(assignmentXml);
if ( doc != null ) {
if (doc != null) {
boolean changed = false;

NodeList subNodes = doc.getElementsByTagName("submissions");
for(int i = 0; i < subNodes.getLength(); i++) {
for (int i = 0; i < subNodes.getLength(); i++) {
Node subNode = subNodes.item(i);
NodeList children = subNode.getChildNodes();
for (int j = 0; j < children.getLength(); j++) {
Expand All @@ -872,31 +867,8 @@ private static void patchArchive(CCConfig ccConfig, String path) {
changed = true;
}
}

/* Remove the groups within the groups tag so we have an empty groups tag
<Assignment>
<groups />
</Assignment>
*/
subNodes = doc.getElementsByTagName("groups");
for(int i = 0; i < subNodes.getLength(); i++) {
Node subNode = subNodes.item(i);
while (subNode.hasChildNodes()) {
subNode.removeChild(subNode.getFirstChild());
changed = true;
}
}

subNodes = doc.getElementsByTagName("typeOfAccess");
for(int i = 0; i < subNodes.getLength(); i++) {
Node subNode = subNodes.item(i);
subNode.setTextContent("SITE");
changed = true;
}

if ( changed) Xml.writeDocument(doc, assignmentXml);
if (changed) Xml.writeDocument(doc, assignmentXml);
}

}

private static void addAllArchive(ZipPrintStream out, CCConfig ccConfig, File dir, String path) throws IOException {
Expand Down

0 comments on commit b65b6d1

Please sign in to comment.