class ApplicationsResource extends RealmAwareResource {

    @Override
    public Promise<ResourceResponse, ResourceException> updateInstance(Context context, String resourceId,
            UpdateRequest request) {

        final Subject subject = getContextSubject(context);
        if (subject == null) {
            debug.error("ApplicationsResource :: UPDATE : Unknown Subject");
            return new BadRequestException().asPromise();
        }

        final String realm = getRealm(context);
        try {
            ApplicationWrapper applicationWrapper = createApplicationWrapper(request.getContent(), subject);
            ensureApplicationIdMatch(applicationWrapper, resourceId);
            if (!applicationExists(resourceId, realm, subject)) {
                throw new EntitlementException(EntitlementException.NOT_FOUND, resourceId);
            }
            Application application = appService(subject, realm).saveApplication(applicationWrapper.getApplication());
            return newResultPromise(newResourceResponse(application.getName(),
                    Long.toString(application.getLastModifiedDate()), applicationToJson(application)));
        } catch (EntitlementException e) {
            debug.error("ApplicationsResource :: UPDATE by {}: Error performing update operation.",
                    getPrincipalNameFromSubject(subject), e);
            return exceptionMappingHandler.handleError(context, request, e).asPromise();
        }
    }

    @Inject public  ApplicationsResource(@Named("frRest") Debug debug, ApplicationServiceFactory applicationServiceFactory,
            ApplicationTypeManagerWrapper appTypeManagerWrapper,
            ExceptionMappingHandler<EntitlementException, ResourceException> exceptionMappingHandler);

}