fixed commit issues

revert-70aa11f8
ayyoob 8 years ago
parent 536d100fd6
commit d70cea2e46

@ -82,7 +82,7 @@ public class DeviceTypeManagementAdminServiceImpl implements DeviceTypeManagemen
DeviceMgtAPIUtils.getDeviceManagementService().registerDeviceType(httpDeviceTypeManagerService); DeviceMgtAPIUtils.getDeviceManagementService().registerDeviceType(httpDeviceTypeManagerService);
return Response.status(Response.Status.OK).build(); return Response.status(Response.Status.OK).build();
} else { } else {
return Response.status(Response.Status.BAD_REQUEST).entity("device type name does not match the pattern " return Response.status(Response.Status.BAD_REQUEST).entity("Device type name does not match the pattern "
+ DEVICETYPE_REGEX_PATTERN).build(); + DEVICETYPE_REGEX_PATTERN).build();
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {

@ -538,7 +538,7 @@ public class DeviceMgtAPIUtils {
Header httpHeader = new Header(); Header httpHeader = new Header();
httpHeader.setName(AUTHORIZATION_HEADER); httpHeader.setName(AUTHORIZATION_HEADER);
httpHeader.setValue(authValue); httpHeader.setValue(authValue);
list.add(httpHeader);//"https" list.add(httpHeader);
eventReciverOptions.setProperty(HTTPConstants.HTTP_HEADERS, list); eventReciverOptions.setProperty(HTTPConstants.HTTP_HEADERS, list);
eventReciverOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER eventReciverOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER
@ -570,7 +570,7 @@ public class DeviceMgtAPIUtils {
Header httpHeader = new Header(); Header httpHeader = new Header();
httpHeader.setName(AUTHORIZATION_HEADER); httpHeader.setName(AUTHORIZATION_HEADER);
httpHeader.setValue(authValue); httpHeader.setValue(authValue);
list.add(httpHeader);//"https" list.add(httpHeader);
eventReciverOptions.setProperty(HTTPConstants.HTTP_HEADERS, list); eventReciverOptions.setProperty(HTTPConstants.HTTP_HEADERS, list);
eventReciverOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER eventReciverOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER
@ -602,7 +602,7 @@ public class DeviceMgtAPIUtils {
Header httpHeader = new Header(); Header httpHeader = new Header();
httpHeader.setName(AUTHORIZATION_HEADER); httpHeader.setName(AUTHORIZATION_HEADER);
httpHeader.setValue(authValue); httpHeader.setValue(authValue);
list.add(httpHeader);//"https" list.add(httpHeader);
eventReciverOptions.setProperty(HTTPConstants.HTTP_HEADERS, list); eventReciverOptions.setProperty(HTTPConstants.HTTP_HEADERS, list);
eventReciverOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER eventReciverOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER

@ -87,7 +87,7 @@ public class HTTPDeviceTypeManagerService extends DeviceTypeManagerService imple
if (feature.getMetadataEntries() != null && feature.getMetadataEntries().size() > 0) { if (feature.getMetadataEntries() != null && feature.getMetadataEntries().size() > 0) {
List<String> metaValues = new ArrayList<>(); List<String> metaValues = new ArrayList<>();
for (Feature.MetadataEntry metadataEntry : feature.getMetadataEntries()) { for (Feature.MetadataEntry metadataEntry : feature.getMetadataEntries()) {
metadataEntry.getValue(); metaValues.add(metadataEntry.getValue().toString());
} }
configFeature.setMetaData(metaValues); configFeature.setMetaData(metaValues);
} }

@ -135,36 +135,19 @@ public class PropertyBasedPluginDAOImpl implements PluginDAO {
"UPDATE DM_DEVICE_PROPERTIES SET PROPERTY_VALUE = ? WHERE DEVICE_TYPE_NAME = ? AND " + "UPDATE DM_DEVICE_PROPERTIES SET PROPERTY_VALUE = ? WHERE DEVICE_TYPE_NAME = ? AND " +
"DEVICE_IDENTIFICATION = ? AND PROPERTY_NAME = ? AND TENANT_ID= ?"); "DEVICE_IDENTIFICATION = ? AND PROPERTY_NAME = ? AND TENANT_ID= ?");
Device.Property[] properties = new Device.Property[device.getProperties().size()];
int i =0;
for (Device.Property property : device.getProperties()) { for (Device.Property property : device.getProperties()) {
properties[i] = property; if (!deviceProps.contains(property.getName())) {
i++; continue;
stmt.setString(1, getPropertyValue(device.getProperties(), property.getValue())); }
stmt.setString(1, property.getValue());
stmt.setString(1, deviceType); stmt.setString(1, deviceType);
stmt.setString(2, device.getDeviceIdentifier()); stmt.setString(2, device.getDeviceIdentifier());
stmt.setString(3, property.getName()); stmt.setString(3, property.getName());
stmt.setInt(4, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true)); stmt.setInt(4, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true));
stmt.addBatch(); stmt.addBatch();
} }
int[] updates = stmt.executeBatch();
if (updates.length > 0) {
for (int j = 0; j < updates.length; j++) {
if (updates[j] < 0) {
stmt = conn.prepareStatement(
"INSERT INTO DM_DEVICE_PROPERTIES(DEVICE_TYPE_NAME, DEVICE_IDENTIFICATION, PROPERTY_NAME, " +
"PROPERTY_VALUE, TENANT_ID) VALUES (?, ?, ?, ?, ?)");
stmt.setString(1, deviceType);
stmt.setString(2, device.getDeviceIdentifier());
stmt.setString(3, properties[j].getName());
stmt.setString(4, getPropertyValue(device.getProperties(), properties[j].getValue()));
stmt.setInt(5, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true));
stmt.addBatch();
}
}
stmt.executeBatch(); stmt.executeBatch();
status = true; return true;
}
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while modifying the device '" + String msg = "Error occurred while modifying the device '" +
device.getDeviceIdentifier() + "' data on" + deviceType; device.getDeviceIdentifier() + "' data on" + deviceType;
@ -173,7 +156,6 @@ public class PropertyBasedPluginDAOImpl implements PluginDAO {
} finally { } finally {
DeviceTypeUtils.cleanupResources(stmt, null); DeviceTypeUtils.cleanupResources(stmt, null);
} }
return status;
} }
public boolean deleteDevice(String deviceId) throws DeviceTypeMgtPluginException { public boolean deleteDevice(String deviceId) throws DeviceTypeMgtPluginException {

@ -100,6 +100,7 @@ IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[D
CREATE TABLE DM_CONFIG_OPERATION ( CREATE TABLE DM_CONFIG_OPERATION (
OPERATION_ID INTEGER NOT NULL, OPERATION_ID INTEGER NOT NULL,
OPERATION_CONFIG VARBINARY(MAX) DEFAULT NULL, OPERATION_CONFIG VARBINARY(MAX) DEFAULT NULL,
ENABLED BIT NOT NULL DEFAULT 0,
PRIMARY KEY (OPERATION_ID), PRIMARY KEY (OPERATION_ID),
CONSTRAINT FK_DM_OPERATION_CONFIG FOREIGN KEY (OPERATION_ID) REFERENCES CONSTRAINT FK_DM_OPERATION_CONFIG FOREIGN KEY (OPERATION_ID) REFERENCES
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION

@ -86,6 +86,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION (
CREATE TABLE IF NOT EXISTS DM_CONFIG_OPERATION ( CREATE TABLE IF NOT EXISTS DM_CONFIG_OPERATION (
OPERATION_ID INTEGER NOT NULL, OPERATION_ID INTEGER NOT NULL,
OPERATION_CONFIG BLOB DEFAULT NULL, OPERATION_CONFIG BLOB DEFAULT NULL,
ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY (OPERATION_ID), PRIMARY KEY (OPERATION_ID),
CONSTRAINT FK_DM_OPERATION_CONFIG FOREIGN KEY (OPERATION_ID) REFERENCES CONSTRAINT FK_DM_OPERATION_CONFIG FOREIGN KEY (OPERATION_ID) REFERENCES
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION

@ -165,6 +165,7 @@ WHEN (NEW.ID IS NULL)
CREATE TABLE DM_CONFIG_OPERATION ( CREATE TABLE DM_CONFIG_OPERATION (
OPERATION_ID NUMBER(10) NOT NULL, OPERATION_ID NUMBER(10) NOT NULL,
OPERATION_CONFIG BLOB DEFAULT NULL, OPERATION_CONFIG BLOB DEFAULT NULL,
ENABLED NUMBER(10) DEFAULT 0 NOT NULL,
CONSTRAINT PK_DM_CONFIG_OPERATION PRIMARY KEY (OPERATION_ID), CONSTRAINT PK_DM_CONFIG_OPERATION PRIMARY KEY (OPERATION_ID),
CONSTRAINT FK_DM_OPERATION_CONFIG FOREIGN KEY (OPERATION_ID) REFERENCES CONSTRAINT FK_DM_OPERATION_CONFIG FOREIGN KEY (OPERATION_ID) REFERENCES
DM_OPERATION (ID) DM_OPERATION (ID)

@ -72,6 +72,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION (
CREATE TABLE IF NOT EXISTS DM_CONFIG_OPERATION ( CREATE TABLE IF NOT EXISTS DM_CONFIG_OPERATION (
OPERATION_ID INTEGER NOT NULL, OPERATION_ID INTEGER NOT NULL,
OPERATION_CONFIG BYTEA DEFAULT NULL, OPERATION_CONFIG BYTEA DEFAULT NULL,
ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY (OPERATION_ID), PRIMARY KEY (OPERATION_ID),
CONSTRAINT fk_dm_operation_config FOREIGN KEY (OPERATION_ID) REFERENCES CONSTRAINT fk_dm_operation_config FOREIGN KEY (OPERATION_ID) REFERENCES
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION

Loading…
Cancel
Save