Skip to content

Commit

Permalink
Merge pull request #111 from devicehive/hotfix
Browse files Browse the repository at this point in the history
Hotfix #107, #109
  • Loading branch information
demon-xxi committed Oct 12, 2015
2 parents 3fb5f71 + 9b549c3 commit bc0e3c8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.devicehive</groupId>
<artifactId>devicehive-server</artifactId>
<packaging>${packaging.type}</packaging>
<version>2.0.7</version>
<version>2.0.8</version>
<name>DeviceHive Java Server</name>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
@Component
public class SubscriptionManager {

private final CommandSubscriptionStorage commandSubscriptionStorage
= new CommandSubscriptionStorage();
private final CommandUpdateSubscriptionStorage commandUpdateSubscriptionStorage =
new CommandUpdateSubscriptionStorage();
private final NotificationSubscriptionStorage notificationSubscriptionStorage =
new NotificationSubscriptionStorage();
private final CommandSubscriptionStorage commandSubscriptionStorage = new CommandSubscriptionStorage();
private final CommandUpdateSubscriptionStorage commandUpdateSubscriptionStorage = new CommandUpdateSubscriptionStorage();
private final NotificationSubscriptionStorage notificationSubscriptionStorage = new NotificationSubscriptionStorage();

public CommandSubscriptionStorage getCommandSubscriptionStorage() {
return commandSubscriptionStorage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ private void getOrWaitForCommands(HivePrincipal principal, final String devices,
if (timestamp != null) {
list = commandService.find(deviceGuids, commandNames, timestamp, null, Constants.DEFAULT_TAKE, false, principal);
}
// polling expects only commands after timestamp to be returned
list.removeIf(c -> !c.getTimestamp().after(timestamp));

if (!list.isEmpty()) {
Response response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ private void getOrWaitForNotifications(final HivePrincipal principal, final Stri
DEFAULT_TAKE, principal);
}

// polling expects only notifications after timestamp to be returned
list.removeIf(n -> !n.getTimestamp().after(timestamp));

if (!list.isEmpty()) {
Response response;
if (isMany) {
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/devicehive/service/DeviceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,13 @@ public List<Device> getList(String name,
@Transactional(propagation = Propagation.SUPPORTS)
//TODO: need to remove it
public long getAllowedDevicesCount(HivePrincipal principal, List<String> guids) {
return getDeviceList(guids, principal).size();
final CriteriaBuilder cb = genericDAO.criteriaBuilder();
final CriteriaQuery<Device> criteria = cb.createQuery(Device.class);
final Root<Device> from = criteria.from(Device.class);
final Predicate[] predicates = CriteriaHelper.deviceListPredicates(cb, from, guids, Optional.ofNullable(principal));
criteria.where(predicates);
final TypedQuery<Device> query = genericDAO.createQuery(criteria);
return query.getResultList().size();
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public class HiveWebsocketSessionState {
private final Set<UUID> commandSubscriptions = Collections.newSetFromMap(new ConcurrentHashMap<>());
private final Set<UUID> commandUpdateSubscriptions = Collections.newSetFromMap(new ConcurrentHashMap<>());
private final Lock commandSubscriptionsLock = new ReentrantLock(true);
private final Set<UUID> notificationSubscriptions =
Collections.newSetFromMap(new ConcurrentHashMap<>());
private final Set<UUID> notificationSubscriptions = Collections.newSetFromMap(new ConcurrentHashMap<>());
private final Lock notificationSubscriptionsLock = new ReentrantLock(true);
private final Lock commandUpdateSubscriptionsLock = new ReentrantLock(true);
private final ConcurrentMap<Set<String>, Set<UUID>> oldFormatCommandSubscriptions = Maps.newConcurrentMap();
Expand Down

0 comments on commit bc0e3c8

Please sign in to comment.