f33f7b5c29
+ Refactored all imports + Fixed a bug for the logging regarding removing \n \t \r + Updated to current MGO release + Changed the name of ICCC
40 lines
1.4 KiB
Go
40 lines
1.4 KiB
Go
package WebContent
|
|
|
|
import (
|
|
"github.com/SommerEngineering/Ocean/ConfigurationDB"
|
|
"github.com/SommerEngineering/Ocean/CustomerDB"
|
|
"github.com/SommerEngineering/Ocean/Log"
|
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func init() {
|
|
|
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameINIT, `Run init for the web content.`)
|
|
defer Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameINIT, `Init for web content done.`)
|
|
|
|
if isInit {
|
|
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelWARN, LM.SeverityHigh, LM.ImpactNone, LM.MessageNameINIT, `The web content is already fine.`)
|
|
return
|
|
}
|
|
|
|
filename = ConfigurationDB.Read(`FilenameWebResources`)
|
|
dbSession, gridFS := CustomerDB.GridFS()
|
|
defer dbSession.Close()
|
|
|
|
if gridFile, errGridFile := gridFS.Open(filename); errGridFile != nil {
|
|
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactCritical, LM.MessageNameDATABASE, `Was not able to open the web content out of the GridFS!`, filename, errGridFile.Error())
|
|
return
|
|
} else {
|
|
defer gridFile.Close()
|
|
if data, ioError := ioutil.ReadAll(gridFile); ioError != nil {
|
|
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactCritical, LM.MessageNameDATABASE, `Was not able to read the web content file.`, filename, ioError.Error())
|
|
return
|
|
} else {
|
|
zipData = data
|
|
}
|
|
}
|
|
|
|
return
|
|
}
|