Optional<Updates> findOneBySuAndUuidAndDevice(String su, String uuid, Device device);
+ Optional<Updates> findOneBySuAndDeviceAndType(String su, Device device, String type);
+
}
*/
void confirm(String uuid, Device device);
+ /**
+ * Get updates data by update type
+ *
+ * @param device the Device entity
+ * @param type the update type
+ * @return the update data entity
+ */
+ Optional<Updates> find(Device device, String type);
+
}
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.slf4j.*;
+
+import java.time.Instant;
import java.util.Optional;
import static com.samsung.samserver.config.ApplicationProperties.DeviceSettings;
" \"lock\": " + unlocked.getLock() + "\n" +
"}\n";
}
+
String uuid = updatesService.getUpdateUID(type, out);
- Optional<Updates> u = updatesService.find(uuid, device);
+ Optional<Updates> u = updatesService.find(device, type);
if (!u.isPresent()) {
- String uri = "/api/device-service/get-udata?duid="+device.getDuid()+"&uuid="+uuid;
- updatesService.save(new Updates(uuid, type, uri, null, "action:settings updates", out, device));
+ u = Optional.of(
+ new Updates()
+ .type(type)
+ .descr("action:settings updates")
+ .device(device)
+ .su("n")
+ );
}
+
+ updatesService.save(
+ u.get()
+ .uuid(uuid)
+ .uri( "/api/device-service/get-udata?duid="+device.getDuid()+"&uuid="+uuid)
+ .rdate(Instant.now())
+ .ctime(Instant.now())
+ .data(out)
+ );
}
}
* @param data update data
* @return the String
*/
+ @Override
public String getUpdateUID(String type, String data){
return DigestUtils.sha256Hex(type + data);
}
}
}
+ /**
+ * Get updates data by update type
+ *
+ * @param device the Device entity
+ * @param type the update type
+ * @return the update data entity
+ */
+ @Override
+ @Transactional
+ public Optional<Updates> find(Device device, String type){
+ log.debug("Request to get updates Data by update type: {}, {}", device, type);
+ return updatesRepository.findOneBySuAndDeviceAndType("n", device, type);
+ }
+
}