001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019package org.apache.hadoop.security.protocolPB;
020
021import java.io.IOException;
022
023import org.apache.hadoop.security.RefreshUserMappingsProtocol;
024import org.apache.hadoop.security.proto.RefreshUserMappingsProtocolProtos.RefreshSuperUserGroupsConfigurationRequestProto;
025import org.apache.hadoop.security.proto.RefreshUserMappingsProtocolProtos.RefreshSuperUserGroupsConfigurationResponseProto;
026import org.apache.hadoop.security.proto.RefreshUserMappingsProtocolProtos.RefreshUserToGroupsMappingsRequestProto;
027import org.apache.hadoop.security.proto.RefreshUserMappingsProtocolProtos.RefreshUserToGroupsMappingsResponseProto;
028
029import com.google.protobuf.RpcController;
030import com.google.protobuf.ServiceException;
031
032public class RefreshUserMappingsProtocolServerSideTranslatorPB implements RefreshUserMappingsProtocolPB {
033
034  private final RefreshUserMappingsProtocol impl;
035  
036  private final static RefreshUserToGroupsMappingsResponseProto 
037  VOID_REFRESH_USER_GROUPS_MAPPING_RESPONSE =
038      RefreshUserToGroupsMappingsResponseProto.newBuilder().build();
039
040  private final static RefreshSuperUserGroupsConfigurationResponseProto
041  VOID_REFRESH_SUPERUSER_GROUPS_CONFIGURATION_RESPONSE = 
042      RefreshSuperUserGroupsConfigurationResponseProto.newBuilder()
043      .build();
044
045  public RefreshUserMappingsProtocolServerSideTranslatorPB(RefreshUserMappingsProtocol impl) {
046    this.impl = impl;
047  }
048  
049  @Override
050  public RefreshUserToGroupsMappingsResponseProto 
051      refreshUserToGroupsMappings(RpcController controller, 
052      RefreshUserToGroupsMappingsRequestProto request)
053      throws ServiceException {
054    try {
055      impl.refreshUserToGroupsMappings();
056    } catch (IOException e) {
057      throw new ServiceException(e);
058    }
059    return VOID_REFRESH_USER_GROUPS_MAPPING_RESPONSE;
060  }
061
062  @Override
063  public RefreshSuperUserGroupsConfigurationResponseProto 
064      refreshSuperUserGroupsConfiguration(RpcController controller,
065      RefreshSuperUserGroupsConfigurationRequestProto request)
066      throws ServiceException {
067    try {
068      impl.refreshSuperUserGroupsConfiguration();
069    } catch (IOException e) {
070      throw new ServiceException(e);
071    }
072    return VOID_REFRESH_SUPERUSER_GROUPS_CONFIGURATION_RESPONSE;
073  }
074}