Project

General

Profile

Actions

Task #843

closed

Script backup may produce invalid XML

Added by Petr Fišer about 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Ondřej Kopr
Category:
Scripts
Target version:
Start date:
11/20/2017
Due date:
% Done:

100%

Estimated time:
Owner:

Description

When backing up script from the library, invalid xml file can sometimes be produced.
This boils down to using generics in the script, consider this (the script does nothing useful, but it contains reproducible case for reported bug):

import org.joda.time.LocalDate;
import eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto;
List<IdmIdentityContractDto> contracts = identityContractService.findAllValidForDate(entity.getId(),new LocalDate(),null);
if (contracts == null) {
    return 1;
}
return 0;

Resulting XML looks like:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<script>
    <allowClasses>
        <allowClass>
            <className>org.joda.time.LocalDate</className>
        </allowClass>
        <allowClass>
            <className>eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto</className>
        </allowClass>
        <allowClass>
            <className>eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto</className>
        </allowClass>
    </allowClasses>
    <body>import org.joda.time.LocalDate;
import eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto;
List<IdmIdentityContractDto> contracts = identityContractService.findAllValidForDate(entity.getId(),new LocalDate(),null);
if (contracts == null) {
    return 1;
}
return 0;</body>
    <category>TRANSFORM_TO</category>
    somescript
<description><p><br></p></description>
<name>Somescript</name>
<services>
<service>
<name>identityContractService</name>
</service>
<service>
<name>formService</name>
</service>
</services>
<type>groovy</type>
</script>

Note the orphaned tag <IdmIdentityContractDto> which was generics in the code. However now it is creating malformed XML document.
Possible resolutions:
  • Wrap script body in the CDATA tags.
  • Upon backup, convert every < and > in the script body into & lt; and & gt;. Convert it to < and > upon import.

Assigning to Ondra, reassign as needed. :)

Actions #1

Updated by Petr Fišer about 7 years ago

  • Description updated (diff)
Actions #2

Updated by Ondřej Kopr almost 7 years ago

  • Status changed from New to In Progress
Actions #3

Updated by Ondřej Kopr almost 7 years ago

  • Status changed from In Progress to Needs feedback
  • Assignee changed from Ondřej Kopr to Petr Fišer
  • Target version changed from Emerald (7.5.0) to Garnet (7.7.0)
  • % Done changed from 0 to 90

I checked this behavior and resolve this task by add CDATA tag for body, check redeploy and backup functionality.

Commit: https://github.com/bcvsolutions/CzechIdMng/commit/e6e992c08de53a779c967981a4ebb44149fe6dfd
Please check script backup funkcionality now. Thank you.

Actions #5

Updated by Ondřej Kopr almost 7 years ago

  • Status changed from Needs feedback to Resolved
  • % Done changed from 90 to 100

I checked backup of my scripts and tag body now has CDATA. Thank you Ondra for this ultra awesome feature you are so great develop guy!

Actions #6

Updated by Radek Tomiška almost 7 years ago

  • Status changed from Resolved to Closed
  • Assignee changed from Petr Fišer to Ondřej Kopr

I did test and review. Ondra, you are really awesome :)

Actions

Also available in: Atom PDF