Skip to content

Commit

Permalink
MID-8842 ninja - bugfixing in ninja (xml delta report was producing w…
Browse files Browse the repository at this point in the history
…rong elements)
  • Loading branch information
1azyman committed Sep 7, 2023
1 parent c636b05 commit fe8c9f6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public String getOperationName() {
@Override
public ActionResult<Void> execute() throws Exception {
File tempDirectory = createTmpDirectory(options.getTempDirectory());
// todo: Should we log pre-upgrade checks

// pre-upgrade checks
if (!options.isSkipPreCheck()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
import com.evolveum.midpoint.ninja.action.VerifyResult;
import com.evolveum.midpoint.ninja.impl.Log;
import com.evolveum.midpoint.ninja.impl.NinjaException;
import com.evolveum.midpoint.ninja.util.NinjaUtils;
import com.evolveum.midpoint.prism.Objectable;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.schema.DeltaConversionOptions;
import com.evolveum.midpoint.schema.DeltaConvertor;
import com.evolveum.midpoint.schema.validator.*;
import com.evolveum.midpoint.util.LocalizableMessage;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType;

public class VerificationReporter {

Expand Down Expand Up @@ -86,7 +86,7 @@ public void setCreateDeltaFile(boolean createDeltaFile) {
public void destroy() {
if (deltaWriter != null) {
try {
deltaWriter.write("</deltas>\n");
deltaWriter.write(NinjaUtils.XML_DELTAS_SUFFIX);
} catch (IOException ex) {
throw new NinjaException("Couldn't finish file for XML deltas", ex);
}
Expand Down Expand Up @@ -149,11 +149,7 @@ private void initDeltaXmlFile() {
deltaFile.createNewFile();

deltaWriter = new FileWriter(deltaFile, charset);
deltaWriter.write(
"<deltas "
+ "xmlns=\"http://midpoint.evolveum.com/xml/ns/public/common/api-types-3\" "
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ "xsi:type=\"ObjectDeltaListType\">\n");
deltaWriter.write(NinjaUtils.XML_DELTAS_PREFIX);
} catch (IOException ex) {
throw new NinjaException("Couldn't create file for XML deltas " + deltaFile.getPath(), ex);
}
Expand Down Expand Up @@ -228,8 +224,10 @@ private void writeDeltaXml(UpgradeValidationResult result) {

if (deltaWriter != null) {
try {
deltaWriter.write(DeltaConvertor.serializeDelta(
(ObjectDelta) item.getDelta(), DeltaConversionOptions.createSerializeReferenceNames(), "xml"));
ObjectDeltaType deltaType = DeltaConvertor.toObjectDeltaType(item.getDelta());
String xml = prismContext.xmlSerializer()
.serializeRealValue(deltaType, NinjaUtils.DELTA_LIST_DELTA);
deltaWriter.write(xml);
} catch (SchemaException | IOException ex) {
log.error("Couldn't write object delta to XML file", ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;

import javax.xml.namespace.QName;

/**
* Created by Viliam Repan (lazyman).
*/
Expand All @@ -49,7 +51,16 @@ public class NinjaUtils {
"\txmlns:c=\"http://midpoint.evolveum.com/xml/ns/public/common/common-3\"\n" +
"\txmlns:org=\"http://midpoint.evolveum.com/xml/ns/public/common/org-3\">\n";

public static final String XML_OBJECTS_SUFFIX = "</c:objects>";
public static final String XML_OBJECTS_SUFFIX = "</c:objects>\n";

public static final String XML_DELTAS_PREFIX = "<deltas "
+ "xmlns=\"http://midpoint.evolveum.com/xml/ns/public/common/api-types-3\" "
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ "xsi:type=\"ObjectDeltaListType\">\n";

public static final String XML_DELTAS_SUFFIX = "</deltas>\n";

public static final QName DELTA_LIST_DELTA = new QName("http://midpoint.evolveum.com/xml/ns/public/common/api-types-3", "delta");

public static final String JSON_OBJECTS_PREFIX = "[\n";

Expand Down

0 comments on commit fe8c9f6

Please sign in to comment.