@Override public void read(org.apache.thrift.protocol.TProtocol prot, alter_sentry_role_grant_privilege_result struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.success = new TAlterSentryRoleGrantPrivilegeResponse(); struct.success.read(iprot); struct.setSuccessIsSet(true); } } }
public Object getFieldValue(_Fields field) { switch (field) { case STATUS: return getStatus(); case PRIVILEGE: return getPrivilege(); case PRIVILEGES: return getPrivileges(); } throw new IllegalStateException(); }
public void setFieldValue(_Fields field, Object value) { switch (field) { case STATUS: if (value == null) { unsetStatus(); } else { setStatus((org.apache.sentry.service.thrift.TSentryResponseStatus)value); } break; case PRIVILEGE: if (value == null) { unsetPrivilege(); } else { setPrivilege((TSentryPrivilege)value); } break; case PRIVILEGES: if (value == null) { unsetPrivileges(); } else { setPrivileges((Set<TSentryPrivilege>)value); } break; } }
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case STATUS: return isSetStatus(); case PRIVILEGE: return isSetPrivilege(); case PRIVILEGES: return isSetPrivileges(); } throw new IllegalStateException(); }
(TAlterSentryRoleGrantPrivilegeRequest request) throws TException { final Timer.Context timerContext = sentryMetrics.grantTimer.time(); TAlterSentryRoleGrantPrivilegeResponse response = new TAlterSentryRoleGrantPrivilegeResponse(); try { validateClientVersion(request.getProtocol_version()); response.setStatus(Status.OK()); response.setPrivileges(request.getPrivileges()); if (response.isSetPrivileges() && response.getPrivileges().size() == 1) { response.setPrivilege(response.getPrivileges().iterator().next()); String msg = "Role: " + request.getRoleName() + " doesn't exist"; LOGGER.error(msg, e); response.setStatus(Status.NoSuchObject(msg, e)); } catch (SentryInvalidInputException e) { LOGGER.error(e.getMessage(), e); response.setStatus(Status.InvalidInput(e.getMessage(), e)); } catch (SentryAccessDeniedException e) { LOGGER.error(e.getMessage(), e); response.setStatus(Status.AccessDenied(e.getMessage(), e)); } catch (SentryGroupNotFoundException e) { LOGGER.error(e.getMessage(), e); response.setStatus(Status.AccessDenied(e.getMessage(), e)); } catch (SentryThriftAPIMismatchException e) { LOGGER.error(e.getMessage(), e); response.setStatus(Status.THRIFT_VERSION_MISMATCH(e.getMessage(), e)); } catch (Exception e) { String msg = "Unknown error for request: " + request + ", message: " + e.getMessage();
request.setRoleName(TEST_ROLE_NAME); TAlterSentryRoleGrantPrivilegeResponse response = new TAlterSentryRoleGrantPrivilegeResponse(); privileges.add(privilege); request.setPrivileges(privileges); response.setStatus(Status.OK()); DBAuditMetadataLogEntity amle = new DBAuditMetadataLogEntity(); Set<JsonLogEntity> amles = JsonLogEntityFactory privileges.add(privilege); request.setPrivileges(privileges); response.setStatus(Status.InvalidInput("", null)); amles = JsonLogEntityFactory.getInstance() .createJsonLogEntities(request, response, conf);
private Set<TSentryPrivilege> grantPrivilegesCore(String requestorUserName, String roleName, Set<TSentryPrivilege> privileges) throws SentryUserException { TAlterSentryRoleGrantPrivilegeRequest request = new TAlterSentryRoleGrantPrivilegeRequest(); request.setProtocol_version(ThriftConstants.TSENTRY_SERVICE_VERSION_CURRENT); request.setRequestorUserName(requestorUserName); request.setRoleName(roleName); request.setPrivileges(privileges); try { TAlterSentryRoleGrantPrivilegeResponse response = client.alter_sentry_role_grant_privilege(request); Status.throwIfNotOk(response.getStatus()); return response.getPrivileges(); } catch (TException e) { throw new SentryUserException(THRIFT_EXCEPTION_MESSAGE, e); } }
public TAlterSentryRoleGrantPrivilegeResponse deepCopy() { return new TAlterSentryRoleGrantPrivilegeResponse(this); }
private JsonLogEntity createJsonLogEntity( TAlterSentryRoleGrantPrivilegeRequest request, TSentryPrivilege privilege, TAlterSentryRoleGrantPrivilegeResponse response, Configuration conf) { DBAuditMetadataLogEntity hamle = createCommonHAMLE(conf, response.getStatus(), request.getRequestorUserName(), request.getClass().getName()); hamle.setOperationText(CommandUtil.createCmdForGrantPrivilege(request)); hamle.setDatabaseName(privilege.getDbName()); hamle.setTableName(privilege.getTableName()); hamle.setResourcePath(privilege.getURI()); return hamle; }
public void write(org.apache.thrift.protocol.TProtocol oprot, TAlterSentryRoleGrantPrivilegeResponse struct) throws org.apache.thrift.TException { struct.validate(); if (struct.isSetPrivilege()) { oprot.writeFieldBegin(PRIVILEGE_FIELD_DESC); struct.privilege.write(oprot); if (struct.isSetPrivileges()) { oprot.writeFieldBegin(PRIVILEGES_FIELD_DESC);
if (isSetPrivilege()) { if (!first) sb.append(", "); sb.append("privilege:"); if (isSetPrivileges()) { if (!first) sb.append(", "); sb.append("privileges:");
@Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof TAlterSentryRoleGrantPrivilegeResponse) return this.equals((TAlterSentryRoleGrantPrivilegeResponse)that); return false; }
@Override public int hashCode() { List<Object> list = new ArrayList<Object>(); boolean present_status = true && (isSetStatus()); list.add(present_status); if (present_status) list.add(status); boolean present_privilege = true && (isSetPrivilege()); list.add(present_privilege); if (present_privilege) list.add(privilege); boolean present_privileges = true && (isSetPrivileges()); list.add(present_privileges); if (present_privileges) list.add(privileges); return list.hashCode(); }
/** * Performs a deep copy on <i>other</i>. */ public alter_sentry_role_grant_privilege_result(alter_sentry_role_grant_privilege_result other) { if (other.isSetSuccess()) { this.success = new TAlterSentryRoleGrantPrivilegeResponse(other.success); } }
void verify(Status status) throws Exception { TAlterSentryRoleGrantPrivilegeRequest grantRequest = new TAlterSentryRoleGrantPrivilegeRequest(); grantRequest.setProtocol_version(ThriftConstants.TSENTRY_SERVICE_VERSION_CURRENT); grantRequest.setRequestorUserName(REQUESTOR_USER); grantRequest.setRoleName(roleName); grantRequest.setPrivilege(privilege); TAlterSentryRoleGrantPrivilegeResponse response = processor.alter_sentry_role_grant_privilege(grantRequest); if (response.getStatus().getValue() == Status.OK.getCode()) { Mockito.verify(sentryStore).alterSentryRoleGrantPrivileges(grantRequest.getRoleName(), grantRequest.getPrivileges()); } else { Mockito.verify(sentryStore, Mockito.times(0)) .alterSentryRoleGrantPrivileges(Mockito.anyString(), Mockito.anySet()); } assertEquals("Grant " + privilege.getAction() + " response is not valid", status.getCode(), response.getStatus().getValue()); Mockito.reset(sentryStore); } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, TAlterSentryRoleGrantPrivilegeResponse struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; struct.status.write(oprot); BitSet optionals = new BitSet(); if (struct.isSetPrivilege()) { optionals.set(0); } if (struct.isSetPrivileges()) { optionals.set(1); } oprot.writeBitSet(optionals, 2); if (struct.isSetPrivilege()) { struct.privilege.write(oprot); } if (struct.isSetPrivileges()) { { oprot.writeI32(struct.privileges.size()); for (TSentryPrivilege _iter44 : struct.privileges) { _iter44.write(oprot); } } } }
public boolean equals(alter_sentry_role_grant_privilege_result that) { if (that == null) return false; boolean this_present_success = true && this.isSetSuccess(); boolean that_present_success = true && that.isSetSuccess(); if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (!this.success.equals(that.success)) return false; } return true; }
public boolean equals(TAlterSentryRoleGrantPrivilegeResponse that) { if (that == null) return false; boolean this_present_status = true && this.isSetStatus(); boolean that_present_status = true && that.isSetStatus(); if (this_present_status || that_present_status) { if (!(this_present_status && that_present_status)) return false; if (!this.status.equals(that.status)) return false; } boolean this_present_privilege = true && this.isSetPrivilege(); boolean that_present_privilege = true && that.isSetPrivilege(); if (this_present_privilege || that_present_privilege) { if (!(this_present_privilege && that_present_privilege)) return false; if (!this.privilege.equals(that.privilege)) return false; } boolean this_present_privileges = true && this.isSetPrivileges(); boolean that_present_privileges = true && that.isSetPrivileges(); if (this_present_privileges || that_present_privileges) { if (!(this_present_privileges && that_present_privileges)) return false; if (!this.privileges.equals(that.privileges)) return false; } return true; }
public void read(org.apache.thrift.protocol.TProtocol iprot, alter_sentry_role_grant_privilege_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.success = new TAlterSentryRoleGrantPrivilegeResponse(); struct.success.read(iprot); struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); struct.validate(); }
@Override public void alter_sentry_role_grant_privilege(TAlterSentryRoleGrantPrivilegeRequest request, TAlterSentryRoleGrantPrivilegeResponse response) { for (NotificationHandler handler : handlers) { try { LOGGER.debug("Calling " + handler); handler.alter_sentry_role_grant_privilege(new TAlterSentryRoleGrantPrivilegeRequest(request), new TAlterSentryRoleGrantPrivilegeResponse(response)); } catch (Exception ex) { LOGGER.error("Unexpected error in " + handler + ". Request: " + request + ", Response: " + response, ex); } } }