(String[] args)
| 19 | |
| 20 | public class EditConfiguration { |
| 21 | public static void main(String[] args) throws IOException, |
| 22 | ParserConfigurationException, SAXException { |
| 23 | |
| 24 | |
| 25 | /*Build the XML configuration |
| 26 | *The XML configuration required is: |
| 27 | * |
| 28 | * <configuration> |
| 29 | * <system> |
| 30 | * <services> |
| 31 | * <ftp/> |
| 32 | * </services> |
| 33 | * </system> |
| 34 | * </configuration> |
| 35 | */ |
| 36 | XMLBuilder builder = new XMLBuilder(); |
| 37 | XML ftp_config = builder.createNewConfig("system", "services", "ftp"); |
| 38 | |
| 39 | Device device = CreateDevice.createDevice(); |
| 40 | device.connect(); |
| 41 | |
| 42 | //Lock the configuration first |
| 43 | boolean isLocked = device.lockConfig(); |
| 44 | if(!isLocked) { |
| 45 | System.out.println("Could not lock configuration. Exit now."); |
| 46 | return; |
| 47 | } |
| 48 | |
| 49 | //Load and commit the configuration |
| 50 | try { |
| 51 | device.loadXMLConfiguration(ftp_config.toString(), "merge"); |
| 52 | device.commit(); |
| 53 | } catch(LoadException | CommitException e) { |
| 54 | System.out.println(e.getMessage()); |
| 55 | return; |
| 56 | } |
| 57 | |
| 58 | //Unlock the configuration and close the device. |
| 59 | device.unlockConfig(); |
| 60 | device.close(); |
| 61 | } |
| 62 | } |
nothing calls this directly
no test coverage detected