Search in sources :

Example 16 with UnprocessableEntityException

use of com.thoughtworks.go.config.exceptions.UnprocessableEntityException in project gocd by gocd.

the class TrackingToolRepresenter method fromJSON.

public static Object fromJSON(JsonReader jsonReader) {
    String type = jsonReader.getString("type");
    JsonReader attributes = jsonReader.readJsonObject("attributes");
    if ("generic".equals(type)) {
        return ExternalTrackingToolRepresenter.fromJSON(attributes);
    }
    throw new UnprocessableEntityException(String.format("Invalid Tracking tool type '%s'. It has to be one of '%s'.", type, String.join(", ", "generic")));
}
Also used : UnprocessableEntityException(com.thoughtworks.go.config.exceptions.UnprocessableEntityException) JsonReader(com.thoughtworks.go.api.representers.JsonReader)

Example 17 with UnprocessableEntityException

use of com.thoughtworks.go.config.exceptions.UnprocessableEntityException in project gocd by gocd.

the class TrackingToolRepresenter method fromJSON.

public static Object fromJSON(JsonReader jsonReader) {
    String type = jsonReader.getString("type");
    JsonReader attributes = jsonReader.readJsonObject("attributes");
    if ("generic".equals(type)) {
        return ExternalTrackingToolRepresenter.fromJSON(attributes);
    }
    throw new UnprocessableEntityException(String.format("Invalid Tracking tool type '%s'. It has to be one of '%s'.", type, String.join(", ", "generic")));
}
Also used : UnprocessableEntityException(com.thoughtworks.go.config.exceptions.UnprocessableEntityException) JsonReader(com.thoughtworks.go.api.representers.JsonReader)

Example 18 with UnprocessableEntityException

use of com.thoughtworks.go.config.exceptions.UnprocessableEntityException in project gocd by gocd.

the class UserService method updateNotificationFilter.

public void updateNotificationFilter(final long userId, final NotificationFilter notificationFilter) {
    notificationFilter.validate(validationContext);
    if (!notificationFilter.errors().isEmpty()) {
        throw new UnprocessableEntityException("Notification filter validation failed.");
    }
    User user = userDao.load(userId);
    user.updateNotificationFilter(notificationFilter);
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            synchronized (enableUserMutex) {
                userDao.saveOrUpdate(user);
            }
        }
    });
}
Also used : UnprocessableEntityException(com.thoughtworks.go.config.exceptions.UnprocessableEntityException) TransactionStatus(org.springframework.transaction.TransactionStatus) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult)

Aggregations

UnprocessableEntityException (com.thoughtworks.go.config.exceptions.UnprocessableEntityException)18 JsonReader (com.thoughtworks.go.api.representers.JsonReader)11 OutputListWriter (com.thoughtworks.go.api.base.OutputListWriter)3 OutputWriter (com.thoughtworks.go.api.base.OutputWriter)3 ErrorGetter (com.thoughtworks.go.api.representers.ErrorGetter)3 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)3 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)3 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)3 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)3 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)3 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)3 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)3 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)3 NotificationFilter (com.thoughtworks.go.domain.NotificationFilter)3 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)3 Arrays.stream (java.util.Arrays.stream)3 HashMap (java.util.HashMap)3 StringUtils.equalsIgnoreCase (org.apache.commons.lang3.StringUtils.equalsIgnoreCase)3 TransactionStatus (org.springframework.transaction.TransactionStatus)2