Returns the audit record for the given id.

@param   entityid  The entity Id. Cannot be null.
@param   limit     max no of records

@return  The audit object.

@throws  WebApplicationException  Throws the exception for invalid input data.
556782
@GET
    @Path("/entity/{entityid}")
    @Description("Returns the audit trail for an entity.")
    @Produces(MediaType.APPLICATION_JSON)
    public List<AuditDto> findByEntityId(@PathParam("entityid") BigInteger entityid,
        @QueryParam("limit") BigInteger limit) {
        if (entityid == null || entityid.compareTo(BigInteger.ZERO) < 1) {
            throw new WebApplicationException("Entity ID cannot be null and must be a positive non-zero number.", Status.BAD_REQUEST);
        }
        if (limit != null && limit.compareTo(BigInteger.ZERO) < 1) {
            throw new WebApplicationException("Limit must be a positive non-zero number.", Status.BAD_REQUEST);
        }

        List<Audit> auditList = limit == null ? _auditService.findByEntity(entityid) : _auditService.findByEntity(entityid, limit);

        if (auditList != null && auditList.size() > 0) {
            return AuditDto.transformToDto(auditList);
        } else {
            throw new WebApplicationException(Response.Status.NOT_FOUND.getReasonPhrase(), Response.Status.NOT_FOUND);
        }
    }
1049915
public Object get(Class entityClass, Serializable id) throws Exception {
		return get(entityClass, id, null);
	}
467264
@Override
    public Object getEntityFromDocument(Class<?> entityClass, JsonObject obj, EntityType entityType)
    {
        Object entity = KunderaCoreUtils.createNewInstance(entityClass);
        Set<Attribute> attributes = entityType.getAttributes();
        Iterator<Attribute> iterator = attributes.iterator();
        iterateAndPopulateEntity(entity, obj, iterator);
        return entity;
    }
1152585
public static AuditDto transformToDto(Audit audit) {
        if (audit == null) {
            throw new WebApplicationException("Null entity object cannot be converted to Dto object.", Status.INTERNAL_SERVER_ERROR);
        }

        AuditDto auditDto = new AuditDto();

        try {
        	    auditDto.setId(audit.getId());
        	    auditDto.setHostName(audit.getHostName());
        	    auditDto.setMessage(audit.getMessage());
        	    auditDto.setCreatedDate(audit.getCreatedDate());
            auditDto.setEntityId(audit.getEntityId());
        } catch (Exception ex) {
            throw new WebApplicationException("DTO transformation failed.", Status.INTERNAL_SERVER_ERROR);
        }
        return auditDto;
    }
296404
public function getEntityAttributeView($type = false, $offset = 0, $limit = 1000, $details = true) {
        $Entities = array();
        $Columns = array();

        if ($type) {
            $url = $this->url . "contextEntityTypes/" . $type;
        } else {
            $url = $this->url . "contextEntities";
        }
        
        $_details = ($details)? "on" : "off";
        
        //Need improvments sinse paging was implemented
        $ret = $this->restRequest($url . "?offset=$offset&limit=$limit&details=$_details", 'GET')->getResponseBody();

        $Context = new Context\Context($ret);

        $keysindex = array();


        $ContextOBject = $Context->__toObject();

        if (is_object($ContextOBject) && isset($ContextOBject->contextResponses)) {
            foreach ($ContextOBject->contextResponses as $entity) {
                $t = $entity->contextElement->type;
                $id = $entity->contextElement->id;

                if (!array_key_exists($t, $keysindex)) {
                    $keysindex[$t] = 0;
                }

                if (!array_key_exists($t, $Columns)) {
                    $Columns[$t] = array("id", "__original");
                }
                $i = $keysindex[$t];

                $Entities[$t][$i]['id'] = $id;

                foreach ($entity->contextElement->attributes as $value) {
                    $Entities[$t][$i][$value->name] = $value->value;
                    array_push($Columns[$t], $value->name);
                }

                $Entities[$t][$i]['__original'] = $entity->contextElement;

                $keysindex[$t] ++;
            }


            if ($this->checkVersion("0.15.0", ">=")) {
                if (!isset($this->_entityTypes)) {
                    $this->getEntityTypes();
                }
                
                foreach ($this->_entityTypes as $t => $attr) {
                    $Columns[$t] = array("id", "__original");
                    foreach ($attr as $a) {
//                        var_dump($a);
                        array_push($Columns[$t], $a);
                    }
                }
            } else {
                //Slow
                foreach ($Columns as $c => $column) {
                    $Columns[$c] = array_unique($column);
                }
            }

            //Magic: Create Empy columns for different entities attribute of the same type
            foreach ($Entities as $EntityType => $EntityGroup) {
                foreach ($EntityGroup as $key => $EntityRow) {
                    $diff = array_diff($Columns[$EntityType], array_keys($EntityRow));
                    if (count($diff) > 0) {
                        foreach ($diff as $column) {
                            $Entities[$EntityType][$key][$column] = null; //Empty value
                        }
                    }
                }
            }
        }
//        }

        return array("entities" => $Entities, "columns" => $Columns);
    }
