Commit af75fe88 authored by Robert Smith's avatar Robert Smith
Browse files

Fixed SerializedItemBuilder JAXB class problem



Fixed a bug with the SerializedItemBuilder where the
ICEJAXBClassProvider was not being used to get a full list of
unmarshalable classes.
Signed-off-by: Robert Smith's avatarRobert Smith <smithrw@ornl.gov>
parent 8224b13d
...@@ -26,6 +26,7 @@ import javax.xml.bind.JAXBException; ...@@ -26,6 +26,7 @@ import javax.xml.bind.JAXBException;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.ice.datastructures.ICEObject.ICEJAXBHandler; import org.eclipse.ice.datastructures.ICEObject.ICEJAXBHandler;
import org.eclipse.ice.datastructures.jaxbclassprovider.ICEJAXBClassProvider;
import org.eclipse.ice.item.jobLauncher.JobLauncher; import org.eclipse.ice.item.jobLauncher.JobLauncher;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -108,7 +109,10 @@ public class SerializedItemBuilder implements ItemBuilder { ...@@ -108,7 +109,10 @@ public class SerializedItemBuilder implements ItemBuilder {
Reader reader = null; Reader reader = null;
ICEJAXBHandler xmlMarshaller = new ICEJAXBHandler(); ICEJAXBHandler xmlMarshaller = new ICEJAXBHandler();
boolean tryAgain = false; boolean tryAgain = false;
ArrayList<Class> classList = new ArrayList<Class>();
// Initialize the class list using ICE's standard JAXB class list.
ArrayList<Class> classList = (ArrayList<Class>) new ICEJAXBClassProvider()
.getClasses();
// The input stream should be legit // The input stream should be legit
if (inputStream != null) { if (inputStream != null) {
...@@ -123,8 +127,8 @@ public class SerializedItemBuilder implements ItemBuilder { ...@@ -123,8 +127,8 @@ public class SerializedItemBuilder implements ItemBuilder {
buffer = new char[1024]; buffer = new char[1024];
try { try {
// Setup the reader // Setup the reader
reader = new BufferedReader(new InputStreamReader(inputStream, reader = new BufferedReader(
"UTF-8")); new InputStreamReader(inputStream, "UTF-8"));
// Load the bytes into the writer // Load the bytes into the writer
while ((numChars = reader.read(buffer)) != -1) { while ((numChars = reader.read(buffer)) != -1) {
writer.write(buffer, 0, numChars); writer.write(buffer, 0, numChars);
...@@ -135,8 +139,8 @@ public class SerializedItemBuilder implements ItemBuilder { ...@@ -135,8 +139,8 @@ public class SerializedItemBuilder implements ItemBuilder {
} }
// Read an input stream from the writer // Read an input stream from the writer
itemReadStream = new ByteArrayInputStream(writer.toString() itemReadStream = new ByteArrayInputStream(
.getBytes()); writer.toString().getBytes());
// Start by trying load the Item as a JobLauncher. Catch any // Start by trying load the Item as a JobLauncher. Catch any
// exceptions so that we can try again. // exceptions so that we can try again.
...@@ -145,10 +149,10 @@ public class SerializedItemBuilder implements ItemBuilder { ...@@ -145,10 +149,10 @@ public class SerializedItemBuilder implements ItemBuilder {
originalItem = (Item) xmlMarshaller.read(classList, originalItem = (Item) xmlMarshaller.read(classList,
itemReadStream); itemReadStream);
} catch (NullPointerException e) { } catch (NullPointerException e) {
logger.error(getClass().getName() + " Exception!",e); logger.error(getClass().getName() + " Exception!", e);
tryAgain = true; tryAgain = true;
} catch (JAXBException e) { } catch (JAXBException e) {
logger.error(getClass().getName() + " Exception!",e); logger.error(getClass().getName() + " Exception!", e);
tryAgain = true; tryAgain = true;
} }
...@@ -165,10 +169,10 @@ public class SerializedItemBuilder implements ItemBuilder { ...@@ -165,10 +169,10 @@ public class SerializedItemBuilder implements ItemBuilder {
originalItem = (Item) xmlMarshaller.read(classList, originalItem = (Item) xmlMarshaller.read(classList,
itemReadStream); itemReadStream);
} catch (NullPointerException e) { } catch (NullPointerException e) {
logger.error(getClass().getName() + " Exception!",e); logger.error(getClass().getName() + " Exception!", e);
tryAgain = true; tryAgain = true;
} catch (JAXBException e) { } catch (JAXBException e) {
logger.error(getClass().getName() + " Exception!",e); logger.error(getClass().getName() + " Exception!", e);
tryAgain = true; tryAgain = true;
} }
} }
...@@ -245,6 +249,7 @@ public class SerializedItemBuilder implements ItemBuilder { ...@@ -245,6 +249,7 @@ public class SerializedItemBuilder implements ItemBuilder {
/* /*
* (non-Javadoc) * (non-Javadoc)
*
* @see org.eclipse.ice.item.ItemBuilder#isPublishable() * @see org.eclipse.ice.item.ItemBuilder#isPublishable()
*/ */
@Override @Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment