Class AssetResource


  • @Path("/jans-assets")
    @Produces("application/json")
    @Consumes("application/json")
    public class AssetResource
    extends ConfigBaseResource
    • Constructor Summary

      Constructors 
      Constructor Description
      AssetResource()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      jakarta.ws.rs.core.Response deleteAsset​(@NotNull String inum)
      Delete the asset identified by the given inum.
      jakarta.ws.rs.core.Response getAssetByInum​(@NotNull String inum)
      Retrieves the asset for the given inum.
      jakarta.ws.rs.core.Response getAssetByName​(@NotNull String name)
      Fetch assets that match the provided asset name.
      jakarta.ws.rs.core.Response getAssetDirMapping()
      Retrieve configured mappings between asset types and their directory locations.
      jakarta.ws.rs.core.Response getAssets​(int limit, String pattern, String status, int startIndex, String sortBy, String sortOrder, String fieldValuePair)
      Retrieves Jans assets matching the provided search and sorting criteria.
      jakarta.ws.rs.core.Response getJansServices()
      Retrieve valid asset service (module) names.
      jakarta.ws.rs.core.Response getValidAssetTypes()
      Retrieve valid asset file types supported by the server.
      jakarta.ws.rs.core.Response loadServiceAsset​(@NotNull String serviceName)
      Load assets for the specified service on the server.
      jakarta.ws.rs.core.Response updateAsset​(AssetForm assetForm)
      Update an existing asset using data supplied in a multipart form.
      jakarta.ws.rs.core.Response uploadAsset​(AssetForm assetForm)
      Create a new asset from multipart form data.
      • Methods inherited from class io.jans.configapi.core.rest.BaseResource

        checkNotEmpty, checkNotEmpty, checkNotNull, checkNotNull, checkNotNull, checkResourceNotNull, createSearchRequest, findRootError, getBadRequestException, getBadRequestException, getBadRequestException, getHttpHeaders, getHttpRequest, getInternalServerException, getInternalServerException, getMissingAttributeError, getNotAcceptableException, getNotFoundError, getNotFoundError, getUriInfo, throwBadRequestException, throwBadRequestException, throwBadRequestException, throwInternalServerException, throwInternalServerException, throwInternalServerException, throwInternalServerException, throwMissingAttributeError, throwNotFoundException, throwNotFoundException
    • Constructor Detail

      • AssetResource

        public AssetResource()
    • Method Detail

      • getAssets

        @GET
        public jakarta.ws.rs.core.Response getAssets​(@DefaultValue("50") @QueryParam("limit")
                                                     int limit,
                                                     @DefaultValue("") @QueryParam("pattern")
                                                     String pattern,
                                                     @DefaultValue("all") @QueryParam("status")
                                                     String status,
                                                     @DefaultValue("0") @QueryParam("startIndex")
                                                     int startIndex,
                                                     @DefaultValue("inum") @QueryParam("sortBy")
                                                     String sortBy,
                                                     @DefaultValue("ascending") @QueryParam("sortOrder")
                                                     String sortOrder,
                                                     @DefaultValue("") @QueryParam("fieldValuePair")
                                                     String fieldValuePair)
                                              throws Exception
        Retrieves Jans assets matching the provided search and sorting criteria.
        Parameters:
        limit - maximum number of results to return
        pattern - search pattern to filter assets
        status - status filter for assets
        startIndex - 1-based index of the first result to return
        sortBy - attribute name to sort results by
        sortOrder - sort direction, either "ascending" or "descending"
        fieldValuePair - comma-separated field=value pairs to further filter results (e.g. "adminCanEdit=true,dataType=string")
        Returns:
        HTTP 200 response containing a paged result of matching asset documents
        Throws:
        Exception
      • getAssetByInum

        @GET
        @Path("{inum}")
        public jakarta.ws.rs.core.Response getAssetByInum​(@PathParam("inum") @NotNull
                                                          @NotNull String inum)
                                                   throws Exception
        Retrieves the asset for the given inum.
        Parameters:
        inum - the unique asset identifier
        Returns:
        the Document representing the asset with the specified inum
        Throws:
        Exception
      • getAssetByName

        @GET
        @Path("name/{name}")
        public jakarta.ws.rs.core.Response getAssetByName​(@PathParam("name") @NotNull
                                                          @NotNull String name)
                                                   throws Exception
        Fetch assets that match the provided asset name. Returns a paged result containing Document entries for assets whose name matches the provided value.
        Parameters:
        name - the asset name to search for
        Returns:
        a DocumentPagedResult containing matching asset documents
        Throws:
        Exception
      • getJansServices

        @GET
        @Path("/services")
        public jakarta.ws.rs.core.Response getJansServices()
        Retrieve valid asset service (module) names.
        Returns:
        a list of valid asset service/module names; an empty list if no services are available
      • getValidAssetTypes

        @GET
        @Path("/asset-type")
        public jakarta.ws.rs.core.Response getValidAssetTypes()
        Retrieve valid asset file types supported by the server.
        Returns:
        a List of valid asset file extensions/types (each element is a file type string); returns an empty list if none are configured
      • getAssetDirMapping

        @GET
        @Path("/asset-dir-mapping")
        public jakarta.ws.rs.core.Response getAssetDirMapping()
        Retrieve configured mappings between asset types and their directory locations.
        Returns:
        a list of AssetDirMapping objects representing asset type → directory mappings; an empty list if no mappings are configured
      • uploadAsset

        @Consumes("multipart/form-data")
        @POST
        @Path("/upload")
        public jakarta.ws.rs.core.Response uploadAsset​(AssetForm assetForm)
                                                throws Exception
        Create a new asset from multipart form data. Processes the supplied AssetForm (which must contain a Document with a non-null fileName and a non-empty file stream), saves the asset, and returns the created asset representation.
        Parameters:
        assetForm - multipart form containing the asset Document and file stream; the Document must include `fileName` and the form must include a non-empty `assetFile`
        Returns:
        HTTP response with the created Document as the entity and status 201 (Created)
        Throws:
        Exception - if an unexpected error occurs while processing or saving the asset
      • updateAsset

        @Consumes("multipart/form-data")
        @PUT
        @Path("/upload")
        public jakarta.ws.rs.core.Response updateAsset​(AssetForm assetForm)
                                                throws Exception
        Update an existing asset using data supplied in a multipart form. The provided AssetForm must contain a Document with a valid `inum` and a `fileName`, and may include the asset file stream.
        Parameters:
        assetForm - multipart form containing the asset Document and optional asset file; the Document's `inum` and `fileName` are required
        Returns:
        the modified Document representing the updated asset
        Throws:
        Exception - if validation fails (missing form, missing Document or inum, asset not found, or name conflict) or if persisting the updated asset fails
      • loadServiceAsset

        @Consumes("multipart/form-data")
        @POST
        @Path("/service/{service-name}")
        public jakarta.ws.rs.core.Response loadServiceAsset​(@PathParam("service-name") @NotNull
                                                            @NotNull String serviceName)
                                                     throws Exception
        Load assets for the specified service on the server. Initiates loading of assets associated with the given service and returns a message describing the outcome.
        Parameters:
        serviceName - the name of the service whose assets will be loaded
        Returns:
        a message describing the result of the load operation
        Throws:
        Exception - if an error occurs while loading assets
      • deleteAsset

        @DELETE
        @Path("{inum}")
        public jakarta.ws.rs.core.Response deleteAsset​(@PathParam("inum") @NotNull
                                                       @NotNull String inum)
        Delete the asset identified by the given inum.
        Parameters:
        inum - the asset's unique identifier
        Returns:
        HTTP 204 No Content response on successful deletion