javaibm-mqrfh2

How to move up subfolders one folder in a mqrfh2-header with java?


I want the SubFolders to move one folder up and delete the "FolderToDelete", since it is useless after moving the needed subfolders up.
The RFH2-Header is structured like this:

<usr>

  <FolderToDelete>

    <SubFolder 1 To Move Up>
    </SubFolder 1 To Move Up>

    <SubFolder 2 To Move Up>
    </SubFolder 2 To Move Up>

    <SubFolder I don't need 1>
    </SubFolder I don't need 1>

    <SubFolder 3 To Move Up>
    </SubFolder 3 To Move Up>

    <SubFolder I don't need 2>
    </SubFolder I don't need 2>

  </FolderToDelete>

</usr>

It tried it like this:

newMsg.setStringProperty("usr.SubFolder 1 To Move Up", message.getStringProperty("usr.FolderToDelete.SubFolder 1 To Move Up"));
newMsg.setStringProperty("usr.SubFolder 2 To Move Up", message.getStringProperty("usr.FolderToDelete.SubFolder 2 To Move Up"));
newMsg.setStringProperty("usr.SubFolder 3 To Move Up", message.getStringProperty("usr.FolderToDelete.SubFolder 3 To Move Up"));

newMsg.deleteProperty("usr.FolderToDelete");

It wasn't working and I got an errormessage for the first line. This is the errormessage:

MQJE001: Completion code '2', Cause '2471'.

The Website http://blog.robiii.nl/2012/01/websphere-mq-reason-codes.html says, that this is the following cause:

2471 09A7 RC2471 MQRC_PROPERTY_NOT_AVAILABLE

But I know that the property is available, I'm sure there's no mistake with the name.

Is it because I am working with subfolders and not with properties? If yes, why is there a difference? Subfolders and properties are simply html-tags with string content in it. There's no difference? How can I work with subfolders, if there are no methods provided by the mq-classes?


Solution

  • Here's the solution, but I won't give any code:
    First, read all the names from the attributes in one array. Filter the array to the names you want to save. Read all the properties by using this list. Save the properties from the list, but cut "FolderToDelete" from the key.

    Done!