* ============LICENSE_START=======================================================
* VID
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2018 Nokia. All rights reserved.
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 - 2019 Nokia. All rights reserved.
* ================================================================================
* Licensed 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.
public static final String TBL_NAME = "fn_role";
public static final String TEMP_DELIMITER ="***";
public static final String OLD_DELIMITER = "_";
+ public static final String CrLf = ";\r\n";
@Override
public String generateRoleScript(Boolean firstRun) {
- String query = "USE " + DB_NAME + ";\r\n" +
+ String query = "USE " + DB_NAME + CrLf +
"SET SQL_SAFE_UPDATES = 0;\r\n";
try {
HttpResponse<SubscriberList> allSubscribers = aaiOverTLSClient.getAllSubscribers();
}
catch (Exception e) {
- Log.error("There was an error in updating roles "+e.getMessage());
+ Log.error("There was an error in updating roles ", e);
}
return query;
}
String availableRoles="";
HashMap<String,String> servicesNames = new HashMap<>();
for (Subscriber subscriber: subscribers.customer) {
- AaiResponse<Services> subscriberResponse = client.getSubscriberData(subscriber.globalCustomerId);
+ AaiResponse<Services> subscriberResponse = client.getSubscriberData(subscriber.globalCustomerId, true);
for(ServiceSubscription service: subscriberResponse.getT().serviceSubscriptions.serviceSubscription) {
servicesNames.put(service.serviceType,"");
String roleName = "'" + subscriber.subscriberName + ModelConstants.ROLE_DELIMITER + service.serviceType + "'";
query = query + "('" + subscriber.globalCustomerId + "','" + subscriberName + "') ,";
}
if(query.length() > 0)
- query = query.substring(0, query.length()-1) + ";\r\n";
+ query = query.substring(0, query.length()-1) + CrLf;
return query;
}
}
});
if(query[0].length() > 0)
- query[0] = query[0].substring(0, query[0].length()-1) + ";\r\n";
+ query[0] = query[0].substring(0, query[0].length()-1) + CrLf;
return query[0];
}
private String createTemporaryTableAvailableRoles(String availableRoles) {
String query = "CREATE TEMPORARY TABLE IF NOT EXISTS available_roles(rname VARCHAR(255));\r\n";
- query += "INSERT INTO available_roles VALUES "+availableRoles+";\r\n";
+ query += "INSERT INTO available_roles VALUES "+availableRoles+CrLf;
return query;
}
}
private String dropTemporaryTable(String table) {
- return "DROP TEMPORARY TABLE IF EXISTS " + table + ";\r\n";
+ return "DROP TEMPORARY TABLE IF EXISTS " + table + CrLf;
}
}