Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Instrument Control
NomadCommandSystem
Commits
c4c15e95
Commit
c4c15e95
authored
Dec 16, 2014
by
helene ortiz
Browse files
Migration GUI files in server
parent
61502640
Changes
12
Hide whitespace changes
Inline
Side-by-side
src/fr/ill/ics/bridge/ControllerManager.java
View file @
c4c15e95
...
...
@@ -82,7 +82,4 @@ public abstract class ControllerManager {
public
abstract
void
reloadControllers
();
public
abstract
String
getControllerNameWithRole
(
Controller
controller
,
String
role
);
public
abstract
String
getFileContent
(
String
controllerType
,
String
fileName
);
public
abstract
void
setFileContent
(
String
controllerType
,
String
fileName
,
String
content
);
}
src/fr/ill/ics/bridge/DriverManager.java
View file @
c4c15e95
...
...
@@ -60,7 +60,4 @@ public abstract class DriverManager {
public
abstract
Long
getChannel
(
String
driverName
);
public
abstract
void
reconnectDriver
(
String
driverName
);
public
abstract
String
getFileContent
(
String
controllerType
,
String
fileName
);
public
abstract
void
setFileContent
(
String
controllerType
,
String
fileName
,
String
content
);
}
\ No newline at end of file
src/fr/ill/ics/bridge/ResourceManager.java
0 → 100644
View file @
c4c15e95
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package
fr.ill.ics.bridge
;
import
fr.ill.ics.nscclient.servant.CorbaResourceManager
;
import
fr.ill.ics.nscclient.servant.ResourceNotFoundException
;
public
abstract
class
ResourceManager
{
private
static
ResourceManager
instance
=
null
;
public
static
ResourceManager
getInstance
()
{
return
instance
;
}
public
static
void
initInstance
(
String
serverId
)
{
instance
=
new
CorbaResourceManager
(
serverId
);
instance
.
init
();
}
public
static
void
resetInstance
()
{
instance
=
null
;
}
protected
abstract
void
init
();
public
abstract
String
getFileContent
(
String
controllerType
,
String
fileName
)
throws
ResourceNotFoundException
;
public
abstract
void
setFileContent
(
String
controllerType
,
String
fileName
,
String
content
);
}
src/fr/ill/ics/core/property/PropertyManager.java
View file @
c4c15e95
...
...
@@ -18,6 +18,7 @@
package
fr.ill.ics.core.property
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Iterator
;
...
...
@@ -33,6 +34,7 @@ import java.util.logging.Logger;
import
fr.ill.ics.bridge.Controller
;
import
fr.ill.ics.bridge.ControllerManager
;
import
fr.ill.ics.bridge.DriverManager
;
import
fr.ill.ics.bridge.ResourceManager
;
import
fr.ill.ics.bridge.command.AtomicCommandWrapper
;
import
fr.ill.ics.core.property.format.DecimalFormat
;
import
fr.ill.ics.core.property.format.PropertyFormat
;
...
...
@@ -44,6 +46,7 @@ import fr.ill.ics.nscclient.dataprovider.ServantDatabase;
import
fr.ill.ics.nscclient.servant.ClientServantDescriptor
;
import
fr.ill.ics.nscclient.servant.CorbaServant
;
import
fr.ill.ics.nscclient.servant.DynamicPropertyDescriptor
;
import
fr.ill.ics.nscclient.servant.ResourceNotFoundException
;
import
fr.ill.ics.util.ConfigManager
;
import
fr.ill.ics.util.FileHelper
;
...
...
@@ -184,14 +187,12 @@ public class PropertyManager {
// Search on server side
String
fileName
=
controllerType
+
ConfigManager
.
PROPERTIES_PATTERN
;
String
fileContent
=
DriverManager
.
getInstance
().
getFileContent
(
controllerType
,
fileName
);
if
(
fileContent
==
null
)
{
fileContent
=
ControllerManager
.
getInstance
().
getFileContent
(
controllerType
,
fileName
);
}
if
(
fileContent
!=
null
)
{
String
fileContent
;
try
{
fileContent
=
ResourceManager
.
getInstance
().
getFileContent
(
controllerType
,
fileName
);
propertyParser
.
parseXmlString
(
fileContent
);
processParsedProperties
();
}
else
{
}
catch
(
ResourceNotFoundException
e
)
{
clientFilesFoundPerControllerType
.
put
(
controllerType
,
false
);
return
false
;
}
...
...
@@ -209,13 +210,13 @@ public class PropertyManager {
clientFilesFoundPerControllerType
.
put
(
controllerType
,
true
);
return
true
;
}
/**
*
*/
private
void
processParsedProperties
()
{
LinkedHashMap
<
String
,
XMLPropertyDescriptor
>
propertiesFromFile
=
new
LinkedHashMap
<
String
,
XMLPropertyDescriptor
>(
propertyParser
.
getProperties
().
size
());
propertiesFromFile
.
putAll
(
propertyParser
.
getProperties
());
...
...
@@ -233,8 +234,8 @@ public class PropertyManager {
Map
propertiesTypesFromFile
=
new
LinkedHashMap
(
propertyParser
.
getProperties
().
size
());
propertiesTypesFromFile
.
putAll
(
propertyParser
.
getPropertyTypes
());
}
/**
...
...
@@ -372,17 +373,31 @@ public class PropertyManager {
// create dynamically a list of properties and create a new xml file
Map
propertyNamesAndTypes
=
servant
.
getPropertyNamesAndTypes
();
String
propertiesFile
=
propertyParser
.
createPropertyFile
(
servant
.
getType
(),
propertyNamesAndTypes
);
if
(
propertiesFile
!=
null
)
{
propertyParser
.
parseXmlFile
(
propertiesFile
);
LinkedHashMap
<
String
,
XMLPropertyDescriptor
>
propertiesFromFile
=
new
LinkedHashMap
<
String
,
XMLPropertyDescriptor
>(
propertyParser
.
getProperties
().
size
());
propertiesFromFile
.
putAll
(
propertyParser
.
getProperties
());
propertiesByControllerType
.
put
(
propertyParser
.
getControllerType
(),
propertiesFromFile
);
Map
propertiesTypesFromFile
=
new
LinkedHashMap
<
String
,
String
>(
propertyParser
.
getPropertyTypes
().
size
());
propertiesTypesFromFile
.
putAll
(
propertyParser
.
getPropertyTypes
());
// Does controllerTypeProperties.xml file exist on client side ?
String
fileName
=
ConfigManager
.
CONTROLLERS_DIRECTORY
+
servant
.
getType
()
+
ConfigManager
.
FILE_SEPARATOR
+
servant
.
getType
()
+
ConfigManager
.
PROPERTIES_PATTERN
;
boolean
existsOnClientSide
=
new
File
(
fileName
).
exists
();
if
(!
existsOnClientSide
)
{
fileName
=
servant
.
getType
()
+
ConfigManager
.
PROPERTIES_PATTERN
;
String
fileContent
;
try
{
fileContent
=
ResourceManager
.
getInstance
().
getFileContent
(
servant
.
getType
(),
fileName
);
}
catch
(
ResourceNotFoundException
e
)
{
// file does not exist on server side either
String
propertiesFile
=
propertyParser
.
createPropertyFile
(
servant
.
getType
(),
propertyNamesAndTypes
,
servant
.
getId
());
if
(
propertiesFile
!=
null
)
{
propertyParser
.
parseXmlFile
(
propertiesFile
);
if
(
propertyParser
.
getProperties
()
!=
null
)
{
LinkedHashMap
<
String
,
XMLPropertyDescriptor
>
propertiesFromFile
=
new
LinkedHashMap
<
String
,
XMLPropertyDescriptor
>(
propertyParser
.
getProperties
().
size
());
propertiesFromFile
.
putAll
(
propertyParser
.
getProperties
());
propertiesByControllerType
.
put
(
propertyParser
.
getControllerType
(),
propertiesFromFile
);
Map
propertiesTypesFromFile
=
new
LinkedHashMap
<
String
,
String
>(
propertyParser
.
getPropertyTypes
().
size
());
propertiesTypesFromFile
.
putAll
(
propertyParser
.
getPropertyTypes
());
}
}
}
}
}
...
...
src/fr/ill/ics/core/property/parser/PropertyParser.java
View file @
c4c15e95
...
...
@@ -18,10 +18,6 @@
package
fr.ill.ics.core.property.parser
;
import
java.io.BufferedWriter
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.util.Iterator
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
...
...
@@ -31,6 +27,7 @@ import java.util.logging.Level;
import
org.xml.sax.Attributes
;
import
org.xml.sax.SAXException
;
import
fr.ill.ics.bridge.ResourceManager
;
import
fr.ill.ics.core.property.parser.descriptor.ConditionDescriptor
;
import
fr.ill.ics.core.property.parser.descriptor.XMLDynamicPropertyDescriptor
;
import
fr.ill.ics.core.property.parser.descriptor.XMLPropertyDescriptor
;
...
...
@@ -38,7 +35,7 @@ import fr.ill.ics.util.ConfigManager;
import
fr.ill.ics.util.GenericParser
;
public
class
PropertyParser
extends
GenericParser
{
// ***************************************************************************
// ************************* Possible nodes **********************************
// ***************************************************************************
...
...
@@ -56,10 +53,10 @@ public class PropertyParser extends GenericParser {
public
final
static
String
TAG_RANGE
=
"range"
;
public
final
static
String
TAG_PROPERTY_RANGE
=
"property_range"
;
public
final
static
String
TAG_SPECIFIC_VALUES
=
"specific_values"
;
// For dynamic properties
public
final
static
String
TAG_DYNAMIC_PROPERTY
=
"dynamic_property"
;
// ********************************************************************************
// ************************* Possible attributes **********************************
// ********************************************************************************
...
...
@@ -80,42 +77,42 @@ public class PropertyParser extends GenericParser {
private
final
static
String
ATTRIBUTE_MAX_EXCLUDED
=
"max_excluded"
;
private
final
static
String
ATTRIBUTE_DECIMAL_FORMAT_PROPERTY_NAME
=
"property_name"
;
private
final
static
String
ATTRIBUTE_SIZE_PROPERTY
=
"size_property"
;
private
String
controllerType
;
private
Map
properties
;
// KEY=property name VALUE=PropertyDescriptor instance
private
Map
propertyTypes
;
// KEY=property name VALUE=property type
private
XMLPropertyDescriptor
propertyDescriptor
;
// For dynamic properties
private
XMLDynamicPropertyDescriptor
dynamicPropertyDescriptor
;
private
Map
dynamicProperties
;
// KEY=dynamic property generic name VALUE=DynamicPropertyDescriptor instance
public
void
startElement
(
String
uri
,
String
localName
,
String
qName
,
Attributes
attributes
)
throws
SAXException
{
super
.
startElement
(
uri
,
localName
,
qName
,
attributes
);
if
(
qName
.
equals
(
TAG_CONTROLLER
))
{
controllerType
=
getAttribute
(
attributes
,
ATTRIBUTE_CONTROLLER_TYPE
);
properties
=
new
LinkedHashMap
();
dynamicProperties
=
new
LinkedHashMap
();
propertyTypes
=
new
LinkedHashMap
();
}
else
if
(
qName
.
equals
(
TAG_PROPERTY
))
{
propertyDescriptor
=
new
XMLPropertyDescriptor
(
getAttribute
(
attributes
,
ATTRIBUTE_PROPERTY_NAME
),
getAttribute
(
attributes
,
ATTRIBUTE_PROPERTY_TYPE
));
propertyDescriptor
.
setMaxLength
(
getAttribute
(
attributes
,
ATTRIBUTE_MAX_LENGTH
));
propertyDescriptor
.
setUndoable
(
getAttribute
(
attributes
,
ATTRIBUTE_IS_UNDOABLE
));
// Store it in the map
properties
.
put
(
propertyDescriptor
.
getPropertyName
(),
propertyDescriptor
);
// store property name and type
propertyTypes
.
put
(
propertyDescriptor
.
getPropertyName
(),
propertyDescriptor
.
getPropertyType
());
}
else
if
(
qName
.
equals
(
TAG_DYNAMIC_PROPERTY
))
{
dynamicPropertyDescriptor
=
new
XMLDynamicPropertyDescriptor
(
getAttribute
(
attributes
,
ATTRIBUTE_PROPERTY_NAME
),
getAttribute
(
attributes
,
ATTRIBUTE_PROPERTY_TYPE
));
dynamicPropertyDescriptor
.
setMaxLength
(
getAttribute
(
attributes
,
ATTRIBUTE_MAX_LENGTH
));
dynamicPropertyDescriptor
.
setUndoable
(
getAttribute
(
attributes
,
ATTRIBUTE_IS_UNDOABLE
));
if
(
attributeIsPresent
(
attributes
,
ATTRIBUTE_SIZE_PROPERTY
))
{
dynamicPropertyDescriptor
.
setSizePropertyName
(
getAttribute
(
attributes
,
ATTRIBUTE_SIZE_PROPERTY
));
}
...
...
@@ -124,9 +121,9 @@ public class PropertyParser extends GenericParser {
dynamicProperties
.
put
(
dynamicPropertyDescriptor
.
getPropertyName
(),
dynamicPropertyDescriptor
);
// store property name and type
propertyTypes
.
put
(
dynamicPropertyDescriptor
.
getPropertyName
(),
dynamicPropertyDescriptor
.
getPropertyType
());
propertyDescriptor
=
dynamicPropertyDescriptor
;
}
else
if
(
qName
.
equals
(
TAG_DECIMAL_FORMAT
))
{
propertyDescriptor
.
setFormat
(
TAG_DECIMAL_FORMAT
);
if
(
attributeIsPresent
(
attributes
,
ATTRIBUTE_NB_DECIMAL_PLACES
))
{
...
...
@@ -134,14 +131,14 @@ public class PropertyParser extends GenericParser {
}
else
if
(
attributeIsPresent
(
attributes
,
ATTRIBUTE_DECIMAL_FORMAT_PROPERTY_NAME
))
{
propertyDescriptor
.
setDecimaFormatPropertyName
(
getAttribute
(
attributes
,
ATTRIBUTE_DECIMAL_FORMAT_PROPERTY_NAME
));
}
}
else
if
(
qName
.
equals
(
TAG_SCIENTIFIC_FORMAT
))
{
propertyDescriptor
.
setFormat
(
TAG_SCIENTIFIC_FORMAT
);
propertyDescriptor
.
setNbDecimalPlaces
(
getAttribute
(
attributes
,
ATTRIBUTE_NB_DECIMAL_PLACES
));
}
else
if
(
qName
.
equals
(
TAG_HEXADECIMAL_FORMAT
))
{
propertyDescriptor
.
setFormat
(
TAG_HEXADECIMAL_FORMAT
);
}
else
if
(
qName
.
equals
(
TAG_UNIT_FORMAT
))
{
propertyDescriptor
.
setFormat
(
TAG_UNIT_FORMAT
);
...
...
@@ -149,26 +146,26 @@ public class PropertyParser extends GenericParser {
ConditionDescriptor
conditionDescriptor
=
new
ConditionDescriptor
(
TAG_GREATER_THAN
);
conditionDescriptor
.
setGreaterThanValue
(
getAttribute
(
attributes
,
ATTRIBUTE_GREATER_THAN_VALUE
));
propertyDescriptor
.
addCondition
(
conditionDescriptor
);
}
else
if
(
qName
.
equals
(
TAG_LOWER_THAN
))
{
ConditionDescriptor
conditionDescriptor
=
new
ConditionDescriptor
(
TAG_LOWER_THAN
);
conditionDescriptor
.
setLowerThanValue
(
getAttribute
(
attributes
,
ATTRIBUTE_LOWER_THAN_VALUE
));
propertyDescriptor
.
addCondition
(
conditionDescriptor
);
}
else
if
(
qName
.
equals
(
TAG_STRICTLY_POSITIVE
))
{
ConditionDescriptor
conditionDescriptor
=
new
ConditionDescriptor
(
TAG_STRICTLY_POSITIVE
);
propertyDescriptor
.
addCondition
(
conditionDescriptor
);
}
else
if
(
qName
.
equals
(
TAG_POSITIVE
))
{
ConditionDescriptor
conditionDescriptor
=
new
ConditionDescriptor
(
TAG_POSITIVE
);
propertyDescriptor
.
addCondition
(
conditionDescriptor
);
}
else
if
(
qName
.
equals
(
TAG_RANGE
))
{
ConditionDescriptor
conditionDescriptor
=
new
ConditionDescriptor
(
TAG_RANGE
);
conditionDescriptor
.
setMin
(
getAttribute
(
attributes
,
ATTRIBUTE_MIN_INCLUDED
));
conditionDescriptor
.
setMax
(
getAttribute
(
attributes
,
ATTRIBUTE_MAX_INCLUDED
));
propertyDescriptor
.
addCondition
(
conditionDescriptor
);
}
else
if
(
qName
.
equals
(
TAG_PROPERTY_RANGE
))
{
ConditionDescriptor
conditionDescriptor
=
new
ConditionDescriptor
(
TAG_PROPERTY_RANGE
);
conditionDescriptor
.
setMinProperty
(
getAttribute
(
attributes
,
ATTRIBUTE_MIN_PROPERTY
));
...
...
@@ -185,14 +182,14 @@ public class PropertyParser extends GenericParser {
ConditionDescriptor
conditionDescriptor
=
new
ConditionDescriptor
(
TAG_SPECIFIC_VALUES
);
conditionDescriptor
.
setValues
(
getAttribute
(
attributes
,
ATTRIBUTE_SPECIFIC_VALUES
));
propertyDescriptor
.
addCondition
(
conditionDescriptor
);
}
else
{
// Unknown tag
LOGGER
.
logp
(
Level
.
WARNING
,
this
.
getClass
().
getName
(),
"startElement"
,
"Unknown tag ("
+
qName
+
") found in "
+
fileName
+
" file. Tag will be ignored."
);
}
}
/**
* Overridden to reset dynamic property (to avoid size tags out from dynamic property one)
*/
...
...
@@ -202,82 +199,59 @@ public class PropertyParser extends GenericParser {
dynamicPropertyDescriptor
=
null
;
}
}
/**
* Create a new file
* @param type
*/
public
String
createPropertyFile
(
String
controllerType
,
Map
propertiesAndTypes
)
{
// Create a new filename
String
filename
=
ConfigManager
.
CONTROLLERS_DIRECTORY
+
controllerType
+
ConfigManager
.
FILE_SEPARATOR
+
controllerType
+
ConfigManager
.
getInstance
().
getString
(
"propertiesFileExtension"
);
if
(!
new
File
(
filename
).
getParentFile
().
exists
())
{
new
File
(
filename
).
getParentFile
().
mkdir
();
}
try
{
File
propertiesFile
=
new
File
(
filename
);
if
(!
propertiesFile
.
exists
())
{
BufferedWriter
out
=
new
BufferedWriter
(
new
FileWriter
(
propertiesFile
));
out
.
write
(
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>"
);
out
.
write
(
LINE_SEPARATOR
);
out
.
write
(
"<!-- Automatically generated Property file : remove this line if modified -->"
);
out
.
write
(
LINE_SEPARATOR
);
out
.
write
(
LINE_SEPARATOR
);
out
.
write
(
"<"
+
TAG_CONTROLLER
+
" "
+
ATTRIBUTE_CONTROLLER_TYPE
+
"=\""
+
controllerType
+
"\">"
);
out
.
write
(
LINE_SEPARATOR
);
// Iterate over map of properties and create new entry for each
// It is more efficient to use an iterator on the entrySet of the map, to avoid the Map.get(key) lookup.
Iterator
it
=
propertiesAndTypes
.
entrySet
().
iterator
();
Entry
entry
;
String
propertyTypeAttribute
;
while
(
it
.
hasNext
())
{
entry
=
(
Entry
)
it
.
next
();
// Get the type attribute from the config manager. if it doesn't exist
// then ignor the property
propertyTypeAttribute
=
(
String
)
entry
.
getValue
();
if
(!
propertyTypeAttribute
.
equals
(
""
))
{
out
.
write
(
"\t<"
+
TAG_PROPERTY
+
" "
+
ATTRIBUTE_PROPERTY_NAME
+
"=\""
+
entry
.
getKey
()
+
"\" "
+
ATTRIBUTE_PROPERTY_TYPE
+
"=\""
+
propertyTypeAttribute
+
"\">"
);
out
.
write
(
LINE_SEPARATOR
);
out
.
write
(
"\t</"
+
TAG_PROPERTY
+
">"
);
out
.
write
(
LINE_SEPARATOR
);
out
.
write
(
LINE_SEPARATOR
);
}
}
out
.
write
(
"</"
+
TAG_CONTROLLER
+
">"
);
out
.
write
(
LINE_SEPARATOR
);
out
.
close
();
public
String
createPropertyFile
(
String
controllerType
,
Map
propertiesAndTypes
,
int
servantId
)
{
String
filename
=
controllerType
+
ConfigManager
.
PROPERTIES_PATTERN
;
String
fileContent
=
""
;
fileContent
=
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>"
+
LINE_SEPARATOR
;
fileContent
=
fileContent
+
"<!-- Automatically generated Property file : remove this line if modified -->"
+
LINE_SEPARATOR
;
fileContent
=
fileContent
+
"<"
+
TAG_CONTROLLER
+
" "
+
ATTRIBUTE_CONTROLLER_TYPE
+
"=\""
+
controllerType
+
"\">"
+
LINE_SEPARATOR
;
// Iterate over map of properties and create new entry for each
// It is more efficient to use an iterator on the entrySet of the map, to avoid the Map.get(key) lookup.
Iterator
it
=
propertiesAndTypes
.
entrySet
().
iterator
();
Entry
entry
;
String
propertyTypeAttribute
;
while
(
it
.
hasNext
())
{
entry
=
(
Entry
)
it
.
next
();
// Get the type attribute from the config manager. if it doesn't exist
// then ignor the property
propertyTypeAttribute
=
(
String
)
entry
.
getValue
();
if
(!
propertyTypeAttribute
.
equals
(
""
))
{
fileContent
=
fileContent
+
"\t<"
+
TAG_PROPERTY
+
" "
+
ATTRIBUTE_PROPERTY_NAME
+
"=\""
+
entry
.
getKey
()
+
"\" "
+
ATTRIBUTE_PROPERTY_TYPE
+
"=\""
+
propertyTypeAttribute
+
"\">"
+
LINE_SEPARATOR
;
fileContent
=
fileContent
+
"\t</"
+
TAG_PROPERTY
+
">"
+
LINE_SEPARATOR
;
}
}
catch
(
IOException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"IOException while creating properties file for : "
+
controllerType
);
return
null
;
}
fileContent
=
fileContent
+
"</"
+
TAG_CONTROLLER
+
">"
+
LINE_SEPARATOR
;
ResourceManager
.
getInstance
().
setFileContent
(
controllerType
,
filename
,
fileContent
);
return
filename
;
}
public
Map
getProperties
()
{
return
properties
;
}
public
Map
getDynamicProperties
()
{
return
dynamicProperties
;
}
public
Map
getPropertyTypes
()
{
return
propertyTypes
;
}
public
String
getControllerType
()
{
return
controllerType
;
}
}
src/fr/ill/ics/nscclient/servant/CorbaControllerManager.java
View file @
c4c15e95
...
...
@@ -18,10 +18,6 @@
package
fr.ill.ics.nscclient.servant
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashSet
;
...
...
@@ -273,28 +269,4 @@ public class CorbaControllerManager extends ControllerManager implements ServerC
CorbaController
corbaController
=
(
CorbaController
)
controller
;
return
servantManager
.
getControllerNameWithRole
(
corbaController
.
getId
(),
role
);
}
public
String
getFileContent
(
String
controllerType
,
String
fileName
)
{
String
fullFilePath
=
"/home/dpt/ortizh/tmp/"
+
fileName
;
if
(
new
File
(
fullFilePath
).
exists
())
{
try
{
String
content
=
""
;
String
line
;
BufferedReader
in
=
new
BufferedReader
(
new
FileReader
(
fullFilePath
));
while
((
line
=
in
.
readLine
())
!=
null
)
{
content
=
content
+
line
+
"\n"
;
}
in
.
close
();
return
content
;
}
catch
(
IOException
e
)
{
System
.
err
.
println
(
"IOException while getting content of file "
+
fullFilePath
);
e
.
printStackTrace
();
}
}
return
null
;
}
public
void
setFileContent
(
String
controllerType
,
String
fileName
,
String
content
)
{
}
}
\ No newline at end of file
src/fr/ill/ics/nscclient/servant/CorbaDriverManager.java
View file @
c4c15e95
...
...
@@ -18,10 +18,6 @@
package
fr.ill.ics.nscclient.servant
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.Iterator
;
...
...
@@ -145,26 +141,4 @@ public class CorbaDriverManager extends DriverManager {
}
}
public
String
getFileContent
(
String
controllerType
,
String
fileName
)
{
String
fullFilePath
=
"/home/dpt/ortizh/tmp/"
+
controllerType
+
"/"
+
fileName
;
if
(
new
File
(
fullFilePath
).
exists
())
{
try
{
String
content
=
""
;
String
line
;
BufferedReader
in
=
new
BufferedReader
(
new
FileReader
(
fullFilePath
));
while
((
line
=
in
.
readLine
())
!=
null
)
{
content
=
content
+
line
+
"\n"
;
}
in
.
close
();
return
content
;
}
catch
(
IOException
e
)
{
System
.
err
.
println
(
"IOException while getting content of file "
+
fullFilePath
);
e
.
printStackTrace
();
}
}
return
null
;
}
public
void
setFileContent
(
String
controllerType
,
String
fileName
,
String
content
)
{
}
}
\ No newline at end of file
src/fr/ill/ics/nscclient/servant/CorbaResourceManager.java
0 → 100644
View file @
c4c15e95
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package
fr.ill.ics.nscclient.servant
;
import
fr.ill.ics.bridge.ResourceManager
;
import
fr.ill.ics.nscclient.sessionmanagement.ServerSessionManager
;
public
class
CorbaResourceManager
extends
ResourceManager
{
private
String
serverId
;
private
CorbaServantManager
servantManager
;
/**
*
*/
public
CorbaResourceManager
(
String
serverId
)
{
this
.
serverId
=
serverId
;
}
/**
*
*/
protected
void
init
()
{
this
.
servantManager
=
ServerSessionManager
.
getInstance
(
serverId
).
getServantManager
();
}
protected
void
reset
()
{
this
.
servantManager
=
ServerSessionManager
.
getInstance
(
serverId
).
getServantManager
();
}
public
String
getFileContent
(
String
controllerType
,
String
fileName
)
throws
ResourceNotFoundException
{
System
.
out
.
println
(
fileName
);
return
servantManager
.
readResourceFile
(
controllerType
,
fileName
);
/*
String fullFilePath = "/home/dpt/ortizh/tmp/" + fileName;
if (new File(fullFilePath).exists()) {
try {