Change the period of validity for a subscription.

@param subscription the subscription.
@param newValidity the new validity .
@return the updated subscription.
515830
public Subscription limitValidity( String subscription, String newValidity ) {
    return limitValidity( new Subscription( subscription ), newValidity );
  }
328624
function (id) {
      var custom = later[id];
      if(!custom) throw new Error('Custom time period ' + id + ' not recognized!');

      add(id, custom.extent(new Date())[0], custom.extent(new Date())[1]);
      return this;
    }
426814
function valErrsChanged(newValue) {

                    // HTML5 custom validity
                    // http://dev.w3.org/html5/spec-preview/constraints.html#the-constraint-validation-api
                    if (domEl.setCustomValidity) {
                        /* only works in HTML 5. Maybe should throw if not available. */
                        domEl.setCustomValidity(newValue || '');
                    }

                    var errorHtml = newValue ? valTemplate.replace(/%error%/, newValue) : "";
                    var isRequired = info.getIsRequired();
                    var requiredHtml = isRequired ? requiredTemplate : '';
                    decorator.innerHTML = (isRequired || !!errorHtml) ? requiredHtml + errorHtml : "";
                }
1118189
public T set(final T newValue) {
        if(continuous!=null)
         continuous.offer(newValue);

        setDiscreteIfDiff(newValue);
        return newValue;
    }
1189900
void setValidityCheck(PassFactory validityCheck) {
    this.validityCheck = validityCheck;
    this.changeVerifier = new ChangeVerifier(compiler).snapshot(jsRoot);
  }
675349
@Override
	public Date whenToValidate(Notify type, Date lastValidated) {
		switch(type) {
			case Approval:
			case PasswordExpiration:
				return null;
			default:
				GregorianCalendar gc = new GregorianCalendar();
				gc.setTime(lastValidated);
				gc.add(GregorianCalendar.MONTH, 6);  // 6 month policy
				return gc.getTime();
		}
	}
589146
public void setSubscriptions(List<String> subscriptions) {
        this.subscriptions.clear();
        if(subscriptions == null) return;
        for(String currentSubscription: subscriptions) {
            if (this.getNotifierName().equals(AlertService.SupportedNotifier.GUS.getName())) {
                if (currentSubscription.isEmpty() || currentSubscription.length() < 10)
                    throw new IllegalArgumentException("GUS Subscription has to contain subjectId with more than 10 characters.");
            } else if (this.getNotifierName().equals(AlertService.SupportedNotifier.EMAIL.getName())) {

                if (currentSubscription.isEmpty() || !currentSubscription.contains("@")) {
                    String errorMessage = MessageFormat.format("Email Address {0} is not allowed as @ not present.",
                            currentSubscription);
                    throw new IllegalArgumentException(errorMessage);
                }
            } else if (this.getNotifierName().equals(AlertService.SupportedNotifier.CALLBACK.getName()) && currentSubscription.isEmpty()) {
                throw new IllegalArgumentException("Callback Notifier Subscription cannot be empty.");
            }
        }
        if (subscriptions != null && !subscriptions.isEmpty()) {
            this.subscriptions.addAll(subscriptions);
        }
    }
341721
public int subscribe(final String subscriptionName, Object[] params) {
        // add the subscription to the HashMap with its initial value "false" which says that it is not ready
        subscriptionsAreReady.put(subscriptionName, false);
        
        // subscribe to a Meteor collection with given params
        // test error handling for invalid subscription
        return getDDP().subscribe(subscriptionName, params, new DDPListener() {
            @Override
            public void onReady(String id) {
                // mark subscription ready
                subscriptionsAreReady.replace(subscriptionName, true);

                // broadcast that subscription has been updated
                broadcastSubscriptionChanged(subscriptionName,
                        DdpMessageType.READY, null);
            }

            @Override
            public void onResult(Map<String, Object> jsonFields) {
                String msgtype = (String) jsonFields
                        .get(DdpMessageField.MSG);
                // ignore {"server_id":"GqrKrbcSeDfTYDkzQ"} web socket msgs
                if ((msgtype != null) && (msgtype.equals(DdpMessageType.ERROR))) {
                    broadcastDDPError((String) jsonFields
                            .get(DdpMessageField.ERRORMSG));
                }
            }
        });
    }
