Program: 15572
Project: 15572
Buggy source:
private String processRequestImpl(String api,Object object,String clientId,String token){
  String result="String_Node_Str";
  try {
    SensorManager sensorManager=new SensorManager();
    Sensor sensor=null;
    String triples="String_Node_Str";
switch (api) {
case "String_Node_Str":
      if (object instanceof Sensor)       sensor=(Sensor)object;
 else       break;
    logger.info("String_Node_Str" + sensor.getId());
  if ((sensor.getMetaGraph() == null) || (sensor.getMetaGraph() == "String_Node_Str"))   sensor.setMetaGraph(propertyManagement.getSchedulerLsmMetaGraph());
String permissionString="String_Node_Str";
if (PermissionsUtil.getUserType(sensor.getMetaGraph()) == PermissionsUtil.GUESS_USER) permissionString=PermissionsUtil.ADD_SENSOR_GUESS;
 else if (PermissionsUtil.getUserType(sensor.getMetaGraph()) == PermissionsUtil.DEMO_USER) permissionString=PermissionsUtil.ADD_SENSOR_DEMO;
 else permissionString=PermissionsUtil.ADD_SENSOR_MAIN;
if (SecurityUtil.hasPermission(PermissionsUtil.LSM_ALL,getServletContext(),token,clientId) || SecurityUtil.hasPermission(permissionString,getServletContext(),token,clientId)) {
sensorManager.setDataGraph(sensor.getDataGraph());
sensorManager.setMetaGraph(sensor.getMetaGraph());
triples=TriplesDataRetriever.getSensorTripleMetadata(sensor);
sensorManager.insertTriplesToGraph(sensor.getMetaGraph(),triples);
logger.info("String_Node_Str");
}
 else {
result="String_Node_Str";
logger.info(result);
}
break;
case "String_Node_Str":
Observation observation=null;
if (object instanceof Observation) observation=(Observation)object;
 else break;
logger.info("String_Node_Str" + observation.getId());
triples="String_Node_Str";
if ((observation.getMetaGraph() == null) || (observation.getMetaGraph() == "String_Node_Str")) observation.setMetaGraph(propertyManagement.getLSMLocalMetaGraph());
if (PermissionsUtil.getUserType(observation.getMetaGraph()) == PermissionsUtil.GUESS_USER) permissionString=PermissionsUtil.UPDATE_SENSOR_DATA_GUESS;
 else if (PermissionsUtil.getUserType(observation.getMetaGraph()) == PermissionsUtil.DEMO_USER) permissionString=PermissionsUtil.UPDATE_SENSOR_DATA_DEMO;
 else permissionString=PermissionsUtil.UPDATE_SENSOR_DATA_MAIN;
if (SecurityUtil.hasPermission(PermissionsUtil.LSM_ALL,getServletContext(),token,clientId) || SecurityUtil.hasPermission(permissionString,getServletContext(),token,clientId)) {
sensorManager.setDataGraph(observation.getDataGraph());
sensorManager.setMetaGraph(observation.getMetaGraph());
sensor=sensorManager.getSpecifiedSensorWithSensorId(observation.getSensor());
if (sensor == null) {
result="String_Node_Str" + observation.getSensor() + "String_Node_Str";
return result;
}
String foi="String_Node_Str";
if (observation.getFeatureOfInterest().equals("String_Node_Str") || observation.getFeatureOfInterest() == null) foi=ConnectionManager.propertyManagement.getOpeniotResourceNamespace() + Double.toString(sensor.getPlace().getLat()).replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str") + Double.toString(sensor.getPlace().getLng()).replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
 else foi=observation.getFeatureOfInterest();
triples+=TriplesDataRetriever.getObservationTripleData(observation.getId(),observation.getSensor(),foi,observation.getTimes());
OntModel model=ModelFactory.createOntologyModel();
for (ObservedProperty obv : observation.getReadings()) {
OntClass cl=model.createClass(obv.getPropertyType());
if (obv.getUnit().equals("String_Node_Str")) triples+=TriplesDataRetriever.getTripleDataHasNoUnit("String_Node_Str",cl.getLocalName(),obv.getValue().toString(),observation.getId(),sensor.getProperties().get(obv.getPropertyType()),observation.getTimes());
 else triples+=TriplesDataRetriever.getTripleDataHasUnit("String_Node_Str",cl.getLocalName(),obv.getValue().toString(),obv.getUnit(),observation.getId(),sensor.getProperties().get(obv.getPropertyType()),observation.getTimes());
}
sensorManager.insertTriplesToGraph(observation.getDataGraph(),triples);
logger.info("String_Node_Str");
}
 else {
result="String_Node_Str";
logger.info(result);
}
break;
case "String_Node_Str":
RDFTuple tuple=null;
if (object instanceof RDFTuple) tuple=(RDFTuple)object;
 else break;
if (PermissionsUtil.getUserType(tuple.getGraphURL()) == PermissionsUtil.GUESS_USER) permissionString=PermissionsUtil.ADD_TRIPLES_GUESS;
 else if (PermissionsUtil.getUserType(tuple.getGraphURL()) == PermissionsUtil.DEMO_USER) permissionString=PermissionsUtil.ADD_TRIPLES_DEMO;
 else permissionString=PermissionsUtil.ADD_TRIPLES_MAIN;
if (SecurityUtil.hasPermission(PermissionsUtil.LSM_ALL,getServletContext(),token,clientId) || SecurityUtil.hasPermission(permissionString,getServletContext(),token,clientId)) {
sensorManager.insertTriplesToGraph(tuple.getGraphURL(),tuple.getNtriple());
logger.info("String_Node_Str" + tuple.getGraphURL());
}
 else {
result="String_Node_Str";
logger.info(result);
}
break;
case "String_Node_Str":
tuple=null;
if (object instanceof RDFTuple) tuple=(RDFTuple)object;
 else break;
if (PermissionsUtil.getUserType(tuple.getGraphURL()) == PermissionsUtil.GUESS_USER) permissionString=PermissionsUtil.DEL_TRIPLES_GUESS;
 else if (PermissionsUtil.getUserType(tuple.getGraphURL()) == PermissionsUtil.DEMO_USER) permissionString=PermissionsUtil.DEL_TRIPLES_DEMO;
 else permissionString=PermissionsUtil.DEL_TRIPLES_MAIN;
if (SecurityUtil.hasPermission(PermissionsUtil.LSM_ALL,getServletContext(),token,clientId) || SecurityUtil.hasPermission(permissionString,getServletContext(),token,clientId)) {
if (tuple.getNtriple().equals("String_Node_Str")) {
sensorManager.clearGraph(tuple.getGraphURL());
logger.info("String_Node_Str" + tuple.getGraphURL());
}
 else {
sensorManager.deleteTriples(tuple.getGraphURL(),tuple.getNtriple());
logger.info("String_Node_Str" + tuple.getGraphURL());
}
}
 else {
result="String_Node_Str";
logger.info(result);
}
break;
case "String_Node_Str":
HashMap<String,String> patterns=null;
if (PermissionsUtil.getUserType(patterns.get("String_Node_Str")) == PermissionsUtil.GUESS_USER) permissionString=PermissionsUtil.UPDATE_TRIPLES_GUESS;
 else if (PermissionsUtil.getUserType(patterns.get("String_Node_Str")) == PermissionsUtil.DEMO_USER) permissionString=PermissionsUtil.UPDATE_TRIPLES_DEMO;
 else permissionString=PermissionsUtil.UPDATE_TRIPLES_MAIN;
if (SecurityUtil.hasPermission(PermissionsUtil.LSM_ALL,getServletContext(),token,clientId) || SecurityUtil.hasPermission(permissionString,getServletContext(),token,clientId)) {
if (object instanceof HashMap<?,?>) patterns=(HashMap<String,String>)object;
sensorManager.updateGraph(patterns.get("String_Node_Str"),patterns.get("String_Node_Str"),patterns.get("String_Node_Str"));
}
 else {
result="String_Node_Str";
logger.info(result);
}
default :
break;
}
}
 catch (Exception e) {
logger.error("String_Node_Str",e);
result=e.toString();
}
return result;
}

