Resolve comments

pull/436/head
prathabanKavin 5 months ago
parent b70986464d
commit af8894f950

@ -1,3 +1,21 @@
/*
* Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you 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. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package io.entgra.device.mgt.core.application.mgt.common.dto; package io.entgra.device.mgt.core.application.mgt.common.dto;
import io.entgra.device.mgt.core.application.mgt.common.CategorizedSubscriptionResult; import io.entgra.device.mgt.core.application.mgt.common.CategorizedSubscriptionResult;

@ -1,3 +1,21 @@
/*
* Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you 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. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package io.entgra.device.mgt.core.application.mgt.common.dto; package io.entgra.device.mgt.core.application.mgt.common.dto;
import java.util.List; import java.util.List;

@ -1,3 +1,21 @@
/*
* Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you 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. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package io.entgra.device.mgt.core.device.mgt.core.dto; package io.entgra.device.mgt.core.device.mgt.core.dto;
public class DeviceDetailsDTO { public class DeviceDetailsDTO {

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
* *
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License, * Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -391,6 +391,11 @@ public class OperationDAOUtil {
return operation; return operation;
} }
/**
* @param blob
* @return
* @throws SQLException
*/
public static JSONObject convertBlobToJsonObject(Blob blob) throws SQLException { public static JSONObject convertBlobToJsonObject(Blob blob) throws SQLException {
String jsonString; String jsonString;
try (InputStream inputStream = blob.getBinaryStream(); try (InputStream inputStream = blob.getBinaryStream();
@ -413,19 +418,24 @@ public class OperationDAOUtil {
jsonString = new JSONObject(obj).toString(); jsonString = new JSONObject(obj).toString();
} }
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
throw new SQLException("Failed to deserialize object from BLOB", e); String msg = "Failed to deserialize object from BLOB";
log.error(msg, e);
throw new SQLException(msg, e);
} }
} else { } else {
// If not serialized, treat it as plain JSON string // If not serialized, treat it as plain JSON string
jsonString = new String(blobBytes, "UTF-8"); jsonString = new String(blobBytes, "UTF-8");
} }
} catch (IOException e) { } catch (IOException e) {
throw new SQLException("Failed to convert BLOB to JSON string", e); String msg = "Failed to convert BLOB to JSON string";
log.error(msg, e);
throw new SQLException(msg, e);
} }
// Convert JSON string to JSONObject // Convert JSON string to JSONObject
if (jsonString == null || jsonString.isEmpty()) { if (jsonString == null || jsonString.isEmpty()) {
throw new SQLException("Converted JSON string is null or empty"); String msg = "Converted JSON string is null or empty";
log.error(msg);
throw new SQLException(msg);
} }
return new JSONObject(jsonString); return new JSONObject(jsonString);
} }

Loading…
Cancel
Save