All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sap.cds.adapter.subscription.MtSubscriptionAdapterFactory Maven / Gradle / Ivy

There is a newer version: 3.8.0
Show newest version
/**************************************************************************
 * (C) 2019-2020 SAP SE or an SAP affiliate company. All rights reserved. *
 **************************************************************************/
package com.sap.cds.adapter.subscription;

import javax.servlet.Servlet;

import com.sap.cds.adapter.ServletAdapterFactory;
import com.sap.cds.adapter.UrlResourcePath;
import com.sap.cds.feature.config.Properties;
import com.sap.cds.feature.mt.MtFeatureConditions;
import com.sap.cds.reflect.CdsModel;
import com.sap.cds.services.runtime.CdsRuntime;
import com.sap.cds.services.utils.path.UrlPathUtil;
import com.sap.cds.services.utils.path.UrlResourcePathBuilder;

/**
 * Factory for the subscription adapter.
 */
public class MtSubscriptionAdapterFactory implements ServletAdapterFactory {

	@Override
	public Servlet createAdapter(CdsRuntime runtime) {
		return new MtSubscriptionServlet(runtime);
	}

	@Override
	public boolean isEnabled() {
		return Properties.getCds().getMultiTenancy().getEndpoint().isEnabled() &&
				MtFeatureConditions.unmetCondition() == null;
	}

	@Override
	public String getBasePath() {
		return UrlPathUtil.normalizeBasePath(Properties.getCds().getMultiTenancy().getEndpoint().getPath());
	}

	@Override
	public String[] getMappings(CdsModel model) {
		return new String[] { UrlResourcePathBuilder.path(getBasePath()).recursive().build().getPath() };
	}

	@Override
	public UrlResourcePath getServletPath(CdsModel model) {
		// mt endpoints always need authentication
		return UrlResourcePathBuilder.path(getBasePath()).recursive().isPublic(false).build();
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy