- Attribute attributeData = null;
- AttributeValues attributeValueData = null;
- String userId = null;
- if (fromAPI) {
- //JsonNode json = root.get("dictionaryFields");
- attributeData = (Attribute)mapper.readValue(root.get("dictionaryFields").toString(), Attribute.class);
- attributeValueData = (AttributeValues)mapper.readValue(root.get("dictionaryFields").toString(), AttributeValues.class);
- userId = "API";
-
- //check if update operation or create, get id for data to be updated and update attributeData
- if (request.getParameter("operation").equals("update")) {
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(attributeData.getXacmlId(), "xacmlId", Attribute.class);
- int id = 0;
- Attribute data = (Attribute) duplicateData.get(0);
- id = data.getId();
- if(id==0){
- isFakeUpdate=true;
- attributeData.setId(1);
- } else {
- attributeData.setId(id);
- }
- attributeData.setUserCreatedBy(this.getUserInfo(userId));
- }
- } else {
- attributeData = (Attribute)mapper.readValue(root.get("attributeDictionaryData").toString(), Attribute.class);
- attributeValueData = (AttributeValues)mapper.readValue(root.get("attributeDictionaryData").toString(), AttributeValues.class);
- userId = root.get("userid").textValue();
- }
- String userValue = "";
- int counter = 0;
- if(attributeValueData.getUserDataTypeValues().size() > 0){
- for(Object attribute : attributeValueData.getUserDataTypeValues()){
- if(attribute instanceof LinkedHashMap<?, ?>){
- String key = ((LinkedHashMap<?, ?>) attribute).get("attributeValues").toString();
- if(counter>0){
- userValue = userValue + ",";
- }
- userValue = userValue + key ;
- counter ++;
- }
+ Attribute attributeData = null;
+ AttributeValues attributeValueData = null;
+ String userId = null;
+ if(fromAPI){
+ attributeData = mapper.readValue(root.get(dictionaryFields).toString(), Attribute.class);
+ attributeValueData = mapper.readValue(root.get(dictionaryFields).toString(), AttributeValues.class);
+ userId = "API";
+ }else{
+ attributeData = mapper.readValue(root.get("attributeDictionaryData").toString(), Attribute.class);
+ attributeValueData = mapper.readValue(root.get("attributeDictionaryData").toString(), AttributeValues.class);
+ userId = root.get("userid").textValue();
+ }
+ UserInfo userInfo = utils.getUserInfo(userId);
+ List<Object> duplicateData = commonClassDao.checkDuplicateEntry(attributeData.getXacmlId(), xacmlId, Attribute.class);
+ boolean duplicateflag = false;
+ if(!duplicateData.isEmpty()){
+ Attribute data = (Attribute) duplicateData.get(0);
+ if(request.getParameter(operation) != null && "update".equals(request.getParameter(operation))){
+ attributeData.setId(data.getId());
+ }else if((request.getParameter(operation) != null && !"update".equals(request.getParameter(operation))) ||
+ (request.getParameter(operation) == null && (data.getId() != attributeData.getId()))){
+ duplicateflag = true;