public static MgmtTarget toResponse(final Target target) {
        if (target == null) {
            return null;
        }
        final MgmtTarget targetRest = new MgmtTarget();
        targetRest.setControllerId(target.getControllerId());
        targetRest.setDescription(target.getDescription());
        targetRest.setName(target.getName());
        targetRest.setUpdateStatus(target.getUpdateStatus().name().toLowerCase());

        final URI address = target.getAddress();
        if (address != null) {
            if (IpUtil.isIpAddresKnown(address)) {
                targetRest.setIpAddress(address.getHost());
            }
            targetRest.setAddress(address.toString());
        }

        targetRest.setCreatedBy(target.getCreatedBy());
        targetRest.setLastModifiedBy(target.getLastModifiedBy());

        targetRest.setCreatedAt(target.getCreatedAt());
        targetRest.setLastModifiedAt(target.getLastModifiedAt());

        targetRest.setSecurityToken(target.getSecurityToken());
        targetRest.setRequestAttributes(target.isRequestControllerAttributes());

        // last target query is the last controller request date
        final Long lastTargetQuery = target.getLastTargetQuery();
        final Long installationDate = target.getInstallationDate();

        if (lastTargetQuery != null) {
            targetRest.setLastControllerRequestAt(lastTargetQuery);
        }
        if (installationDate != null) {
            targetRest.setInstalledAt(installationDate);
        }

        targetRest.add(linkTo(methodOn(MgmtTargetRestApi.class).getTarget(target.getControllerId())).withSelfRel());

        return targetRest;
    }
public static MgmtTarget toResponse ( final Target target ) { if ( target == null ) { return null ; } final MgmtTarget targetRest = new MgmtTarget ( ) ; targetRest . setControllerId ( target . getControllerId ( ) ) ; targetRest . setDescription ( target . getDescription ( ) ) ; targetRest . setName ( target . getName ( ) ) ; targetRest . setUpdateStatus ( target . getUpdateStatus ( ) . name ( ) . toLowerCase ( ) ) ; final URI address = target . getAddress ( ) ; if ( address != null ) { if ( IpUtil . isIpAddresKnown ( address ) ) { targetRest . setIpAddress ( address . getHost ( ) ) ; } targetRest . setAddress ( address . toString ( ) ) ; } targetRest . setCreatedBy ( target . getCreatedBy ( ) ) ; targetRest . setLastModifiedBy ( target . getLastModifiedBy ( ) ) ; targetRest . setCreatedAt ( target . getCreatedAt ( ) ) ; targetRest . setLastModifiedAt ( target . getLastModifiedAt ( ) ) ; targetRest . setSecurityToken ( target . getSecurityToken ( ) ) ; targetRest . setRequestAttributes ( target . isRequestControllerAttributes ( ) ) ; final Long lastTargetQuery = target . getLastTargetQuery ( ) ; final Long installationDate = target . getInstallationDate ( ) ; if ( lastTargetQuery != null ) { targetRest . setLastControllerRequestAt ( lastTargetQuery ) ; } if ( installationDate != null ) { targetRest . setInstalledAt ( installationDate ) ; } targetRest . add ( linkTo ( methodOn ( MgmtTargetRestApi . class ) . getTarget ( target . getControllerId ( ) ) ) . withSelfRel ( ) ) ; return targetRest ; }
Create a response for target.

@param target
the target
@return the response