|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sage.orion.sdata.servlet.JDBCResourceKind
com.sage.orion.sdata.servlet.swtservice.UIDefinitionResourceKind
public class UIDefinitionResourceKind
This class is a special resource kind class for UI definitions. Since UI definition files can get very large (for example, 95K for the showcase's main UI definition), the files are stored in the appropriate directory structure within the servlet rather than in a database. The directory structure takes into account version, language, category, user ID, and company ID. Non-customized UI definition files are stored in the category's directory while customized ones are stored in the user-specific directories under the category directory. The special value of "-" can be passed in for the language and/or user ID, where "-" means that the sign on information will be used to determine the actual the language and user ID. (The concept of "-" is similar to the concept of using "-" as the default dataset in an SData URL). The UI definition file's name is the UI definition's name followed by a ".xml" file extension. (Note that this name may be different than the value of the "id" attribute in the UI definition's root "ui" element). When a "get" request is received, the UI definition will be retrieved from files stored in that directory structure. When a "put" request is received, the UI definition will be stored in the appropriate file within that directory structure.
Currently, this resource kind only supports GET and PUT requests. Note that a PUT request may end up creating a new file, but that detail is hidden from the caller.
In terms of GET, this resource kind only supports a GET request for a single
UI definition resource, where that GET is done by key. The key to use is
'version;languageCode;category;userID;name'
. For example, the key
might be 'portal61a;-;portal;-;SwtPortalUIDefinition'
to get the UI
definition for the currently signed-on user in their language, or
'portal61a;fra;portal;ADMIN;SwtPortalUIDefinition'
to get the UI
definition for ADMIN assuming the French language.
This resource kind follows a fallback scheme to try to find an appropriate UI
definition resource. It starts by looking for that user's customized version
of the UI definition for the specified language. If that customized version
isn't found, it then looks for the default version of the UI definition for
the specified language. If neither of those files is found and if the
specified language isn't the default of "eng" (the one for English), this
resource kind will fall back to "eng" and try a similar search for the UI
definition. For example, when the key is
'portal61a;fra;portal;ADMIN;SwtPortalUIDefinition'
, the resource kind
will first look for SwtPortalUIDefinition.xml in the
portal61a\fra\portal\ADMIN\SAMINC
directory (SAMINC is the current
dataset) within the directory where UI definitions are stored the servlet.
The search would continue in portal61a\fra\portal
, then
portal61a\eng\portal\ADMIN\SAMINC
, and finally in
portal61a\eng\portal
.
In terms of PUT (update), this resource kind supports a PUT request for a single UI definition resource, where that PUT is done by key. The key to use for the PUT request is the same key that would be used for a GET request.
The PUT request will take the UI definition (passed in as part of the PUT
payload) and save it as the user's customized version of the UI definition
for the specified language. If such a file already exists, that existing file
will be overwritten with the updated UI definition. If the file does not yet
exist, it will be created. (Even though a new file gets created, we still
count it as a PUT because we are updating an already existing UI definition -
after all, the non-customized version has to exist before we can get it and
later save it as a customized version). Note that the default
(non-customized) version of the UI definition is never touched. For example,
when user ADMIN is logged in as a French ("fra") user, doing a PUT with key
'portal61a;-;portal;-;SwtPortalUIDefinition'
would save the UI
definition (passed in through the payload) as the SwtPortalUIDefinition.xml
file in the portal61a\fra\portal\ADMIN\SAMINC
directory (SAMINC is
the current dataset).
NOTE: UI developers who change UI definitions will first need to copy the changed definitions to the appropriate directory structure within the portal configuration area (under the directory where Tomcat is installed). Then, they will need to stop and restart Tomcat. The language directories (e.g. the "eng" directories) must be lower-cased.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.sage.orion.sdata.servlet.JDBCResourceKind |
---|
JDBCResourceKind.HTTPMethodsAuthorizator, JDBCResourceKind.ResourceAuthorizator, JDBCResourceKind.ResourceDataAuthorizator |
Field Summary |
---|
Fields inherited from class com.sage.orion.sdata.servlet.JDBCResourceKind |
---|
ADD, ALTER_TABLE, AND, CLOSE_BRACE, COMMA, CONSTRAINT, DEFAULT, DEFAULT_LANGUAGE_CODE, DELETE_FROM, DROP, DROP_TABLE, FROM, NOT_NULL, OPEN_BRACE, PRIMARY_KEY, SELECT, UICONTENT_SQL_SELECT_STMT, VARCHAR_50, WHERE |
Constructor Summary | |
---|---|
UIDefinitionResourceKind(ApplicationContext context,
ConnectionPool connectionPool,
java.lang.String authToken)
Constructor |
Method Summary | |
---|---|
protected boolean |
canGetOnData(SDataRequest request,
java.sql.Connection connection)
Indicates whether the user has the privilege to GET the data specified in the request. |
protected boolean |
canPutOnData(SDataRequest request,
java.sql.Connection connection)
Indicates whether the user has the privilege to PUT the data specified in the request. |
protected ResourceResponse |
doGet(SDataRequest request,
java.sql.Connection connection)
This method takes appropriate action and generates ResourceResponse based on the specified request |
protected ResourceResponse |
doPut(SDataRequest request,
java.sql.Connection connection)
Handles the PUT request, which is for updating records. |
protected SchemaResponse |
doSchema(SDataRequest request,
java.sql.Connection connection)
Handles the GET request for the special $schema operator. |
protected ResourceResponse |
doTemplate(SDataRequest request,
java.sql.Connection connection)
Handles the GET request for the special $template operator. |
protected java.util.List<FieldDefinition> |
getAllFields()
returns a list of FieldDefinitions in the ResourceKind |
protected java.lang.String |
getCalculateFieldValue(java.lang.String value,
SDataRequest request,
java.sql.ResultSet resultSet,
int fieldIndex)
Get the value of the calculated field, if it is a regular (non-calculated) field then the original value will be returned unchanged |
protected org.w3c.dom.Document |
getFileAsNormalizedDOM(java.io.File inputFilePath,
boolean useLock)
Gets the specified input file's contents as a normalized DOM document, and if specified, locking the file in a shared ("for reading") manner while getting that content. |
java.lang.String |
getName()
|
protected java.lang.String[] |
getPrimaryKey()
Get the primary key of the underlying JDBC table for which one JDBCResourceKindImpl is created |
protected java.lang.String |
getTableName()
Get the JDBC table name for which ResourceKindImpl is created |
boolean |
isUserSpecificResource()
Indicates whether the resource is user specific or not. |
protected org.w3c.dom.Document |
parseFile(java.io.File inputFilePath,
javax.xml.parsers.DocumentBuilder documentBuilder,
boolean useLock)
Uses the specified document builder to parse the specified input file into a "plain" DOM document (with no other transformations such as normalization done), and if specified, locking the file in a shared ("for reading") manner during the parse. |
protected boolean |
supportDelete()
Indicates whether the ResourceKind in general supports DELETE or not. |
protected boolean |
supportGet()
Indicates whether the ResourceKind in general supports GET or not. |
protected boolean |
supportPost()
Indicates whether the ResourceKind in general supports POST or not. |
protected boolean |
supportPut()
Indicates whether the ResourceKind in general supports PUT or not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UIDefinitionResourceKind(ApplicationContext context, ConnectionPool connectionPool, java.lang.String authToken)
context
- SData application contextconnectionPool
- connectionPool of the underline DBauthToken
- the authentication tokenMethod Detail |
---|
protected SchemaResponse doSchema(SDataRequest request, java.sql.Connection connection)
doSchema
in class JDBCResourceKind
request
- The input SDataRequest for the GET of the special $schema
operator.connection
- The JDBC connection object which provides a gateway to access
underlying DB.
protected ResourceResponse doTemplate(SDataRequest request, java.sql.Connection connection) throws java.sql.SQLException
doTemplate
in class JDBCResourceKind
request
- The input SDataRequest for the GET of the special $template
operator.connection
- The JDBC connection object which provides a gateway to access
underlying DB.
java.sql.SQLException
- SQLExceptionprotected ResourceResponse doGet(SDataRequest request, java.sql.Connection connection) throws java.sql.SQLException
doGet
in class JDBCResourceKind
request
- the SDataRequestconnection
- the JDBC connection object which provides a gateway to access
underlying DB
java.sql.SQLException
- SQLExceptionprotected ResourceResponse doPut(SDataRequest request, java.sql.Connection connection) throws java.sql.SQLException
doPut
in class JDBCResourceKind
request
- the request Object having the entry object for the JDBC
ResourceKind Put requestconnection
- the JDBC connection object which provides a gateway to access
underlying DB
java.sql.SQLException
- SQLExceptionprotected org.w3c.dom.Document getFileAsNormalizedDOM(java.io.File inputFilePath, boolean useLock)
Gets the specified input file's contents as a normalized DOM document, and if specified, locking the file in a shared ("for reading") manner while getting that content.
NOTE: This method does not return null - it throws an exception if it encounters a problem.
inputFilePath
- The File object representing the path to input file.useLock
- Whether or not to lock the file (in a shared manner) during the
parse.
protected org.w3c.dom.Document parseFile(java.io.File inputFilePath, javax.xml.parsers.DocumentBuilder documentBuilder, boolean useLock) throws java.io.IOException, org.xml.sax.SAXException
Uses the specified document builder to parse the specified input file into a "plain" DOM document (with no other transformations such as normalization done), and if specified, locking the file in a shared ("for reading") manner during the parse.
NOTE: We block until the lock is obtained.
inputFilePath
- The File object representing the path to the input file.documentBuilder
- The DOM document builder used to parse the input file.useLock
- Whether or not to lock the file (in a shared manner) during the
parse.
java.lang.NullPointerException
- Null arguments were passed in.
java.io.IOException
- A problem happened while trying to access the input file.
org.xml.sax.SAXException
- A problem happened while trying to parse the input file's
content.protected java.lang.String[] getPrimaryKey()
getPrimaryKey
in class JDBCResourceKind
protected java.lang.String getTableName()
getTableName
in class JDBCResourceKind
public java.lang.String getName()
protected java.util.List<FieldDefinition> getAllFields()
getAllFields
in class JDBCResourceKind
protected java.lang.String getCalculateFieldValue(java.lang.String value, SDataRequest request, java.sql.ResultSet resultSet, int fieldIndex)
getCalculateFieldValue
in class JDBCResourceKind
value
- value of the fieldrequest
- the input SDataRequestresultSet
- resultSet returned by queryfieldIndex
- fieldIndex - 0-based
public boolean isUserSpecificResource()
isUserSpecificResource
in class JDBCResourceKind
protected boolean supportDelete()
supportDelete
in class JDBCResourceKind
protected boolean supportGet()
supportGet
in class JDBCResourceKind
protected boolean supportPost()
supportPost
in class JDBCResourceKind
protected boolean supportPut()
supportPut
in class JDBCResourceKind
protected boolean canGetOnData(SDataRequest request, java.sql.Connection connection) throws java.sql.SQLException
canGetOnData
in class JDBCResourceKind
request
- The GET request.connection
- The database connection.
java.sql.SQLException
- SQLExceptionprotected boolean canPutOnData(SDataRequest request, java.sql.Connection connection) throws java.sql.SQLException
canPutOnData
in class JDBCResourceKind
request
- The PUT request.connection
- The database connection.
java.sql.SQLException
- SQLException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |