Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
  * regarding copyright ownership.  The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
  *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.syncope.client.services.proxy;
public class UserRequestServiceProxy extends SpringServiceProxy implements UserRequestService {
    public UserRequestServiceProxy(final String baseUrlfinal RestTemplate restTemplate) {
        super(baseUrlrestTemplate);
    }
    @Override
    public Response getOptions() {
        return Response.ok()
                .header("Allow""GET,POST,OPTIONS,HEAD")
                .header(isCreateAllowed())
                .build();
    }
    @Override
    public boolean isCreateAllowed() {
        return getRestTemplate().getForObject( + "user/request/create/allowed.json"Boolean.class);
    }
    @Override
    public Response create(final UserRequestTO userRequestTO) {
        UserRequestTO created;
        switch (userRequestTO.getType()) {
            case :
                created = getRestTemplate().postForObject( + "user/request/update"userRequestTO.getUserMod(),
                        UserRequestTO.class);
                break;
            case :
                created = getRestTemplate().getForObject( + "user/request/delete/{userId}"UserRequestTO.class,
                        userRequestTO.getUserId());
                break;
            case :
            default:
                created = getRestTemplate().postForObject( + "user/request/create"userRequestTO.getUserTO(),
                        UserRequestTO.class);
        }
        URI location = URI.create( + "user/request/read/" + created.getId() + ".json");
        return Response.created(location).header(.created.getId()).build();
    }
    @Override
    public List<UserRequestTOlist() {
        return Arrays.asList(getRestTemplate().getForObject( + "user/request/list.json"UserRequestTO[].class));
    }
    @Override
    public UserRequestTO read(final Long requestId) {
        return getRestTemplate().getForObject( + "user/request/read/{requestId}.json"UserRequestTO.class,
                requestId);
    }
    @Override
    public void delete(final Long requestId) {
        getRestTemplate().getForObject( + "user/request/deleteRequest/{requestId}.json"UserRequestTO.class,
                requestId);
    }
New to GrepCode? Check out our FAQ X