-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* first parts to implement file upload feature * Add partial implementation of getFile for in-memory backend Signed-off-by: Zai Müller-Zhang <[email protected]> * Implements File support for Submodelrepository MongoDB Signed-off-by: Mohammad Ghazanfar Ali Danish <[email protected]> * Add In-Memory backend und unit Test. Add Rest API for file upload Created unit test for file upload Signed-off-by: Zai Müller-Zhang <[email protected]> * Add new Exception for mqtt Add json file for test Signed-off-by: Zai Müller-Zhang <[email protected]> * Fixes the File upload issue with HTTP Signed-off-by: Mohammad Ghazanfar Ali Danish <[email protected]> * Add new Exception for mqtt Add json file for test Signed-off-by: Zai Müller-Zhang <[email protected]> * Add http unit test for get- set- delete files Signed-off-by: Zai Müller-Zhang <[email protected]> Co-authored-by: Danish, Mohammad Ghazanfar Ali<[email protected]> * In SubmodelRepositoryApiHTTPController, Change Http status code to "precondition failed" if the submodel element is not a file sme. In InMemorySubmodelRepository, delete unused exception. Refactor Http Test * move unit tests for file upload and download to SubmodelRepositorySubmodelHTTPTestSuite Signed-off-by: Zai Müller-Zhang <[email protected]> * Change expected value of the assertion for the setFileValue unit test. Signed-off-by: Zai Müller-Zhang <[email protected]> * Adjust assertion in unit test getDefaultSubmodelRepositoryName() Signed-off-by: Zai Müller-Zhang <[email protected]> * Add new cosntructor in MongoDBSubmodelRepositoryFactory which uses the default repository name Signed-off-by: Zai Müller-Zhang <[email protected]> * Put the private mathod after the unit tests. Signed-off-by: Zai Müller-Zhang <[email protected]> * Delete unnecessary exception throw Signed-off-by: Zai Müller-Zhang <[email protected]> * add @autowire=false to the constructor Signed-off-by: Zai Müller-Zhang <[email protected]> * Handles correct closing of input streams - Minor refactoring Signed-off-by: Mohammad Ghazanfar Ali Danish <[email protected]> * Refactors code Signed-off-by: Mohammad Ghazanfar Ali Danish <[email protected]> --------- Signed-off-by: Zai Müller-Zhang <[email protected]> Signed-off-by: Mohammad Ghazanfar Ali Danish <[email protected]> Co-authored-by: Zai Müller-Zhang <[email protected]> Co-authored-by: Mohammad Ghazanfar Ali Danish <[email protected]>
- Loading branch information
1 parent
0187f43
commit 07fa3d7
Showing
32 changed files
with
1,335 additions
and
235 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...src/main/java/org/eclipse/digitaltwin/basyx/core/exceptions/ElementNotAFileException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/******************************************************************************* | ||
* Copyright (C) 2023 the Eclipse BaSyx Authors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to | ||
* the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
* | ||
* SPDX-License-Identifier: MIT | ||
******************************************************************************/ | ||
|
||
package org.eclipse.digitaltwin.basyx.core.exceptions; | ||
|
||
/** | ||
* Indicates that the requested submodel element is not a File SubmodelElement | ||
* | ||
* @author danish | ||
* | ||
*/ | ||
@SuppressWarnings("serial") | ||
public class ElementNotAFileException extends RuntimeException { | ||
public ElementNotAFileException() { | ||
} | ||
|
||
public ElementNotAFileException(String elementId) { | ||
super(getMsg(elementId)); | ||
} | ||
|
||
private static String getMsg(String elementId) { | ||
return "SubmodelElement with Id " + elementId + " is not a File"; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...in/java/org/eclipse/digitaltwin/basyx/core/exceptions/FeatureNotImplementedException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/******************************************************************************* | ||
* Copyright (C) 2023 the Eclipse BaSyx Authors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to | ||
* the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
* | ||
* SPDX-License-Identifier: MIT | ||
******************************************************************************/ | ||
|
||
package org.eclipse.digitaltwin.basyx.core.exceptions; | ||
|
||
/** | ||
* This exception is used for features where certain functionalities are not implemented yet. | ||
* | ||
* @author zhangzai | ||
* | ||
*/ | ||
@SuppressWarnings("serial") | ||
public class FeatureNotImplementedException extends RuntimeException { | ||
|
||
public FeatureNotImplementedException() { | ||
super(); | ||
} | ||
|
||
public FeatureNotImplementedException(String featureName) { | ||
super(getMessage(featureName)); | ||
} | ||
|
||
private static String getMessage(String featureName) { | ||
return "Feature " + featureName + " is not implemented yet"; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...rc/main/java/org/eclipse/digitaltwin/basyx/core/exceptions/FileDoesNotExistException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/******************************************************************************* | ||
* Copyright (C) 2023 the Eclipse BaSyx Authors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to | ||
* the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
* | ||
* SPDX-License-Identifier: MIT | ||
******************************************************************************/ | ||
|
||
package org.eclipse.digitaltwin.basyx.core.exceptions; | ||
|
||
/** | ||
* Indicates that the requested file does not exist | ||
* | ||
* @author danish | ||
* | ||
*/ | ||
@SuppressWarnings("serial") | ||
public class FileDoesNotExistException extends RuntimeException { | ||
public FileDoesNotExistException() { | ||
} | ||
|
||
public FileDoesNotExistException(String elementId) { | ||
super(getMsg(elementId)); | ||
} | ||
|
||
private static String getMsg(String elementId) { | ||
return "Requested File inside File SubmodelElement with ID : " + elementId + " does not exist"; | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
...re/src/main/java/org/eclipse/digitaltwin/basyx/core/exceptions/FileHandlingException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/******************************************************************************* | ||
* Copyright (C) 2023 the Eclipse BaSyx Authors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to | ||
* the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
* | ||
* SPDX-License-Identifier: MIT | ||
******************************************************************************/ | ||
|
||
package org.eclipse.digitaltwin.basyx.core.exceptions; | ||
|
||
/** | ||
* Indicates that the provided file could not be handled | ||
* | ||
* @author zhangzai | ||
* | ||
*/ | ||
@SuppressWarnings("serial") | ||
public class FileHandlingException extends RuntimeException { | ||
|
||
public FileHandlingException() { | ||
super(); | ||
} | ||
|
||
public FileHandlingException(String fileName) { | ||
super(getMessage(fileName)); | ||
} | ||
|
||
private static String getMessage(String fileName) { | ||
return "Exception occurred while handling the file: " + fileName; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.