@Override public URI getAreaIdentifier(IArea area) throws SiteWhereException { return createUri(SITEWHERE_PROTOCOL + "area/" + area.getToken()); }
public Builder(String token, String name, IArea area) { request.setToken(token); request.setName(name); request.setAreaToken(area.getToken()); }
@Override public void handleDeviceRegistration(IDeviceRegistrationPayload registration) throws SiteWhereException { Authentication previous = SecurityContextHolder.getContext().getAuthentication(); try { Authentication system = getMicroservice().getSystemUser() .getAuthenticationForTenant(getTenantEngine().getTenant()); SecurityContextHolder.getContext().setAuthentication(system); IDevice device = getOrCreateDevice(registration); // Find assignment metadata that should be associated. ICustomer customer = getCustomerFor(registration); IArea area = getAreaFor(registration); // Make sure device is assigned. if (device.getDeviceAssignmentId() == null) { getLogger().debug("Handling unassigned device for registration."); DeviceAssignmentCreateRequest assnCreate = new DeviceAssignmentCreateRequest(); assnCreate.setDeviceToken(device.getToken()); if (customer != null) { assnCreate.setCustomerToken(customer.getToken()); } if (area != null) { assnCreate.setAreaToken(area.getToken()); } getDeviceManagement().createDeviceAssignment(assnCreate); } boolean isNewRegistration = (device != null); sendRegistrationAck(registration.getDeviceToken(), isNewRegistration); } finally { SecurityContextHolder.getContext().setAuthentication(previous); } }
throw new SiteWhereException("Invalid area reference: " + criteria.getAreaToken()); html += " belonging to area <a href=\"" + relativePath + "/areas/" + area.getToken() + ".html\">" + area.getName() + "</a>";