added permission fix for operation and synchronised application creation to avoid duplicate subscription

4.x.x
ayyoob 8 years ago
parent 6a0c0cb299
commit 5e4b0564b7

@ -107,12 +107,14 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi
validityPeriod = registrationProfile.getValidityPeriod(); validityPeriod = registrationProfile.getValidityPeriod();
} }
String applicationName = "devicetype_app_" + StringUtils.join(registrationProfile.getTags(), "_"); String applicationName = registrationProfile.getApplicationName();
ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( synchronized (ApiApplicationRegistrationServiceImpl.class) {
applicationName, registrationProfile.getTags(), ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(
ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, applicationName, registrationProfile.getTags(),
registrationProfile.isAllowedToAllDomains(), validityPeriod); ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username,
return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); registrationProfile.isAllowedToAllDomains(), validityPeriod);
return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build();
}
} catch (APIManagerException e) { } catch (APIManagerException e) {
String msg = "Error occurred while registering an application with apis '" String msg = "Error occurred while registering an application with apis '"
+ StringUtils.join(registrationProfile.getTags(), ",") + "'"; + StringUtils.join(registrationProfile.getTags(), ",") + "'";

@ -30,6 +30,8 @@ import javax.xml.bind.annotation.XmlRootElement;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class RegistrationProfile { public class RegistrationProfile {
@XmlElement(required = true)
private String applicationName;
@XmlElement(required = true) @XmlElement(required = true)
private String tags[]; private String tags[];
@XmlElement(required = true) @XmlElement(required = true)
@ -37,6 +39,14 @@ public class RegistrationProfile {
@XmlElement(required = false) @XmlElement(required = false)
private String validityPeriod; private String validityPeriod;
public String getApplicationName() {
return applicationName;
}
public void setApiApplicationName(String apiApplicationName) {
this.applicationName = apiApplicationName;
}
public String[] getTags() { public String[] getTags() {
return tags; return tags;
} }

@ -51,6 +51,16 @@ var operationModule = function () {
feature["contentType"] = features[i].contentType; feature["contentType"] = features[i].contentType;
feature["deviceType"] = deviceType; feature["deviceType"] = deviceType;
feature["params"] = []; feature["params"] = [];
var featuresEntry = utility.getDeviceTypeConfig(deviceType)["deviceType"]["features"];
if (featuresEntry) {
var featureEntry = featuresEntry[features[i].code];
if (featureEntry) {
var permissionEntry = featureEntry["permission"];
if (permissionEntry) {
feature["permission"] = permissionEntry
}
}
}
var metaData = features[i].metadataEntries; var metaData = features[i].metadataEntries;
if (metaData) { if (metaData) {
for (var j = 0; j < metaData.length; j++) { for (var j = 0; j < metaData.length; j++) {

Loading…
Cancel
Save