commit
7a2827e73a
@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
~
|
||||
~ Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>tenant-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>io.entgra.tenant.mgt.common</artifactId>
|
||||
<name>Entgra IoT - Tenant Manager Common</name>
|
||||
<description>Entgra IoT - Tenant Manager Common</description>
|
||||
<packaging>bundle</packaging>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
|
||||
<Bundle-Description>Tenant Management Common Bundle</Bundle-Description>
|
||||
<Import-Package>
|
||||
org.apache.commons.logging,
|
||||
org.wso2.carbon.stratos.common.beans
|
||||
</Import-Package>
|
||||
<Export-Package>io.entgra.tenant.mgt.common.*</Export-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.commons</groupId>
|
||||
<artifactId>org.wso2.carbon.tenant.common</artifactId>
|
||||
<version>${carbon.commons.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Entgra Pvt Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.entgra.tenant.mgt.common.exception;
|
||||
|
||||
public class TenantMgtException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 4304028531230841553L;
|
||||
|
||||
public TenantMgtException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
|
||||
public TenantMgtException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Entgra Pvt Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.entgra.tenant.mgt.common.spi;
|
||||
|
||||
import io.entgra.tenant.mgt.common.exception.TenantMgtException;
|
||||
import org.wso2.carbon.stratos.common.beans.TenantInfoBean;
|
||||
|
||||
public interface TenantManagerService {
|
||||
void addDefaultRoles(TenantInfoBean tenantInfoBean) throws TenantMgtException;
|
||||
|
||||
void addDefaultAppCategories(TenantInfoBean tenantInfoBean) throws TenantMgtException;
|
||||
}
|
@ -0,0 +1,136 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
~
|
||||
~ Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>tenant-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>io.entgra.tenant.mgt.core</artifactId>
|
||||
<name>Entgra IoT - Tenant Manager Core</name>
|
||||
<description>Entgra IoT - Tenant Manager Core</description>
|
||||
<packaging>bundle</packaging>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-scr-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
|
||||
<Bundle-Description>Tenant Management Core Bundle</Bundle-Description>
|
||||
<Private-Package>io.entgra.tenant.mgt.core.internal</Private-Package>
|
||||
<Import-Package>
|
||||
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
|
||||
org.osgi.service.*;version="${imp.package.version.osgi.service}",
|
||||
org.apache.commons.logging,
|
||||
io.entgra.application.mgt.common.*,
|
||||
io.entgra.application.mgt.core.config,
|
||||
org.wso2.carbon.device.mgt.core,
|
||||
org.wso2.carbon.user.api,
|
||||
org.wso2.carbon.registry.core.exceptions,
|
||||
io.entgra.tenant.mgt.common.*,
|
||||
org.wso2.carbon.stratos.common.beans,
|
||||
org.wso2.carbon.stratos.common.exception,
|
||||
org.wso2.carbon.stratos.common.listeners,
|
||||
org.wso2.carbon.device.mgt.common.metadata.mgt,
|
||||
org.wso2.carbon.device.mgt.common.exceptions,
|
||||
org.wso2.carbon.device.mgt.common.permission.mgt,
|
||||
org.wso2.carbon.device.mgt.common.roles.config,
|
||||
org.wso2.carbon.device.mgt.core.metadata.mgt,
|
||||
org.wso2.carbon.device.mgt.core.config,
|
||||
org.wso2.carbon.user.core.service,
|
||||
org.wso2.carbon.context
|
||||
</Import-Package>
|
||||
<Export-Package>
|
||||
!io.entgra.tenant.mgt.core.internal,
|
||||
io.entgra.tenant.mgt.core.*
|
||||
</Export-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi.services</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.commons</groupId>
|
||||
<artifactId>org.wso2.carbon.tenant.common</artifactId>
|
||||
<version>${carbon.commons.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.registry.core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.user.core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.user.api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>io.entgra.application.mgt.core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>io.entgra.application.mgt.common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>io.entgra.tenant.mgt.common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Entgra Pvt Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.entgra.tenant.mgt.core;
|
||||
|
||||
import io.entgra.tenant.mgt.common.exception.TenantMgtException;
|
||||
import org.wso2.carbon.stratos.common.beans.TenantInfoBean;
|
||||
|
||||
public interface TenantManager {
|
||||
|
||||
/**
|
||||
* Add default roles to a tenant described by the tenant info bean
|
||||
* @param tenantInfoBean The info bean that provides tenant info
|
||||
* @throws TenantMgtException Throws when error occurred while adding
|
||||
* a role into user store or adding default white label theme to created tenant
|
||||
*/
|
||||
void addDefaultRoles(TenantInfoBean tenantInfoBean) throws TenantMgtException;
|
||||
|
||||
/**
|
||||
* Add default application categories to a tenant described by the tenant info bean
|
||||
* @param tenantInfoBean The info bean that provides tenant info
|
||||
* @throws TenantMgtException Throws when error occurred while adding default application categories
|
||||
*/
|
||||
void addDefaultAppCategories(TenantInfoBean tenantInfoBean) throws TenantMgtException;
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Entgra Pvt Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.entgra.tenant.mgt.core.impl;
|
||||
|
||||
import io.entgra.tenant.mgt.common.spi.TenantManagerService;
|
||||
import io.entgra.tenant.mgt.common.exception.TenantMgtException;
|
||||
import io.entgra.tenant.mgt.core.internal.TenantMgtDataHolder;
|
||||
import org.wso2.carbon.stratos.common.beans.TenantInfoBean;
|
||||
|
||||
public class TenantManagerServiceImpl implements TenantManagerService {
|
||||
|
||||
@Override
|
||||
public void addDefaultRoles(TenantInfoBean tenantInfoBean) throws TenantMgtException {
|
||||
TenantMgtDataHolder.getInstance().getTenantManager().addDefaultRoles(tenantInfoBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDefaultAppCategories(TenantInfoBean tenantInfoBean) throws TenantMgtException {
|
||||
TenantMgtDataHolder.getInstance().getTenantManager().addDefaultAppCategories(tenantInfoBean);
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Entgra Pvt Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.entgra.tenant.mgt.core.internal;
|
||||
|
||||
import io.entgra.application.mgt.common.services.ApplicationManager;
|
||||
import io.entgra.tenant.mgt.core.TenantManager;
|
||||
import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelManagementService;
|
||||
import org.wso2.carbon.user.core.service.RealmService;
|
||||
|
||||
public class TenantMgtDataHolder {
|
||||
private static final TenantMgtDataHolder instance = new TenantMgtDataHolder();
|
||||
private TenantManager tenantManager;
|
||||
|
||||
private ApplicationManager applicationManager;
|
||||
|
||||
private WhiteLabelManagementService whiteLabelManagementService;
|
||||
|
||||
private RealmService realmService;
|
||||
|
||||
public RealmService getRealmService() {
|
||||
return realmService;
|
||||
}
|
||||
|
||||
public void setRealmService(RealmService realmService) {
|
||||
this.realmService = realmService;
|
||||
}
|
||||
|
||||
public ApplicationManager getApplicationManager() {
|
||||
return applicationManager;
|
||||
}
|
||||
|
||||
public void setApplicationManager(ApplicationManager applicationManager) {
|
||||
this.applicationManager = applicationManager;
|
||||
}
|
||||
|
||||
public WhiteLabelManagementService getWhiteLabelManagementService() {
|
||||
return whiteLabelManagementService;
|
||||
}
|
||||
|
||||
public void setWhiteLabelManagementService(WhiteLabelManagementService whiteLabelManagementService) {
|
||||
this.whiteLabelManagementService = whiteLabelManagementService;
|
||||
}
|
||||
|
||||
public TenantManager getTenantManager() {
|
||||
return tenantManager;
|
||||
}
|
||||
|
||||
public void setTenantManager(TenantManager tenantManager) {
|
||||
this.tenantManager = tenantManager;
|
||||
}
|
||||
|
||||
public static TenantMgtDataHolder getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Entgra Pvt Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.entgra.tenant.mgt.core.internal;
|
||||
|
||||
import io.entgra.application.mgt.common.services.ApplicationManager;
|
||||
import io.entgra.tenant.mgt.common.spi.TenantManagerService;
|
||||
import io.entgra.tenant.mgt.core.TenantManager;
|
||||
import io.entgra.tenant.mgt.core.impl.TenantManagerImpl;
|
||||
import io.entgra.tenant.mgt.core.impl.TenantManagerServiceImpl;
|
||||
import io.entgra.tenant.mgt.core.listener.DeviceMgtTenantListener;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.osgi.service.component.ComponentContext;
|
||||
import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelManagementService;
|
||||
import org.wso2.carbon.device.mgt.core.metadata.mgt.WhiteLabelManagementServiceImpl;
|
||||
import org.wso2.carbon.stratos.common.listeners.TenantMgtListener;
|
||||
import org.wso2.carbon.user.core.service.RealmService;
|
||||
|
||||
/**
|
||||
* @scr.component name="org.wso2.carbon.devicemgt.tenant.manager" immediate="true"
|
||||
* @scr.reference name="org.wso2.carbon.application.mgt.service"
|
||||
* interface="io.entgra.application.mgt.common.services.ApplicationManager"
|
||||
* cardinality="1..1"
|
||||
* policy="dynamic"
|
||||
* bind="setApplicationManager"
|
||||
* unbind="unsetApplicationManager"
|
||||
* @scr.reference name="user.realmservice.default"
|
||||
* interface="org.wso2.carbon.user.core.service.RealmService"
|
||||
* cardinality="1..1"
|
||||
* policy="dynamic"
|
||||
* bind="setRealmService"
|
||||
* unbind="unsetRealmService"
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TenantMgtServiceComponent {
|
||||
|
||||
private static final Log log = LogFactory.getLog(TenantManagerService.class);
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
protected void activate(ComponentContext componentContext) {
|
||||
try {
|
||||
TenantManagerService tenantManagerService = new TenantManagerServiceImpl();
|
||||
componentContext.getBundleContext().
|
||||
registerService(TenantManagerServiceImpl.class.getName(), tenantManagerService, null);
|
||||
TenantManager tenantManager = new TenantManagerImpl();
|
||||
TenantMgtDataHolder.getInstance().setTenantManager(tenantManager);
|
||||
WhiteLabelManagementService whiteLabelManagementService = new WhiteLabelManagementServiceImpl();
|
||||
componentContext.getBundleContext().registerService(WhiteLabelManagementServiceImpl.class.getName(),
|
||||
whiteLabelManagementService, null);
|
||||
TenantMgtDataHolder.getInstance().setWhiteLabelManagementService(whiteLabelManagementService);
|
||||
DeviceMgtTenantListener deviceMgtTenantListener = new DeviceMgtTenantListener();
|
||||
if(log.isDebugEnabled()) {
|
||||
log.info("Tenant management listener is registering");
|
||||
}
|
||||
componentContext.getBundleContext().
|
||||
registerService(TenantMgtListener.class.getName(), deviceMgtTenantListener, null);
|
||||
if(log.isDebugEnabled()) {
|
||||
log.info("Tenant management service activated");
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
String msg = "Error occurred while activating tenant management service";
|
||||
log.error(msg, t);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
protected void deactivate(ComponentContext componentContext) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
protected void setApplicationManager(ApplicationManager applicationManager) {
|
||||
if(log.isDebugEnabled()) {
|
||||
log.info("Application manager service is binding");
|
||||
}
|
||||
TenantMgtDataHolder.getInstance().setApplicationManager(applicationManager);
|
||||
}
|
||||
|
||||
protected void unsetApplicationManager(ApplicationManager applicationManager) {
|
||||
if(log.isDebugEnabled()) {
|
||||
log.info("Application manager service is unbinding");
|
||||
}
|
||||
TenantMgtDataHolder.getInstance().setApplicationManager(null);
|
||||
}
|
||||
|
||||
protected void setRealmService(RealmService realmService) {
|
||||
if(log.isDebugEnabled()) {
|
||||
log.info("Realm Service service is binding");
|
||||
}
|
||||
TenantMgtDataHolder.getInstance().setRealmService(realmService);
|
||||
}
|
||||
|
||||
protected void unsetRealmService(RealmService realmService) {
|
||||
if(log.isDebugEnabled()) {
|
||||
log.info("Realm Service service is unbinding");
|
||||
}
|
||||
TenantMgtDataHolder.getInstance().setRealmService(null);
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Entgra Pvt Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.entgra.tenant.mgt.core.listener;
|
||||
|
||||
import io.entgra.tenant.mgt.core.TenantManager;
|
||||
import io.entgra.tenant.mgt.common.exception.TenantMgtException;
|
||||
import io.entgra.tenant.mgt.core.internal.TenantMgtDataHolder;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.stratos.common.beans.TenantInfoBean;
|
||||
import org.wso2.carbon.stratos.common.exception.StratosException;
|
||||
import org.wso2.carbon.stratos.common.listeners.TenantMgtListener;
|
||||
|
||||
public class DeviceMgtTenantListener implements TenantMgtListener {
|
||||
|
||||
private static final Log log = LogFactory.getLog(DeviceMgtTenantListener.class);
|
||||
public static final int LISTENER_EXECUTION_ORDER = 10;
|
||||
|
||||
@Override
|
||||
public void onTenantCreate(TenantInfoBean tenantInfoBean) {
|
||||
// Any work to be performed after a tenant creation
|
||||
TenantManager tenantManager = TenantMgtDataHolder.getInstance().getTenantManager();
|
||||
try {
|
||||
tenantManager.addDefaultRoles(tenantInfoBean);
|
||||
tenantManager.addDefaultAppCategories(tenantInfoBean);
|
||||
} catch (TenantMgtException e) {
|
||||
String msg = "Error occurred while executing tenant creation flow";
|
||||
log.error(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTenantUpdate(TenantInfoBean tenantInfoBean) throws StratosException {
|
||||
// Any work to be performed after a tenant information update happens
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTenantDelete(int i) {
|
||||
// Any work to be performed after a tenant deletion
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTenantRename(int i, String s, String s1) throws StratosException {
|
||||
// Any work to be performed after a tenant rename happens
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTenantInitialActivation(int i) throws StratosException {
|
||||
// Any work to be performed after a tenant's initial activation happens
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTenantActivation(int i) throws StratosException {
|
||||
// Any work to be performed after a tenant activation
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTenantDeactivation(int i) throws StratosException {
|
||||
// Any work to be performed after a tenant deactivation
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscriptionPlanChange(int i, String s, String s1) throws StratosException {
|
||||
// Any work to be performed after subscription plan change
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getListenerOrder() {
|
||||
return LISTENER_EXECUTION_ORDER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPreDelete(int i) throws StratosException {
|
||||
// Any work to be performed before a tenant is deleted
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
~
|
||||
~ Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>tenant-mgt</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>Entgra IoT - Tenant Management Component</name>
|
||||
<description>Entgra IoT - Tenant Management Component</description>
|
||||
|
||||
<modules>
|
||||
<module>io.entgra.tenant.mgt.core</module>
|
||||
<module>io.entgra.tenant.mgt.common</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>tenant-mgt-feature</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>io.entgra.tenant.mgt.server.feature</artifactId>
|
||||
<name>Entgra IoT - Tenant Management Server Feature</name>
|
||||
<description>Entgra IoT - Tenant Management Server Feature</description>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>io.entgra.tenant.mgt.core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>io.entgra.tenant.mgt.common</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>src/main/resources</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>resources</directory>
|
||||
<includes>
|
||||
<include>build.properties</include>
|
||||
<include>p2.inf</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.wso2.maven</groupId>
|
||||
<artifactId>carbon-p2-plugin</artifactId>
|
||||
<version>${carbon.p2.plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>p2-feature-generation</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>p2-feature-gen</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<id>io.entgra.tenant.mgt.server</id>
|
||||
<propertiesFile>../../etc/feature.properties</propertiesFile>
|
||||
<adviceFile>
|
||||
<properties>
|
||||
<propertyDef>org.wso2.carbon.p2.category.type:server
|
||||
</propertyDef>
|
||||
<propertyDef>org.eclipse.equinox.p2.type.group:true
|
||||
</propertyDef>
|
||||
</properties>
|
||||
</adviceFile>
|
||||
<bundles>
|
||||
<!--<bundleDef>{groupId}:{artifactId}:{version}</bundleDef>-->
|
||||
<bundleDef>
|
||||
org.wso2.carbon.devicemgt:io.entgra.tenant.mgt.core:${carbon.device.mgt.version}
|
||||
</bundleDef>
|
||||
<bundleDef>
|
||||
org.wso2.carbon.devicemgt:io.entgra.tenant.mgt.common:${carbon.device.mgt.version}
|
||||
</bundleDef>
|
||||
</bundles>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1 @@
|
||||
custom=true
|
@ -0,0 +1 @@
|
||||
instructions.configure = \
|
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>tenant-mgt-feature</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>Entgra IoT - Tenant Management Feature</name>
|
||||
|
||||
<modules>
|
||||
<module>io.entgra.tenant.mgt.server.feature</module>
|
||||
</modules>
|
||||
</project>
|
Loading…
Reference in new issue