1007184
public function getById($entityType, $id, array $params = [], $version = null)
    {
        if (empty($id)) {
            throw new Exception('Id is empty');
        }

        if (!static::isIdValid($id)) {
            throw new Exception('Id is invalid, please use a correctly formatted id');
        }

        return ($version === null)
            ? $this->doGet($entityType . '.json/crud/' . $id, $params)
            : $this->doGet($entityType . '.json/history/' . $id . '/' . $version, $params);
    }
149961
public static AuditEntryBean apiUpdated(ApiBean bean, EntityUpdatedData data,
            ISecurityContext securityContext) {
        if (data.getChanges().isEmpty()) {
            return null;
        }
        AuditEntryBean entry = newEntry(bean.getOrganization().getId(), AuditEntityType.Api, securityContext);
        entry.setEntityId(bean.getId());
        entry.setEntityVersion(null);
        entry.setWhat(AuditEntryType.Update);
        entry.setData(toJSON(data));
        return entry;
    }
1158465
@GET
    @Path("/{id}")
    @Description("Returns the audit trail for a given Id.")
    @Produces(MediaType.APPLICATION_JSON)
    public AuditDto findById(@PathParam("id") BigInteger id) {
        if (id == null || id.compareTo(BigInteger.ZERO) < 1) {
            throw new WebApplicationException("ID cannot be null and must be a positive non-zero number.", Status.BAD_REQUEST);
        }

        Audit audit = _auditService.findAuditByPrimaryKey(id);

        if (audit != null) {
            return AuditDto.transformToDto(_auditService.findAuditByPrimaryKey(id));
        } else {
            throw new WebApplicationException(Response.Status.NOT_FOUND.getReasonPhrase(), Response.Status.NOT_FOUND);
        }
    }
63511
public Referenceable getEntity(final String entityType, final String attribute, final String value)
            throws AtlasServiceException {
        JSONObject jsonResponse = callAPIWithRetries(API.GET_ENTITY, null, new ResourceCreator() {
            @Override
            public WebResource createResource() {
                WebResource resource = getResource(API.GET_ENTITY);
                resource = resource.queryParam(TYPE, entityType);
                resource = resource.queryParam(ATTRIBUTE_NAME, attribute);
                resource = resource.queryParam(ATTRIBUTE_VALUE, value);
                return resource;
            }
        });
        try {
            String entityInstanceDefinition = jsonResponse.getString(AtlasClient.DEFINITION);
            return InstanceSerialization.fromJsonReferenceable(entityInstanceDefinition, true);
        } catch (JSONException e) {
            throw new AtlasServiceException(API.GET_ENTITY, e);
        }
    }
540772
EntityType getEntityTypeBypassingRegistry(String entityTypeId) {
    return entityTypeId != null
        ? dataService.findOneById(
            ENTITY_TYPE_META_DATA, entityTypeId, getEntityTypeFetch(), EntityType.class)
        : null;
  }
