@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl.admin;
import org.apache.axis2.AxisFault ;
import org.apache.axis2.client.Options ;
import org.apache.axis2.client.Stub ;
import org.apache.axis2.java.security.SSLProtocolSocketFactory ;
import org.apache.axis2.transport.http.HTTPConstants ;
import org.apache.commons.codec.binary.Base64 ;
@ -36,13 +37,10 @@ import org.wso2.carbon.application.mgt.stub.upload.types.carbon.UploadedFileItem
import org.wso2.carbon.base.ServerConfiguration ;
import org.wso2.carbon.context.PrivilegedCarbonContext ;
import org.wso2.carbon.core.util.Utils ;
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.Device TypePublish erAdminService;
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.Device AnalyticsArtifactUpload erAdminService;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils ;
import org.wso2.carbon.identity.jwt.client.extension.JWTClient ;
import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException ;
import org.wso2.carbon.registry.core.Registry ;
import org.wso2.carbon.registry.core.Resource ;
import org.wso2.carbon.registry.core.ResourceImpl ;
import org.wso2.carbon.registry.core.exceptions.RegistryException ;
import org.wso2.carbon.user.api.UserStoreException ;
import org.wso2.carbon.utils.CarbonUtils ;
@ -54,7 +52,6 @@ import javax.activation.DataHandler;
import javax.net.ssl.KeyManagerFactory ;
import javax.net.ssl.SSLContext ;
import javax.net.ssl.TrustManagerFactory ;
import javax.ws.rs.GET ;
import javax.ws.rs.POST ;
import javax.ws.rs.Path ;
import javax.ws.rs.PathParam ;
@ -72,7 +69,7 @@ import java.util.ArrayList;
import java.util.List ;
@Path ( "/admin/devicetype" )
public class Device TypePublisherAdminServiceImpl implements DeviceTypePublish erAdminService {
public class Device AnalyticsArtifactUploaderAdminServiceImpl implements DeviceAnalyticsArtifactUpload erAdminService {
/ * *
* required soap header for authorization
@ -109,7 +106,7 @@ public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherA
private String tenantDomain ;
private static final Log log = LogFactory . getLog ( Device TypePublish erAdminServiceImpl. class ) ;
private static final Log log = LogFactory . getLog ( Device AnalyticsArtifactUpload erAdminServiceImpl. class ) ;
private static final String DEFAULT_RESOURCE_LOCATION = "/resources/devicetypes" ;
private static final String CAR_FILE_LOCATION = CarbonUtils . getCarbonHome ( ) + File . separator + "repository" +
File . separator + "resources" + File . separator + "devicetypes" ;
@ -119,12 +116,14 @@ public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherA
private static final String IOT_MGT_PORT = "${iot.manager.https.port}" ;
private static final String IOT_MGT_HOST_NAME = "${iot.manager.host}" ;
private static final String DAS_URL = DEFAULT_HTTP_PROTOCOL + "://" + DAS_HOST_NAME
+ ":" + DAS_PORT + "/services/CarbonAppUploader " + " /";
+ ":" + DAS_PORT + "/services/CarbonAppUploader /";
private static final String DAS_EVENT_RECEIVER_EP = DEFAULT_HTTP_PROTOCOL + "://" + DAS_HOST_NAME
+ ":" + DAS_PORT + "/services/EventReceiverAdminService" + "/" ;
+ ":" + DAS_PORT + "/services/EventReceiverAdminService/" ;
private static final String DAS_EVENT_STREAM_EP = DEFAULT_HTTP_PROTOCOL + "://" + DAS_HOST_NAME
+ ":" + DAS_PORT + "/services/EventStreamAdminService/" ;
private static final String IOT_MGT_URL = DEFAULT_HTTP_PROTOCOL + "://" + IOT_MGT_HOST_NAME
+ ":" + IOT_MGT_PORT + "/services/CarbonAppUploader " + " /";
+ ":" + IOT_MGT_PORT + "/services/CarbonAppUploader /";
private static final String MEDIA_TYPE_XML = "application/xml" ;
private static final String DEVICE_MANAGEMENT_TYPE = "device_management" ;
private static final String TENANT_DOMAIN_PROPERTY = "\\$\\{tenant-domain\\}" ;
@ -134,7 +133,6 @@ public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherA
@POST
@Path ( "/deploy/{type}" )
public Response doPublish ( @PathParam ( "type" ) String type ) {
try {
//Getting the tenant Domain
tenantDomain = PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . getTenantDomain ( ) ;
@ -159,33 +157,86 @@ public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherA
String authValue = AUTHORIZATION_HEADER_VALUE + " " + new String ( Base64 . encodeBase64 (
jwtClient . getJwtToken ( tenantAdminUser ) . getBytes ( ) ) ) ;
List < Header > list = new ArrayList < Header > ( ) ;
List < Header > list = new ArrayList < > ( ) ;
Header httpHeader = new Header ( ) ;
httpHeader . setName ( AUTHORIZATION_HEADER ) ;
httpHeader . setValue ( authValue ) ;
list . add ( httpHeader ) ; //"https"
List < String > streamFileList = getStreamsList ( type ) ;
List < String > receiverFileList = getReceiversList ( type ) ;
if ( ! tenantDomain . equals ( MultitenantConstants . SUPER_TENANT_DOMAIN_NAME ) ) {
if ( streamFileList ! = null ) {
publishDynamicEventStream ( type , MultitenantConstants . SUPER_TENANT_DOMAIN_NAME , streamFileList ) ;
}
if ( receiverFileList ! = null ) {
publishDynamicEventReceivers ( type , MultitenantConstants . SUPER_TENANT_DOMAIN_NAME , receiverFileList ) ;
}
}
if ( streamFileList ! = null ) {
publishDynamicEventStream ( type , tenantDomain , streamFileList ) ;
}
if ( deployAnalyticsCapp ( type , list ) ) {
return Response . status ( Response . Status . BAD_REQUEST )
. entity ( "\"Error, Artifact does not exist.\"" ) . build ( ) ;
}
if ( receiverFileList ! = null ) {
publishDynamicEventReceivers ( type , tenantDomain , receiverFileList ) ;
}
return Response . status ( Response . Status . CREATED ) . entity ( "\"OK. \\n Successfully uploaded the artifacts.\"" )
. build ( ) ;
} catch ( AxisFault e ) {
log . error ( "failed to publish event definitions for tenantDomain:" + tenantDomain , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
} catch ( RemoteException e ) {
log . error ( "Failed to connect with the remote services:" + tenantDomain , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
} catch ( JWTClientException e ) {
log . error ( "Failed to generate jwt token for tenantDomain:" + tenantDomain , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
} catch ( UserStoreException e ) {
log . error ( "Failed to connect with the user store, tenantDomain: " + tenantDomain , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
} catch ( CertificateException | UnrecoverableKeyException | KeyStoreException |
KeyManagementException | IOException | NoSuchAlgorithmException e ) {
log . error ( "Failed to access keystore for, tenantDomain: " + tenantDomain , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
} catch ( RegistryException e ) {
log . error ( "Failed to load tenant, tenantDomain: " + tenantDomain , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
} catch ( ParseException e ) {
log . error ( "Invalid stream definition for device type" + type + " for tenant, tenantDomain: " + tenantDomain , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
}
}
private boolean deployAnalyticsCapp ( @PathParam ( "type" ) String type , List < Header > list ) throws IOException , RegistryException {
CarbonAppUploaderStub carbonAppUploaderStub = null ;
try {
File directory = new File ( CAR_FILE_LOCATION + File . separator + type ) ;
if ( directory . isDirectory ( ) & & directory . exists ( ) ) {
UploadedFileItem [ ] uploadedFileItems = loadCappFromFileSystem ( type ) ;
if ( uploadedFileItems . length > 0 ) {
CarbonAppUploaderStub carbonAppUploaderStub = new CarbonAppUploaderStub ( Utils . replaceSystemProperty (
IOT_MGT_URL ) ) ;
Options appUploaderOptions = carbonAppUploaderStub . _getServiceClient ( ) . getOptions ( ) ;
if ( appUploaderOptions = = null ) {
appUploaderOptions = new Options ( ) ;
}
appUploaderOptions . setProperty ( HTTPConstants . HTTP_HEADERS , list ) ;
appUploaderOptions . setProperty ( HTTPConstants . CUSTOM_PROTOCOL_HANDLER
, new Protocol ( DEFAULT_HTTP_PROTOCOL , ( ProtocolSocketFactory ) new SSLProtocolSocketFactory
( sslContext ) , Integer . parseInt ( Utils . replaceSystemProperty ( IOT_MGT_PORT ) ) ) ) ;
carbonAppUploaderStub . _getServiceClient ( ) . setOptions ( appUploaderOptions ) ;
carbonAppUploaderStub . uploadApp ( uploadedFileItems ) ;
if ( DEVICE_MANAGEMENT_TYPE . equals ( type . toLowerCase ( ) ) ) {
carbonAppUploaderStub = new CarbonAppUploaderStub ( Utils . replaceSystemProperty (
IOT_MGT_URL ) ) ;
Options appUploaderOptions = carbonAppUploaderStub . _getServiceClient ( ) . getOptions ( ) ;
if ( appUploaderOptions = = null ) {
appUploaderOptions = new Options ( ) ;
}
appUploaderOptions . setProperty ( HTTPConstants . HTTP_HEADERS, list ) ;
appUploaderOptions . setProperty ( HTTPConstants . CUSTOM_PROTOCOL_HANDLER
, new Protocol ( DEFAULT_HTTP_PROTOCOL ,
( ProtocolSocketFactory ) new SSLProtocolSocketFactory
( sslContext ) , Integer . parseInt ( Utils . replaceSystemProperty (
IOT_MGT_PORT ) ) ) ) ;
if ( ! DEVICE_MANAGEMENT_TYPE . equals ( type . toLowerCase ( ) ) ) {
carbonAppUploaderStub . _getServiceClient ( ) . setOptions ( appUploaderOptions ) ;
carbonAppUploaderStub . uploadApp ( uploadedFileItems ) ;
} else {
carbonAppUploaderStub = new CarbonAppUploaderStub ( Utils . replaceSystemProperty ( DAS_URL ) ) ;
appUploaderOptions = carbonAppUploaderStub . _getServiceClient ( ) . getOptions ( ) ;
Options appUploaderOptions = carbonAppUploaderStub . _getServiceClient ( ) . getOptions ( ) ;
if ( appUploaderOptions = = null ) {
appUploaderOptions = new Options ( ) ;
}
@ -198,72 +249,30 @@ public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherA
carbonAppUploaderStub . _getServiceClient ( ) . setOptions ( appUploaderOptions ) ;
carbonAppUploaderStub . uploadApp ( uploadedFileItems ) ;
}
int tenantId = PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . getTenantId ( ) ;
Registry registry = DeviceMgtAPIUtils . getRegistryService ( ) . getConfigSystemRegistry ( tenantId ) ;
if ( ! registry . resourceExists ( DEFAULT_RESOURCE_LOCATION + type + ".exist" ) ) {
Resource resource = new ResourceImpl ( ) ;
resource . setContent ( "</exist>" ) ;
resource . setMediaType ( MEDIA_TYPE_XML ) ;
registry . put ( DEFAULT_RESOURCE_LOCATION + type + ".exist" , resource ) ;
}
}
if ( ! tenantDomain . equals ( MultitenantConstants . SUPER_TENANT_DOMAIN_NAME ) ) {
publishDynamicEventReceivers ( type , tenantDomain ) ;
}
publishDynamicEventReceivers ( type , MultitenantConstants . SUPER_TENANT_DOMAIN_NAME ) ;
publishDynamicEventStream ( type , MultitenantConstants . SUPER_TENANT_DOMAIN_NAME ) ;
} else {
return Response . status ( Response . Status . BAD_REQUEST )
. entity ( "\"Error, Artifact does not exist.\"" ) . build ( ) ;
}
} catch ( Exception e ) {
log . error ( "Capp deployment failed due to " + e . getMessage ( ) , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity (
"\"Error, Artifact deployment has failed\"" ) . build ( ) ;
}
return Response . status ( Response . Status . CREATED ) . entity ( "\"OK. \\n Successfully uploaded the artifacts.\"" )
. build ( ) ;
}
@GET
@Path ( "/deploy/{type}/status" )
@Override
public Response getStatus ( @PathParam ( "type" ) String deviceType ) {
int tenantId = PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . getTenantId ( ) ;
Registry registry = null ;
try {
registry = DeviceMgtAPIUtils . getRegistryService ( ) . getConfigSystemRegistry ( tenantId ) ;
if ( registry . resourceExists ( DEFAULT_RESOURCE_LOCATION + deviceType + ".exist" ) ) {
return Response . status ( Response . Status . OK ) . entity ( "Exist" ) . build ( ) ;
} else {
return Response . status ( Response . Status . NO_CONTENT ) . entity ( "Does not Exist" ) . build ( ) ;
return true ;
}
} catch ( RegistryException e ) {
log . error ( "Registry failed to load." + e . getMessage ( ) , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity (
"\"Error, Artifact status check has failed\"" ) . build ( ) ;
return false ;
} finally {
cleanup ( carbonAppUploaderStub ) ;
}
}
private void publishDynamicEventReceivers ( String deviceType , String tenantDomain , List < String > receiversList )
throws IOException , UserStoreException , JWTClientException {
private void publishDynamicEventReceivers ( String deviceType , String tenantDomain ) {
PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . startTenantFlow ( ) ;
PrivilegedCarbonContext . startTenantFlow ( ) ;
PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . setTenantDomain ( tenantDomain , true ) ;
EventReceiverAdminServiceStub receiverAdminServiceStub = null ;
try {
EventReceiverAdminServiceStub receiverAdminServiceStub = new EventReceiverAdminServiceStub ( Utils . replaceSystemProperty ( DAS_EVENT_RECEIVER_EP ) ) ;
receiverAdminServiceStub = new EventReceiverAdminServiceStub
( Utils . replaceSystemProperty ( DAS_EVENT_RECEIVER_EP ) ) ;
Options eventReciverOptions = receiverAdminServiceStub . _getServiceClient ( ) . getOptions ( ) ;
if ( eventReciverOptions = = null ) {
eventReciverOptions = new Options ( ) ;
}
String username =null ;
String username ;
if ( ! tenantDomain . equals ( MultitenantConstants . SUPER_TENANT_DOMAIN_NAME ) ) {
username = PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . getUserRealm ( )
. getRealmConfiguration ( ) . getAdminUserName ( ) + "@" + tenantDomain ;
@ -278,7 +287,7 @@ public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherA
String authValue = AUTHORIZATION_HEADER_VALUE + " " + new String ( Base64 . encodeBase64 (
jwtClient . getJwtToken ( username ) . getBytes ( ) ) ) ;
List < Header > list = new ArrayList < Header > ( ) ;
List < Header > list = new ArrayList < > ( ) ;
Header httpHeader = new Header ( ) ;
httpHeader . setName ( AUTHORIZATION_HEADER ) ;
httpHeader . setValue ( authValue ) ;
@ -287,40 +296,28 @@ public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherA
eventReciverOptions . setProperty ( HTTPConstants . HTTP_HEADERS , list ) ;
eventReciverOptions . setProperty ( HTTPConstants . CUSTOM_PROTOCOL_HANDLER
, new Protocol ( DEFAULT_HTTP_PROTOCOL
, ( ProtocolSocketFactory ) new SSLProtocolSocketFactory ( sslContext )
, Integer . parseInt ( Utils . replaceSystemProperty ( DAS_PORT ) ) ) ) ;
, ( ProtocolSocketFactory ) new SSLProtocolSocketFactory ( sslContext )
, Integer . parseInt ( Utils . replaceSystemProperty ( DAS_PORT ) ) ) ) ;
receiverAdminServiceStub . _getServiceClient ( ) . setOptions ( eventReciverOptions ) ;
List < String > receiversList = getReceiversList ( deviceType ) ;
for ( String receiverContent : receiversList ) {
receiverAdminServiceStub . deployEventReceiverConfiguration ( receiverContent ) ;
}
} catch ( AxisFault e ) {
log . error ( "publishing dynamic event receiver is failed due to " + e . getMessage ( ) , e ) ;
} catch ( RemoteException e ) {
log . error ( "publishing dynamic event receiver is failed due to " + e . getMessage ( ) , e ) ;
} catch ( IOException e ) {
log . error ( "publishing dynamic event receiver is failed due to " + e . getMessage ( ) , e ) ;
} catch ( JWTClientException e ) {
log . error ( "publishing dynamic event receiver is failed due to " + e . getMessage ( ) , e ) ;
} catch ( UserStoreException e ) {
log . error ( "publishing dynamic event receiver is failed due to " + e . getMessage ( ) , e ) ;
} finally {
cleanup ( receiverAdminServiceStub ) ;
PrivilegedCarbonContext . endTenantFlow ( ) ;
}
}
private void publishDynamicEventStream ( String deviceType , String tenantDomain , List < String > streamList )
throws IOException , UserStoreException , JWTClientException , ParseException {
private void publishDynamicEventStream ( String deviceType , String tenantDomain ) {
PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . startTenantFlow ( ) ;
PrivilegedCarbonContext . startTenantFlow ( ) ;
PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . setTenantDomain ( tenantDomain , true ) ;
EventStreamAdminServiceStub eventStreamAdminServiceStub = null ;
try {
EventStreamAdminServiceStub eventStreamAdminServiceStub = new EventStreamAdminServiceStub ( Utils . replaceSystemProperty ( DAS_EVENT_RECEIVER _EP) ) ;
eventStreamAdminServiceStub = new EventStreamAdminServiceStub
( Utils . replaceSystemProperty ( DAS_EVENT_STREAM _EP) ) ;
Options eventReciverOptions = eventStreamAdminServiceStub . _getServiceClient ( ) . getOptions ( ) ;
if ( eventReciverOptions = = null ) {
eventReciverOptions = new Options ( ) ;
@ -340,7 +337,7 @@ public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherA
String authValue = AUTHORIZATION_HEADER_VALUE + " " + new String ( Base64 . encodeBase64 (
jwtClient . getJwtToken ( username ) . getBytes ( ) ) ) ;
List < Header > list = new ArrayList < Header > ( ) ;
List < Header > list = new ArrayList < > ( ) ;
Header httpHeader = new Header ( ) ;
httpHeader . setName ( AUTHORIZATION_HEADER ) ;
httpHeader . setValue ( authValue ) ;
@ -349,45 +346,32 @@ public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherA
eventReciverOptions . setProperty ( HTTPConstants . HTTP_HEADERS , list ) ;
eventReciverOptions . setProperty ( HTTPConstants . CUSTOM_PROTOCOL_HANDLER
, new Protocol ( DEFAULT_HTTP_PROTOCOL
, ( ProtocolSocketFactory ) new SSLProtocolSocketFactory ( sslContext )
, Integer . parseInt ( Utils . replaceSystemProperty ( DAS_PORT ) ) ) ) ;
, ( ProtocolSocketFactory ) new SSLProtocolSocketFactory ( sslContext )
, Integer . parseInt ( Utils . replaceSystemProperty ( DAS_PORT ) ) ) ) ;
eventStreamAdminServiceStub . _getServiceClient ( ) . setOptions ( eventReciverOptions ) ;
List < String > streamList = getStreamsList ( deviceType ) ;
for ( String streamContent : streamList ) {
JSONParser jsonParser = new JSONParser ( ) ;
JSONObject steamJson = ( JSONObject ) jsonParser . parse ( streamContent ) ;
String name = ( String ) steamJson . get ( "name" ) ;
String version = ( String ) steamJson . get ( "version" ) ;
String streamId = name + ":" + version ;
if ( eventStreamAdminServiceStub . getStreamDefinitionAsString ( streamId ) = = null ) {
if ( eventStreamAdminServiceStub . getStreamDefinitionDto ( streamId ) = = null ) {
eventStreamAdminServiceStub . addEventStreamDefinitionAsString ( streamContent ) ;
}
}
} catch ( AxisFault e ) {
log . error ( "publishing dynamic event receiver is failed due to " + e . getMessage ( ) , e ) ;
} catch ( RemoteException e ) {
log . error ( "publishing dynamic event receiver is failed due to " + e . getMessage ( ) , e ) ;
} catch ( IOException e ) {
log . error ( "publishing dynamic event receiver is failed due to " + e . getMessage ( ) , e ) ;
} catch ( JWTClientException e ) {
log . error ( "publishing dynamic event receiver is failed due to " + e . getMessage ( ) , e ) ;
} catch ( UserStoreException e ) {
log . error ( "publishing dynamic event receiver is failed due to " + e . getMessage ( ) , e ) ;
} catch ( ParseException e ) {
log . error ( "publishing dynamic event receiver is failed due to " + e . getMessage ( ) , e ) ;
} finally {
cleanup ( eventStreamAdminServiceStub ) ;
PrivilegedCarbonContext . endTenantFlow ( ) ;
}
}
private List < String > getReceiversList ( String deviceType ) throws IOException {
File directory = new File ( CAR_FILE_LOCATION + File . separator + deviceType + File . separator + "receiver" ) ;
if ( ! directory . exists ( ) ) {
return null ;
}
File [ ] receiverFiles = directory . listFiles ( new FilenameFilter ( ) {
@Override
public boolean accept ( File dir , String name ) {
@ -396,8 +380,8 @@ public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherA
} ) ;
List < String > receiverList = new ArrayList < > ( ) ;
for ( File receiverFile : receiverFiles ) {
String receiverContent = new String ( Files . readAllBytes ( receiverFile . toPath ( ) ) ) ;
receiverContent . replaceAll ( TENANT_DOMAIN_PROPERTY , tenantDomain . toLowerCase ( ) ) ;
String receiverContent Template = new String ( Files . readAllBytes ( receiverFile . toPath ( ) ) ) ;
final String receiverContent = receiverContentTemplate . replaceAll ( TENANT_DOMAIN_PROPERTY , tenantDomain . toLowerCase ( ) ) ;
receiverList . add ( receiverContent ) ;
}
@ -405,8 +389,10 @@ public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherA
}
private List < String > getStreamsList ( String deviceType ) throws IOException {
File directory = new File ( CAR_FILE_LOCATION + File . separator + deviceType + File . separator + "streams" ) ;
if ( ! directory . exists ( ) ) {
return null ;
}
File [ ] receiverFiles = directory . listFiles ( new FilenameFilter ( ) {
@Override
public boolean accept ( File dir , String name ) {
@ -415,11 +401,9 @@ public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherA
} ) ;
List < String > streamList = new ArrayList < > ( ) ;
for ( File StreamFile : receiverFiles ) {
String receiverContent = new String ( Files . readAllBytes ( StreamFile . toPath ( ) ) ) ;
receiverContent . replaceAll ( TENANT_DOMAIN_PROPERTY , tenantDomain . toLowerCase ( ) ) ;
streamList . add ( receiverContent ) ;
String streamContent = new String ( Files . readAllBytes ( StreamFile . toPath ( ) ) ) ;
streamList . add ( streamContent ) ;
}
return streamList ;
}
@ -507,6 +491,15 @@ public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherA
SSLContext . setDefault ( sslContext ) ;
}
private void cleanup ( Stub stub ) {
if ( stub ! = null ) {
try {
stub . cleanup ( ) ;
} catch ( AxisFault axisFault ) {
//do nothing
}
}
}
}