644423
public TimedPhase getNextTimedPhase(final DefaultSubscriptionBase subscription, final DateTime effectiveDate, final Catalog catalog, final InternalTenantContext context) {

        try {
            final SubscriptionBaseTransition pendingOrLastPlanTransition;
            if (subscription.getState() == EntitlementState.PENDING) {
                pendingOrLastPlanTransition = subscription.getPendingTransition();
            } else {
                pendingOrLastPlanTransition = subscription.getLastTransitionForCurrentPlan();
            }

            switch (pendingOrLastPlanTransition.getTransitionType()) {
                // If we never had any Plan change, borrow the logic for createPlan alignment
                case CREATE:
                case TRANSFER:
                    final List<TimedPhase> timedPhases = getTimedPhaseOnCreate(subscription.getAlignStartDate(),
                                                                               subscription.getBundleStartDate(),
                                                                               pendingOrLastPlanTransition.getNextPlan(),
                                                                               pendingOrLastPlanTransition.getNextPhase().getPhaseType(),
                                                                               catalog,
                                                                               // Use the catalog version at subscription creation time: this allows
                                                                               // for PHASE events and uncancel operations for plans/products/pricelists already retired
                                                                               // This is not 100% correct in a scenario where the catalog was updated and the alignment rules changed since
                                                                               // See https://github.com/killbill/killbill/issues/784
                                                                               subscription.getAlignStartDate(),
                                                                               context);
                    return getTimedPhase(timedPhases, effectiveDate, WhichPhase.NEXT);
                case CHANGE:
                    return getTimedPhaseOnChange(subscription.getAlignStartDate(),
                                                 subscription.getBundleStartDate(),
                                                 pendingOrLastPlanTransition.getPreviousPhase(),
                                                 pendingOrLastPlanTransition.getPreviousPlan(),
                                                 pendingOrLastPlanTransition.getNextPlan(),
                                                 effectiveDate,
                                                 // Same remark as above
                                                 subscription.getAlignStartDate(),
                                                 pendingOrLastPlanTransition.getEffectiveTransitionTime(),
                                                 subscription.getAllTransitions().get(0).getNextPhase().getPhaseType(),
                                                 null,
                                                 WhichPhase.NEXT,
                                                 catalog,
                                                 context);
                default:
                    throw new SubscriptionBaseError(String.format("Unexpected initial transition %s for current plan %s on subscription %s",
                                                                  pendingOrLastPlanTransition.getTransitionType(), subscription.getCurrentPlan(), subscription.getId()));
            }
        } catch (Exception /* SubscriptionBaseApiException, CatalogApiException */ e) {
            throw new SubscriptionBaseError(String.format("Could not compute next phase change for subscription %s", subscription.getId()), e);
        }
    }
1290917
public boolean setNewAssignee(DefaultIssue issue, @Nullable String newAssigneeUuid, IssueChangeContext context) {
    if (newAssigneeUuid == null) {
      return false;
    }
    checkState(issue.assignee() == null, "It's not possible to update the assignee with this method, please use assign()");
    issue.setFieldChange(context, ASSIGNEE, UNUSED, newAssigneeUuid);
    issue.setAssigneeUuid(newAssigneeUuid);
    issue.setUpdateDate(context.date());
    issue.setChanged(true);
    issue.setSendNotifications(true);
    return true;
  }
