Example usage for org.springframework.http HttpMethod PUT

List of usage examples for org.springframework.http HttpMethod PUT

Introduction

In this page you can find the example usage for org.springframework.http HttpMethod PUT.

Prototype

HttpMethod PUT

To view the source code for org.springframework.http HttpMethod PUT.

Click Source Link

Usage

From source file:software.coolstuff.springframework.owncloud.service.impl.rest.OwncloudRestResourceServiceTest.java

@Override
protected void prepare_getQuota_OneFile(URI uri, MediaType mediaType, String testFileContent,
        OwncloudQuota expectedFirst, OwncloudQuota expectedSecond) throws Exception {
    mockServer.expect(requestToWithPrefix(uri)).andExpect(method(HttpMethod.PUT))
            .andExpect(header(HttpHeaders.AUTHORIZATION, getBasicAuthorizationHeader()))
            .andExpect(header(HttpHeaders.CONNECTION, "keep-alive")).andExpect(content().contentType(mediaType))
            .andExpect(content().string(testFileContent)).andRespond(withSuccess());

    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    Mockito.when(userQueryService.getQuota(authentication.getName())).then(new Answer<OwncloudQuota>() {
        private int count = 0;

        @Override/*ww w . j  a v a2s . c o  m*/
        public OwncloudQuota answer(InvocationOnMock invocation) throws Throwable {
            if (count++ == 0) {
                return OwncloudRestQuotaImpl.builder().username(expectedFirst.getUsername())
                        .free(expectedFirst.getFree()).relative(expectedFirst.getRelative())
                        .total(expectedFirst.getTotal()).used(expectedFirst.getUsed()).build();
            }
            return OwncloudRestQuotaImpl.builder().username(expectedSecond.getUsername())
                    .free(expectedSecond.getFree()).relative(expectedSecond.getRelative())
                    .total(expectedSecond.getTotal()).used(expectedSecond.getUsed()).build();
        }
    });
}

From source file:software.coolstuff.springframework.owncloud.service.impl.rest.OwncloudRestUserServiceImpl.java

private void updateOwncloudUserField(String username, UserUpdateField updateField, Object value) {
    log.trace("Create the Message Body for the Change Request of the Attribute {} of User {} on Location {}",
            updateField, username, getLocation());
    Map<String, List<String>> data = new HashMap<>();
    data.put("key", Lists.newArrayList(updateField.getFieldName()));
    if (value != null) {
        data.put("value", Lists.newArrayList(updateField.format(value)));
    }/*from   w  w  w .j a va2 s. co  m*/

    log.debug("Update Attribute {} of User {} on Location {}", updateField, username, getLocation());
    exchange("/cloud/users/{user}", HttpMethod.PUT, multiValuedEntity(data), Ocs.Void.class,
            (authenticatedUser, uri, meta) -> checkFieldUpdate(authenticatedUser, uri, meta, username),
            username);
}

From source file:software.coolstuff.springframework.owncloud.service.impl.rest.OwncloudRestUserServiceImpl.java

private void changeOwncloudUserAvailabilityStatus(String username, boolean status) {
    log.debug("{} User {} on Location {}", status ? "Enable" : "Disable", username, getLocation());
    exchange(/*from   www .j a  v  a  2s . c  o  m*/
            "/cloud/users/{user}/{status}", HttpMethod.PUT, emptyEntity(), Ocs.Void.class, (authenticatedUser,
                    uri, meta) -> checkAvailabilityStatusUpdate(authenticatedUser, uri, meta, username),
            username, status ? "enable" : "disable");
}