private List<Add> appendAddConfiguration(Operation operation) throws WindowsOperationException { List<Add> addList = new ArrayList<Add>(); Gson gson = new Gson(); if (SyncmlCommandType.WIFI.getValue().equals(operation.getCode())) { Add add = new Add(); String operationCode = operation.getCode(); Wifi wifiObject = gson.fromJson((String) operation.getPayLoad(), Wifi.class); String data = "<?xml version="1.0"?><WLANProfile" + "xmlns="http://www.microsoft.com/networking/WLAN/profile/v1"><name>" + wifiObject.getNetworkName() + "</name><SSIDConfig><SSID><name>" + wifiObject.getSsid() + "</name></SSID></SSIDConfig><connectionType>" + wifiObject.getConnectionType() + "</connectionType><connectionMode>" + wifiObject.getConnectionMode() + "</connectionMode><MSM><security><" + "authEncryption><authentication>" + wifiObject.getAuthentication() + "</authentication><encryption>" + wifiObject.getEncryption() + "</encryption></authEncryption><sharedKey><keyType>" + wifiObject.getKeyType() + "</keyType><protected>" + wifiObject.getProtection() + "</protected><keyMaterial>" + wifiObject.getKeyMaterial() + "</keyMaterial></sharedKey></security></MSM></WLANProfile>"; Meta meta = new Meta(); meta.setFormat("chr"); List<Item> items = new ArrayList<Item>(); for (Configure configure : Configure.values()) { if (operationCode != null && operationCode.equals(configure.name())) { Target target = new Target(); target.setLocURI(configure.getCode()); items.get(0).setTarget(target); } } items.get(0).setMeta(meta); items.get(0).setData(data); add.setCommandId(301); add.setItems(items); addList.add(add); return addList; } return null; }
private Item appendGetInfo(Operation operation) { Item item = new Item(); String operationCode = operation.getCode(); for (Info info : Info.values()) { if (operationCode != null && operationCode.equals(info.name())) { Target target = new Target(); target.setLocURI(info.getCode()); item.setTarget(target); } } return item; }
private Item appendExecInfo(Operation operation) { Item item = new Item(); String operationCode = operation.getCode(); for (Command command : Command.values()) { if (operationCode != null && operationCode.equals(command.name())) { Target target = new Target(); target.setLocURI(command.getCode()); item.setTarget(target); } } return item; }
private void generateHeader() { SyncmlHeader sourceHeader = syncmlDocument.getHeader(); SyncmlHeader header = new SyncmlHeader(); header.setMsgID(sourceHeader.getMsgID()); header.setSessionId(sourceHeader.getSessionId()); Target target = new Target(); target.setLocURI(sourceHeader.getSource().getLocURI()); header.setTarget(target); Source source = new Source(); source.setLocURI(sourceHeader.getTarget().getLocURI()); header.setSource(source); replySyncmlDocument.setHeader(header); }