810320
public Subscription updateSubscription(SubscriptionUpdate subscriptionUpdate) {

		Subscription subscription = ocpiRepository
				.findSubscriptionByAuthorizationToken(subscriptionUpdate.authorizationToken);

		subscription.getEndpoints().clear();
		// store business details, version and endpoints for this subscription
		io.motown.ocpi.persistence.entities.BusinessDetails businessDetails = new io.motown.ocpi.persistence.entities.BusinessDetails();
		businessDetails.setName(subscriptionUpdate.credentials.business_details.name);
		businessDetails.setWebsite(subscriptionUpdate.credentials.business_details.website);

		subscription.setPartnerAuthorizationToken(subscriptionUpdate.credentials.token);

		subscription.setOcpiVersion(subscriptionUpdate.versionDetails.version);
		for (io.motown.ocpi.dto.Endpoint endpointDto : subscriptionUpdate.versionDetails.endpoints) {

			Endpoint endpoint = new Endpoint();
			endpoint.setIdentifier(endpointDto.identifier);
			endpoint.setUrl(endpointDto.url);
			// because the endpoints in 'versionInformationResponse' are not
			// DTO's (yet) we must instantiate ModuleIdentifier from value
			subscription.addToEndpoints(endpoint);
		}
		// generate new token which will invalidate the token that existed
		subscription.generateNewAuthorizationToken();

		return ocpiRepository.insertOrUpdate(subscription);
	}
1252428
public void validateCriteriaAndAddStrategy(final IBaseResource theResource) {
		String criteria = mySubscriptionCanonicalizer.getCriteria(theResource);
		try {
			SubscriptionMatchingStrategy strategy = mySubscriptionStrategyEvaluator.determineStrategy(criteria);
			mySubscriptionCanonicalizer.setMatchingStrategyTag(theResource, strategy);
		} catch (InvalidRequestException | DataFormatException e) {
			throw new UnprocessableEntityException("Invalid subscription criteria submitted: " + criteria + " " + e.getMessage());
		}
	}
390680
def modify_subscription_status(netid, subscription_code, status):
    
    url = _netid_subscription_url(netid, subscription_code)
    body = {
        'action': 'modify',
        'value': str(status)
    }

    response = post_resource(url, json.dumps(body))
    return _json_to_subscriptions(response)
3366
@Override
  public void validateUpdate(ResourcePool newPool) {
    // Replacement must be of the same ResourceType
    if (!this.getType().equals(newPool.getType())) {
      throw new IllegalArgumentException("ResourceType " + newPool.getType() + " can not replace " + this.getType());
    }
    // Replacement must have the same persistence
    if (this.isPersistent() != newPool.isPersistent()) {
      throw new IllegalArgumentException("ResourcePool for " + newPool.getType() + " with isPersistent="
          + newPool.isPersistent() + " can not replace isPersistent=" + this.isPersistent());
    }
  }
47992
public function setValidityPeriod(\DateInterval $validityPeriod = null): self
    {
        if (null !== $validityPeriod &&
            ($validityPeriod->i < ValidityPeriods::MIN || $validityPeriod->i > ValidityPeriods::MAX)
        ) {
            throw new InvalidValidityPeriodException();
        }

        $this->validityPeriod = $validityPeriod;

        return $this;
    }
703342
private void setPeriodInternal(ReadablePeriod period) {
        int[] newValues = new int[size()];
        for (int i = 0, isize = period.size(); i < isize; i++) {
            DurationFieldType type = period.getFieldType(i);
            int value = period.getValue(i);
            checkAndUpdate(type, newValues, value);
        }
        setValues(newValues);
    }
1216611
function interval(period, scheduler) {
    if (period === void 0) {
        period = 0;
    }
    if (scheduler === void 0) {
        scheduler = _scheduler_async__WEBPACK_IMPORTED_MODULE_1__["async"];
    }
    if (!Object(_util_isNumeric__WEBPACK_IMPORTED_MODULE_2__["isNumeric"])(period) || period < 0) {
        period = 0;
    }
    if (!scheduler || typeof scheduler.schedule !== 'function') {
        scheduler = _scheduler_async__WEBPACK_IMPORTED_MODULE_1__["async"];
    }
    return new _Observable__WEBPACK_IMPORTED_MODULE_0__["Observable"](function (subscriber) {
        subscriber.add(scheduler.schedule(dispatch, period, { subscriber: subscriber, counter: 0, period: period }));
        return subscriber;
    });
}