210228
@SuppressWarnings("unchecked")
	public <T> T getEntity(Response res, Class<?> type) throws WebApplicationException {
		if (res != null) {
			if (res.getStatus() == Response.Status.OK.getStatusCode()
					|| res.getStatus() == Response.Status.CREATED.getStatusCode()
					|| res.getStatus() == Response.Status.NOT_MODIFIED.getStatusCode()) {
					return res.hasEntity() ? res.readEntity((Class<T>) type) : null;
			} else if (res.getStatus() != Response.Status.NOT_FOUND.getStatusCode()
					&& res.getStatus() != Response.Status.NOT_MODIFIED.getStatusCode()
					&& res.getStatus() != Response.Status.NO_CONTENT.getStatusCode()) {
				Map<String, Object> error = res.hasEntity() ? res.readEntity(Map.class) : null;
				if (error != null && error.containsKey("code")) {
					String msg = error.containsKey("message") ? (String) error.get("message") : "error";
					WebApplicationException e = new WebApplicationException(msg, (Integer) error.get("code"));
					logger.error("{} - {}", msg, e.getMessage());
					if (throwExceptionOnHTTPError) {
						throw e;
					}
				} else {
					logger.error("{} - {}", res.getStatus(), res.getStatusInfo().getReasonPhrase());
					if (throwExceptionOnHTTPError) {
						throw new WebApplicationException(res.getStatusInfo().getReasonPhrase(), res.getStatus());
					}
				}
			}
		}
		return null;
	}
596724
public static function getLogData($syncid, $type = 'all', $limitstart = null, $limit = null, $sort = 'id', $dir = 'ASC')
	{
		$db = Factory::getDBO();

		$query = $db->getQuery(true)
			->select('*')
			->from('#__jfusion_sync_details')
			->where('syncid = ' . $db->quote($syncid));

		if (!empty($sort)) {
			$query->order($sort . ' ' . $dir);
		}

		if ($type != 'all') {
			$query->where('action = ' . $db->quote($type));
		}

		$db->setQuery($query, $limitstart, $limit);
		$results = $db->loadObjectList('id');

		return $results;
	}
916031
public T retrieve(String entityId) throws AuthenticationException, ApiException, InvalidRequestException {
		return retrieve(entityId, getAuthenticatedClient());
	}
1052571
@SuppressWarnings("unchecked")
    public QueryResult findTaxClassificationByParentId(IEntity entity) throws FMSException {

        IntuitMessage intuitMessage = prepareFindByParentId(entity);

        //execute interceptors
        executeInterceptors(intuitMessage);

        QueryResult queryResult = null;

        // Iterate the IntuitObjects list in QueryResponse and convert to <T> entity
        IntuitResponse intuitResponse = (IntuitResponse) intuitMessage.getResponseElements().getResponse();
        if (intuitResponse != null) {
            QueryResponse queryResponse = intuitResponse.getQueryResponse();
            if (queryResponse != null) {
                queryResult = getQueryResult(queryResponse);
            }
        }
        return queryResult;
    }
482067
private function createRateLimitData($applicationId, $userId)
	{
		// data needed to create record
		$ipAddress    = \Request::ip();
		$countShort   = 0;
		$countLong    = 0;
		$limitShort   = $this->config['short']['limit'];
		$limitLong    = $this->config['long']['limit'];
		$created      = with(new Date('now'))->toSql();
		$expiresShort = $this->getNewExpiresDateString('short');
		$expiresLong  = $this->getNewExpiresDateString('long');

		// create initial limit record
		return $this->storage->createRateLimitData(
			$applicationId,
			$userId,
			$ipAddress,
			$limitShort,
			$limitLong,
			$countShort,
			$countLong,
			$expiresShort,
			$expiresLong,
			$created
		);
	}
474877
public static List<AuditDto> transformToDto(List<Audit> audits) {
        if (audits == null) {
            throw new WebApplicationException("Null entity object cannot be converted to Dto object.", Status.INTERNAL_SERVER_ERROR);
        }

        List<AuditDto> result = new ArrayList<AuditDto>();

        for (Audit audit : audits) {
        	    
            result.add(transformToDto(audit));
        }
        return result;
    }
1045516
public static EntityGetOperation<AccessPolicyInfo> get(String accessPolicyId) {
        return new DefaultGetOperation<AccessPolicyInfo>(ENTITY_SET,
                accessPolicyId, AccessPolicyInfo.class);
    }