Fixed version (ground truth):
private String processRequestImpl(String api,Object object,String clientId,String token){
  String result="String_Node_Str";
  try {
    SensorManager sensorManager=new SensorManager();
    Sensor sensor=null;
    String triples="String_Node_Str";
switch (api) {
case "String_Node_Str":
      if (object instanceof Sensor)       sensor=(Sensor)object;
 else       break;
    logger.info("String_Node_Str" + sensor.getId());
  if ((sensor.getMetaGraph() == null) || (sensor.getMetaGraph() == "String_Node_Str"))   sensor.setMetaGraph(propertyManagement.getSchedulerLsmMetaGraph());
String permissionString="String_Node_Str";
if (PermissionsUtil.getUserType(sensor.getMetaGraph()) == PermissionsUtil.GUESS_USER) permissionString=PermissionsUtil.ADD_SENSOR_GUESS;
 else if (PermissionsUtil.getUserType(sensor.getMetaGraph()) == PermissionsUtil.DEMO_USER) permissionString=PermissionsUtil.ADD_SENSOR_DEMO;
 else permissionString=PermissionsUtil.ADD_SENSOR_MAIN;
if (SecurityUtil.hasPermission(PermissionsUtil.LSM_ALL,getServletContext(),token,clientId) || SecurityUtil.hasPermission(permissionString,getServletContext(),token,clientId)) {
sensorManager.setDataGraph(sensor.getDataGraph());
sensorManager.setMetaGraph(sensor.getMetaGraph());
triples=TriplesDataRetriever.getSensorTripleMetadata(sensor);
sensorManager.insertTriplesToGraph(sensor.getMetaGraph(),triples);
logger.info("String_Node_Str");
}
 else {
result="String_Node_Str";
logger.info(result);
}
break;
case "String_Node_Str":
Observation observation=null;
if (object instanceof Observation) observation=(Observation)object;
 else break;
logger.info("String_Node_Str" + observation.getId());
triples="String_Node_Str";
if ((observation.getMetaGraph() == null) || (observation.getMetaGraph() == "String_Node_Str")) observation.setMetaGraph(propertyManagement.getLSMLocalMetaGraph());
if (PermissionsUtil.getUserType(observation.getMetaGraph()) == PermissionsUtil.GUESS_USER) permissionString=PermissionsUtil.UPDATE_SENSOR_DATA_GUESS;
 else if (PermissionsUtil.getUserType(observation.getMetaGraph()) == PermissionsUtil.DEMO_USER) permissionString=PermissionsUtil.UPDATE_SENSOR_DATA_DEMO;
 else permissionString=PermissionsUtil.UPDATE_SENSOR_DATA_MAIN;
if (SecurityUtil.hasPermission(PermissionsUtil.LSM_ALL,getServletContext(),token,clientId) || SecurityUtil.hasPermission(permissionString,getServletContext(),token,clientId)) {
sensorManager.setDataGraph(observation.getDataGraph());
sensorManager.setMetaGraph(observation.getMetaGraph());
sensor=sensorManager.getSpecificSensorWithSensorId(observation.getSensor());
if (sensor == null) {
result="String_Node_Str" + observation.getSensor() + "String_Node_Str";
return result;
}
String foi="String_Node_Str";
if (observation.getFeatureOfInterest().equals("String_Node_Str") || observation.getFeatureOfInterest() == null) foi=ConnectionManager.propertyManagement.getOpeniotResourceNamespace() + Double.toString(sensor.getPlace().getLat()).replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str") + Double.toString(sensor.getPlace().getLng()).replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
 else foi=observation.getFeatureOfInterest();
triples+=TriplesDataRetriever.getObservationTripleData(observation.getId(),observation.getSensor(),foi,observation.getTimes());
OntModel model=ModelFactory.createOntologyModel();
for (ObservedProperty obv : observation.getReadings()) {
OntClass cl=model.createClass(obv.getPropertyType());
if (obv.getUnit().equals("String_Node_Str")) triples+=TriplesDataRetriever.getTripleDataHasNoUnit("String_Node_Str",cl.getLocalName(),obv.getValue().toString(),observation.getId(),sensor.getProperties().get(obv.getPropertyType()),observation.getTimes());
 else triples+=TriplesDataRetriever.getTripleDataHasUnit("String_Node_Str",cl.getLocalName(),obv.getValue().toString(),obv.getUnit(),observation.getId(),sensor.getProperties().get(obv.getPropertyType()),observation.getTimes());
}
sensorManager.insertTriplesToGraph(observation.getDataGraph(),triples);
logger.info("String_Node_Str");
}
 else {
result="String_Node_Str";
logger.info(result);
}
break;
case "String_Node_Str":
RDFTuple tuple=null;
if (object instanceof RDFTuple) tuple=(RDFTuple)object;
 else break;
if (PermissionsUtil.getUserType(tuple.getGraphURL()) == PermissionsUtil.GUESS_USER) permissionString=PermissionsUtil.ADD_TRIPLES_GUESS;
 else if (PermissionsUtil.getUserType(tuple.getGraphURL()) == PermissionsUtil.DEMO_USER) permissionString=PermissionsUtil.ADD_TRIPLES_DEMO;
 else permissionString=PermissionsUtil.ADD_TRIPLES_MAIN;
if (SecurityUtil.hasPermission(PermissionsUtil.LSM_ALL,getServletContext(),token,clientId) || SecurityUtil.hasPermission(permissionString,getServletContext(),token,clientId)) {
sensorManager.insertTriplesToGraph(tuple.getGraphURL(),tuple.getNtriple());
logger.info("String_Node_Str" + tuple.getGraphURL());
}
 else {
result="String_Node_Str";
logger.info(result);
}
break;
case "String_Node_Str":
tuple=null;
if (object instanceof RDFTuple) tuple=(RDFTuple)object;
 else break;
if (PermissionsUtil.getUserType(tuple.getGraphURL()) == PermissionsUtil.GUESS_USER) permissionString=PermissionsUtil.DEL_TRIPLES_GUESS;
 else if (PermissionsUtil.getUserType(tuple.getGraphURL()) == PermissionsUtil.DEMO_USER) permissionString=PermissionsUtil.DEL_TRIPLES_DEMO;
 else permissionString=PermissionsUtil.DEL_TRIPLES_MAIN;
if (SecurityUtil.hasPermission(PermissionsUtil.LSM_ALL,getServletContext(),token,clientId) || SecurityUtil.hasPermission(permissionString,getServletContext(),token,clientId)) {
if (tuple.getNtriple().equals("String_Node_Str")) {
sensorManager.clearGraph(tuple.getGraphURL());
logger.info("String_Node_Str" + tuple.getGraphURL());
}
 else {
sensorManager.deleteTriples(tuple.getGraphURL(),tuple.getNtriple());
logger.info("String_Node_Str" + tuple.getGraphURL());
}
}
 else {
result="String_Node_Str";
logger.info(result);
}
break;
case "String_Node_Str":
HashMap<String,String> patterns=null;
if (PermissionsUtil.getUserType(patterns.get("String_Node_Str")) == PermissionsUtil.GUESS_USER) permissionString=PermissionsUtil.UPDATE_TRIPLES_GUESS;
 else if (PermissionsUtil.getUserType(patterns.get("String_Node_Str")) == PermissionsUtil.DEMO_USER) permissionString=PermissionsUtil.UPDATE_TRIPLES_DEMO;
 else permissionString=PermissionsUtil.UPDATE_TRIPLES_MAIN;
if (SecurityUtil.hasPermission(PermissionsUtil.LSM_ALL,getServletContext(),token,clientId) || SecurityUtil.hasPermission(permissionString,getServletContext(),token,clientId)) {
if (object instanceof HashMap<?,?>) patterns=(HashMap<String,String>)object;
sensorManager.updateGraph(patterns.get("String_Node_Str"),patterns.get("String_Node_Str"),patterns.get("String_Node_Str"));
}
 else {
result="String_Node_Str";
logger.info(result);
}
default :
break;
}
}
 catch (Exception e) {
logger.error("String_Node_Str",e);
result=e.toString();
}
return result;
}