@@ -39,10 +39,6 @@ public class MatlabReleaseInfo {
3939 };
4040
4141 private Map <String , String > versionInfoCache = new HashMap <String , String >();
42-
43- public MatlabReleaseInfo (String matlabRoot ) {
44- this .matlabRoot = new FilePath (new File (matlabRoot ));
45- }
4642
4743 public MatlabReleaseInfo (FilePath matlabRoot ) {
4844 this .matlabRoot = matlabRoot ;
@@ -84,7 +80,29 @@ private Map<String, String> getVersionInfoFromFile() throws MatlabVersionNotFoun
8480 try {
8581 FilePath versionFile = new FilePath (this .matlabRoot , VERSION_INFO_FILE );
8682 if (versionFile .exists ()) {
87- versionInfoCache .putAll (versionFile .act (new RemoteFileOperation ()));
83+ DocumentBuilderFactory dbFactory = DocumentBuilderFactory .newInstance ();
84+ DocumentBuilder dBuilder = dbFactory .newDocumentBuilder ();
85+ Document doc = dBuilder .parse (versionFile .read ());
86+
87+ doc .getDocumentElement ().normalize ();
88+ NodeList nList = doc .getElementsByTagName (VERSION_INFO_ROOT_TAG );
89+
90+ for (int temp = 0 ; temp < nList .getLength (); temp ++) {
91+ Node nNode = nList .item (temp );
92+ if (nNode .getNodeType () == Node .ELEMENT_NODE ) {
93+
94+ Element eElement = (Element ) nNode ;
95+
96+ versionInfoCache .put (RELEASE_TAG , eElement .getElementsByTagName (RELEASE_TAG )
97+ .item (0 ).getTextContent ());
98+ versionInfoCache .put (VERSION_TAG , eElement .getElementsByTagName (VERSION_TAG )
99+ .item (0 ).getTextContent ());
100+ versionInfoCache .put (DESCRIPTION_TAG , eElement
101+ .getElementsByTagName (DESCRIPTION_TAG ).item (0 ).getTextContent ());
102+ versionInfoCache .put (DATE_TAG ,
103+ eElement .getElementsByTagName (DATE_TAG ).item (0 ).getTextContent ());
104+ }
105+ }
88106 }
89107 else if (!this .matlabRoot .exists ()){
90108 throw new NotDirectoryException ("Invalid matlabroot path" );
@@ -99,56 +117,4 @@ else if(!this.matlabRoot.exists()){
99117 }
100118 return versionInfoCache ;
101119 }
102-
103- /*
104- * Static File Callable to perform File operations on specific remote nodes.
105- */
106-
107- private static final class RemoteFileOperation implements FileCallable <Map <String , String >> {
108-
109- private static final long serialVersionUID = 1L ;
110-
111- private Map <String , String > versionInfoCache = new HashMap <String , String >();
112-
113- @ Override
114- public void checkRoles (RoleChecker checker ) throws SecurityException {
115- // No checks to perform
116- }
117-
118- @ SuppressFBWarnings (value = "REC_CATCH_EXCEPTION" ,
119- justification = "Irrespective of exception type, intention is to handle it in same way. Also, there is no intention to propagate any runtime exception up in the hierarchy." )
120- @ Override
121- public Map <String , String > invoke (File versionFile , VirtualChannel channel )
122- throws IOException , InterruptedException {
123-
124- try {
125-
126- DocumentBuilderFactory dbFactory = DocumentBuilderFactory .newInstance ();
127- DocumentBuilder dBuilder = dbFactory .newDocumentBuilder ();
128- Document doc = dBuilder .parse (versionFile );
129- doc .getDocumentElement ().normalize ();
130- NodeList nList = doc .getElementsByTagName (VERSION_INFO_ROOT_TAG );
131-
132- for (int temp = 0 ; temp < nList .getLength (); temp ++) {
133- Node nNode = nList .item (temp );
134- if (nNode .getNodeType () == Node .ELEMENT_NODE ) {
135-
136- Element eElement = (Element ) nNode ;
137-
138- versionInfoCache .put (RELEASE_TAG , eElement .getElementsByTagName (RELEASE_TAG )
139- .item (0 ).getTextContent ());
140- versionInfoCache .put (VERSION_TAG , eElement .getElementsByTagName (VERSION_TAG )
141- .item (0 ).getTextContent ());
142- versionInfoCache .put (DESCRIPTION_TAG , eElement
143- .getElementsByTagName (DESCRIPTION_TAG ).item (0 ).getTextContent ());
144- versionInfoCache .put (DATE_TAG ,
145- eElement .getElementsByTagName (DATE_TAG ).item (0 ).getTextContent ());
146- }
147- }
148- } catch (Exception e ) {
149- throw new IOException ("Error in reading MATLAB VersionInfo file" ,e );
150- }
151- return versionInfoCache ;
152- }
153- }
154- }
120+ }
0 commit comments