Class PolicyExport

  • All Implemented Interfaces:
    CLICommand

    public final class PolicyExport
    extends AuthenticatedCommand
    Exports policy model resources into a JSON file.
    Since:
    14.0.0
    • Constructor Detail

      • PolicyExport

        @Inject
        protected PolicyExport​(org.forgerock.http.Client client)
        Constructs a new json resource command.
        Parameters:
        client - the http client
    • Method Detail

      • handleResourceRequest

        public void handleResourceRequest​(RequestContext request)
                                   throws CLIException
        Handles the passed request.
        Parameters:
        request - the command request
        Throws:
        CLIException - should some error occur
      • sendRequest

        protected final org.forgerock.http.protocol.Response sendRequest​(org.forgerock.http.protocol.Request request,
                                                                         String endpoint)
                                                                  throws CLIException
        Sends the given request to the passed endpoint.
        Parameters:
        request - http request
        endpoint - endpoint
        Returns:
        http response
        Throws:
        CLIException - should some error occur
      • readJsonFile

        protected final org.forgerock.json.JsonValue readJsonFile​(String jsonFile)
                                                           throws CLIException
        Reads in a json file.
        Parameters:
        jsonFile - the path to the json file
        Returns:
        the json representation
        Throws:
        CLIException - should some error occur
      • writeJsonFile

        protected final void writeJsonFile​(org.forgerock.json.JsonValue jsonValue,
                                           String jsonFile)
                                    throws CLIException
        Writes out json to file.
        Parameters:
        jsonValue - the json to be written out
        jsonFile - the path to the json file
        Throws:
        CLIException - should some error occur
      • objectToJsonString

        protected final String objectToJsonString​(Object object)
                                           throws CLIException
        Given an object, converts it to a well formatted json representation.
        Parameters:
        object - object
        Returns:
        json representation
        Throws:
        CLIException - should some error occur during the transformation to json