com.tangosol.internal.management.resources.VersionResource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of coherence Show documentation
Show all versions of coherence Show documentation
Oracle Coherence Community Edition
/*
* Copyright (c) 2000, 2022, Oracle and/or its affiliates.
*
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
package com.tangosol.internal.management.resources;
import com.tangosol.internal.http.HttpRequest;
import com.tangosol.internal.http.RequestRouter;
import com.tangosol.internal.http.Response;
import com.tangosol.internal.management.EntityMBeanResponse;
import com.tangosol.internal.management.VersionUtils;
import com.tangosol.util.Filter;
import java.util.LinkedHashMap;
import java.util.Set;
import java.util.function.Supplier;
/**
* The version resource contains information about the latest version of the
* Coherence management REST interface that is supported by the WLS domain.
* For information about versions supported by the REST interface,
* see {@code version_indicator}.
*
* @author Jonathan Knight 2022.01.25
*/
public class VersionResource
extends AbstractManagementResource
{
public VersionResource(Supplier> supplier)
{
f_supplierClusters = supplier;
}
// ----- Routes methods -------------------------------------------------
@Override
public void addRoutes(RequestRouter router, String sPathRoot)
{
router.addGet(sPathRoot, this::get);
router.addRoutes(sPathRoot + "/clusters", new ClustersResource(f_supplierClusters));
}
// ----- Version API ----------------------------------------------------
public Response get(HttpRequest request)
{
String sIncludeFields = request.getFirstQueryParameter(INCLUDE_FIELDS);
String sExcludeFields = request.getFirstQueryParameter(EXCLUDE_FIELDS);
Filter propertiesFilter = getAttributesFilter(sIncludeFields, sExcludeFields);
Filter linksFilter = getLinksFilter(request);
EntityMBeanResponse mBeanResponse = new EntityMBeanResponse(request, linksFilter);
mBeanResponse.addParentResourceLink(getParentUri(request));
mBeanResponse.addSelfResourceLinks(getCurrentUri(request));
// don't add links for the fanout resources since they're internal resources we don't want customers to know about
mBeanResponse.setEntity(new LinkedHashMap<>(VersionUtils.getVersion(VersionUtils.V1, true, VersionUtils.ACTIVE, propertiesFilter)));
return response(mBeanResponse);
}
// ----- data members ---------------------------------------------------
private final Supplier> f_supplierClusters;
}