com.ibm.tivoli.maximo.oslc

Class OslcUtils

  • java.lang.Object
    • com.ibm.tivoli.maximo.oslc.OslcUtils


  • public class OslcUtils
    extends java.lang.Object
    • Constructor Detail

      • OslcUtils

        public OslcUtils()
    • Method Detail

      • generateCSRFToken

        public static java.lang.String generateCSRFToken()
      • generateApiKeyToken

        public static java.lang.String generateApiKeyToken()
      • getLocalizedDateTime

        public static java.lang.String getLocalizedDateTime(int maxType,
                                                            java.util.Date rawData,
                                                            java.util.Locale l)
      • getKPIWhere

        public static java.lang.String getKPIWhere(java.lang.String kpiName,
                                                   UserInfo userInfo)
                                            throws java.rmi.RemoteException,
                                                   MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • setKPIWhere

        public static void setKPIWhere(java.lang.String kpiName,
                                       MboSetRemote msr)
                                throws java.rmi.RemoteException,
                                       MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • setNotIn

        public static void setNotIn(MboSetRemote mboSet,
                                    java.lang.String inClause,
                                    java.lang.String attributeName)
                             throws java.rmi.RemoteException,
                                    MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • setNotIn

        public static void setNotIn(MboSetRemote mboSet,
                                    java.lang.String inClause,
                                    java.lang.String attributeName,
                                    com.ibm.json.java.JSONArray ja)
                             throws java.rmi.RemoteException,
                                    MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • getNotificationHistMessage

        public static com.ibm.json.java.JSONObject getNotificationHistMessage(MboRemote notfMbo)
                                                                       throws java.rmi.RemoteException,
                                                                              MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • setDomainImplicits

        public static void setDomainImplicits(com.ibm.json.java.JSONObject mboOjo,
                                              java.lang.String mboAttrName,
                                              java.lang.String alias,
                                              MboRemote mbo,
                                              OslcRequest request)
                                       throws java.rmi.RemoteException,
                                              MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • getDomainImplicitSchema

        public static DomainInfo getDomainImplicitSchema(MboValueInfo mvi,
                                                         java.lang.String mboAttrName,
                                                         java.lang.String alias)
                                                  throws java.rmi.RemoteException,
                                                         MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • generateCSV

        public static byte[] generateCSV(java.lang.String osName,
                                         MboSetRemote msr,
                                         java.lang.String[] cols,
                                         boolean useAttrTitle,
                                         boolean addAttrNameToTitle)
                                  throws java.rmi.RemoteException,
                                         MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • allowedOptions

        public static void allowedOptions(MboRemote mbo,
                                          com.ibm.json.java.JSONObject jo)
                                   throws java.rmi.RemoteException,
                                          MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • setDomainInternalWhere

        public static void setDomainInternalWhere(MboSetRemote mboset,
                                                  java.lang.String domIntWhere)
                                           throws java.rmi.RemoteException,
                                                  MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • setDomainListWhere

        public static void setDomainListWhere(MboSetRemote mboset,
                                              java.lang.String fd,
                                              java.lang.String orgid,
                                              java.lang.String siteid)
                                       throws java.rmi.RemoteException,
                                              MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • getDomainInfo

        public static DomainInfo getDomainInfo(java.lang.String objectName,
                                               java.lang.String domainName,
                                               java.lang.String siteid,
                                               java.lang.String orgid)
                                        throws java.rmi.RemoteException
        Throws:
        java.rmi.RemoteException
      • handleTimeLineQuery

        public static void handleTimeLineQuery(MboSetRemote msr,
                                               OslcRequest oslcRequest,
                                               java.lang.String osTlAttr)
                                        throws java.rmi.RemoteException,
                                               MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • handleTimeLineQuery

        public static void handleTimeLineQuery(MboSetRemote msr,
                                               java.lang.String tlAttr,
                                               java.lang.String tlRange)
                                        throws java.rmi.RemoteException,
                                               MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • handleTimeLineQuery

        public static void handleTimeLineQuery(MboSetRemote msr,
                                               java.lang.String tlAttr,
                                               java.lang.String tlRange,
                                               boolean tlmodeDate)
                                        throws java.rmi.RemoteException,
                                               MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • startAndEnd

        public static java.util.Date[] startAndEnd(java.util.Date base,
                                                   java.lang.String tlRange)
                                            throws MXException
        Throws:
        MXException
      • getDate

        public static java.util.Date getDate(java.util.Date base,
                                             int val,
                                             java.lang.String unit)
                                      throws MXException
        Throws:
        MXException
      • getPropertiesFromRequest

        public static java.util.Map getPropertiesFromRequest(OslcRequest oslcRequest,
                                                             java.lang.String osName)
                                                      throws MXException,
                                                             java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • getPropertiesFromRequest

        public static java.util.Map getPropertiesFromRequest(OslcRequest oslcRequest,
                                                             java.lang.String osName,
                                                             boolean queryResource,
                                                             boolean ordered)
                                                      throws MXException,
                                                             java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • generateUniqueID

        public static java.lang.String generateUniqueID()
      • getOrgSiteLevel

        public static int getOrgSiteLevel(java.lang.String objectName)
                                   throws MXException,
                                          java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • getLifeSpanForTimedCache

        public static int getLifeSpanForTimedCache()
                                            throws java.rmi.RemoteException
        Throws:
        java.rmi.RemoteException
      • checkAuth

        public static void checkAuth(java.lang.String app,
                                     java.lang.String optionName,
                                     OslcRequest request,
                                     MboRemote mbo)
                              throws java.rmi.RemoteException,
                                     MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • parseSelect

        public static java.util.Map parseSelect(java.lang.String selectExp)
                                         throws MXException
        Throws:
        MXException
      • getIdentifierAsQName

        public static javax.xml.namespace.QName getIdentifierAsQName(java.lang.String identifier,
                                                                     java.util.Map reqPrefixNsMap,
                                                                     java.util.Map prefixNsMap)
      • generateOrderedPropertyMap

        public static void generateOrderedPropertyMap(boolean leanJson,
                                                      java.util.Map propertySet,
                                                      com.ibm.oslc.query.parser.symbols.IOslcProperty oslcProperty,
                                                      java.util.Map reqPrefixNsMap,
                                                      java.util.Map configPrefixNsMap)
      • generateIndexedPropertyMap

        public static void generateIndexedPropertyMap(boolean leanJson,
                                                      java.util.Map propertySet,
                                                      com.ibm.oslc.query.parser.symbols.IOslcProperty oslcProperty,
                                                      java.util.Map reqPrefixNsMap,
                                                      java.util.Map configPrefixNsMap)
      • jsonToBytes

        public static byte[] jsonToBytes(com.ibm.json.java.JSONObject ojo)
                                  throws MXException
        Throws:
        MXException
      • jsonarrayToBytes

        public static byte[] jsonarrayToBytes(com.ibm.json.java.JSONArray ja)
                                       throws MXException
        Throws:
        MXException
      • jsonToBytes

        public static byte[] jsonToBytes(com.ibm.json.java.JSONObject ojo,
                                         boolean pretty)
                                  throws MXException
        Throws:
        MXException
      • jsonarrayToBytes

        public static byte[] jsonarrayToBytes(com.ibm.json.java.JSONArray ja,
                                              boolean pretty)
                                       throws MXException
        Throws:
        MXException
      • bytesToJSONObject

        public static com.ibm.json.java.JSONObject bytesToJSONObject(byte[] data)
                                                              throws MXException
        Throws:
        MXException
      • bytesToOrderedJSONObject

        public static com.ibm.json.java.OrderedJSONObject bytesToOrderedJSONObject(byte[] data)
                                                                            throws MXException
        Throws:
        MXException
      • bytesToJSONArray

        public static com.ibm.json.java.JSONArray bytesToJSONArray(byte[] data)
                                                            throws MXException
        Throws:
        MXException
      • bytesToJSON

        public static com.ibm.json.java.JSONArtifact bytesToJSON(byte[] data)
                                                          throws MXException
        Throws:
        MXException
      • bytesToOrderedJSON

        public static com.ibm.json.java.JSONArtifact bytesToOrderedJSON(byte[] data)
                                                                 throws MXException
        Throws:
        MXException
      • transformURIWithPublicURI

        public static java.lang.String transformURIWithPublicURI(java.lang.String uri)
                                                          throws MXException
        Throws:
        MXException
      • getResourceTypeAsQName

        public static javax.xml.namespace.QName getResourceTypeAsQName(java.lang.String resourceTypeURI)
      • getKeyValueMap

        public static java.util.Map getKeyValueMap(java.util.Map keyMap,
                                                   MboRemote mbo)
                                            throws MXException,
                                                   java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • getLocaleInsensitiveValue

        public static java.lang.String getLocaleInsensitiveValue(MboValueInfo mboValueInfo,
                                                                 MboRemote mbo)
                                                          throws java.rmi.RemoteException,
                                                                 MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • getOslcBaseURI

        public static java.lang.String getOslcBaseURI()
                                               throws java.rmi.RemoteException
        Throws:
        java.rmi.RemoteException
      • generateURITokenFromKeyValueMap

        public static java.lang.String generateURITokenFromKeyValueMap(java.util.Map map)
                                                                throws MXException
        Throws:
        MXException
      • modelToBytes

        public static byte[] modelToBytes(com.hp.hpl.jena.rdf.model.Model rdfModel)
      • bytesToModel

        public static com.hp.hpl.jena.rdf.model.Model bytesToModel(byte[] resourceBytes)
      • generateIdFromMboId

        public static java.lang.String generateIdFromMboId(MboRemote mbo)
                                                    throws java.rmi.RemoteException,
                                                           MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • recoverResourceId

        public static java.lang.String recoverResourceId(java.lang.String encodedId)
                                                  throws MXException
        Throws:
        MXException
      • tokenizeResourceId

        public static java.util.List tokenizeResourceId(java.lang.String recoveredId)
                                                 throws MXException
        Throws:
        MXException
      • encodeResourceId

        public static java.lang.String encodeResourceId(java.lang.String clearTextId)
                                                 throws java.rmi.RemoteException,
                                                        MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • recoverResource

        public static Mbo recoverResource(java.lang.String encodedId,
                                          MboSet mboSet)
                                   throws MXException,
                                          java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • recoverResource

        public static Mbo recoverResource(java.util.Map map,
                                          MboSet mboSet)
                                   throws MXException,
                                          java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • getLinkURIFor

        public static java.lang.String getLinkURIFor(java.lang.String oslcBaseURI,
                                                     java.lang.String osName,
                                                     java.lang.String id)
      • resolveURIExpression

        public static java.lang.String resolveURIExpression(java.lang.String uriExp,
                                                            MboRemote mbo)
                                                     throws java.rmi.RemoteException,
                                                            MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • getMboMboValueInfoForAttribute

        public static MboValueInfo getMboMboValueInfoForAttribute(MboSetRemote mboSet,
                                                                  java.lang.String attributeName,
                                                                  boolean showHidden)
                                                           throws MXException,
                                                                  java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • getMboMboValueInfoForAttribute

        public static MboValueInfo getMboMboValueInfoForAttribute(MboSetRemote mboSet,
                                                                  java.lang.String attributeName)
                                                           throws MXException,
                                                                  java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • getMboMboValueForAttribute

        public static MboValue getMboMboValueForAttribute(MboRemote mbo,
                                                          java.lang.String attributeName)
                                                   throws MXException,
                                                          java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • getQueryPropertyList

        public static java.util.Map getQueryPropertyList(java.lang.String resourceType,
                                                         UserInfo userInfo)
                                                  throws MXException,
                                                         java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • getIdentificationRules

        public static java.util.List getIdentificationRules(java.lang.String resourceType,
                                                            UserInfo userInfo)
                                                     throws MXException,
                                                            java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • getStoredShape

        public static com.hp.hpl.jena.rdf.model.Resource getStoredShape(java.lang.String resourceType,
                                                                        UserInfo userInfo)
                                                                 throws MXException,
                                                                        java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • getRegistryEndpoint

        public static java.lang.String getRegistryEndpoint()
                                                    throws java.rmi.RemoteException
        Throws:
        java.rmi.RemoteException
      • getRegistryQueryBaseURI

        public static java.lang.String getRegistryQueryBaseURI(java.lang.String registryURI,
                                                               byte[] resourceBytes)
      • dateTimeToString

        public static java.lang.String dateTimeToString(java.util.Date d,
                                                        java.util.Locale l,
                                                        java.util.TimeZone tz)
      • timeToString

        public static java.lang.String timeToString(java.util.Date d,
                                                    java.util.Locale l)
      • getLogger

        public static MXLogger getLogger()
        Returns:
        the oslc logger
      • fileVirusScanner

        public static void fileVirusScanner(java.lang.String fileName,
                                            java.io.InputStream in)
                                     throws java.rmi.RemoteException,
                                            MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • encode

        public static java.lang.String encode(java.lang.String token,
                                              boolean pathToken)
                                       throws MXException
        Throws:
        MXException
      • generateESID

        public static java.lang.String generateESID(java.lang.String osName)
      • generateRandomID

        public static java.lang.String generateRandomID()
      • validateAttachmentExt

        public static void validateAttachmentExt(java.lang.String fileName)
                                          throws MXException,
                                                 java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • generateObjQueryFromQbeJSON

        public static java.lang.String generateObjQueryFromQbeJSON(java.lang.String objectName,
                                                                   com.ibm.json.java.JSONObject jo,
                                                                   UserInfo userInfo)
                                                            throws MXException,
                                                                   java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • generateOslcQueryFromQbeJSON

        public static java.lang.String generateOslcQueryFromQbeJSON(java.lang.String osName,
                                                                    com.ibm.json.java.JSONObject jo,
                                                                    UserInfo userInfo)
                                                             throws MXException,
                                                                    java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • toLocalizedFormat

        public static java.lang.String toLocalizedFormat(java.lang.String isoValue,
                                                         MboValueInfo mboValueInfo,
                                                         UserInfo userInfo,
                                                         boolean inClause)
                                                  throws MXException,
                                                         java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • toISOFormat

        public static java.lang.String toISOFormat(java.lang.String localeValue,
                                                   MboValueInfo mboValueInfo,
                                                   UserInfo userInfo,
                                                   boolean inClause)
                                            throws MXException,
                                                   java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • generateLocalizedQueryJSON

        public static void generateLocalizedQueryJSON(java.lang.String osName,
                                                      com.ibm.json.java.JSONObject jo,
                                                      UserInfo userInfo)
                                               throws MXException,
                                                      java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • generateISOQueryJSON

        public static void generateISOQueryJSON(java.lang.String osName,
                                                com.ibm.json.java.JSONObject jo,
                                                UserInfo userInfo)
                                         throws MXException,
                                                java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • addQueryParamToURI

        public static java.lang.String addQueryParamToURI(java.lang.String uri,
                                                          java.lang.String paramName,
                                                          java.lang.String paramValue)
                                                   throws MXException
        Throws:
        MXException
      • createURIFromBase

        public static java.lang.String createURIFromBase(java.util.List path)
                                                  throws MXException
        Throws:
        MXException
      • convertQueryWhereToOslcWhere

        public static java.util.List convertQueryWhereToOslcWhere(java.lang.String queryWhere,
                                                                  UserInfo userInfo,
                                                                  java.lang.String osName,
                                                                  MboSetRemote mboSet)
                                                           throws MXException,
                                                                  java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • convertQueryWhereToObjWhere

        public static java.util.List convertQueryWhereToObjWhere(java.lang.String queryWhere,
                                                                 UserInfo userInfo,
                                                                 java.lang.String objectName,
                                                                 MboSetRemote mboSet)
                                                          throws MXException,
                                                                 java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • getModeOrFromQueryWhere

        public static java.lang.Boolean getModeOrFromQueryWhere(java.lang.String queryWhere)
                                                         throws MXException,
                                                                java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • searchTokens

        public static java.lang.String[] searchTokens(java.lang.String searchString)
      • persistCSRFToken

        public static void persistCSRFToken(UserInfo userInfo,
                                            java.lang.String csrfToken)
      • validateCSRFToken

        public static boolean validateCSRFToken(UserInfo userInfo,
                                                java.lang.String csrfToken)
      • createStatusText

        public static java.lang.String createStatusText(MXException[] warnings,
                                                        OslcRequest request)
      • generateJSONSchema

        public static com.ibm.json.java.JSONObject generateJSONSchema(java.lang.String osName,
                                                                      java.lang.String selectClause,
                                                                      boolean addEnums,
                                                                      java.lang.String queryTemplate,
                                                                      UserInfo userInfo)
                                                               throws java.rmi.RemoteException,
                                                                      MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • generateJSONSchema

        public static com.ibm.json.java.JSONObject generateJSONSchema(java.lang.String osName,
                                                                      java.lang.String selectClause,
                                                                      boolean addEnums,
                                                                      java.lang.String queryTemplate,
                                                                      UserInfo userInfo,
                                                                      boolean strict)
                                                               throws java.rmi.RemoteException,
                                                                      MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • serializeResourceAsObject

        public static byte[] serializeResourceAsObject(java.lang.Object obj,
                                                       java.lang.String osName,
                                                       java.lang.String templateName,
                                                       boolean retainMbos)
                                                throws java.rmi.RemoteException,
                                                       MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • serializeResourceAsObjectWithSelect

        public static com.ibm.json.java.JSONObject serializeResourceAsObjectWithSelect(MboRemote mbo,
                                                                                       java.lang.String osName,
                                                                                       java.lang.String selectClause,
                                                                                       boolean retainMbos)
                                                                                throws java.rmi.RemoteException,
                                                                                       MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • serializeResourceAsObject

        public static byte[] serializeResourceAsObject(java.lang.Object obj,
                                                       java.lang.String osName,
                                                       java.lang.String templateName)
                                                throws java.rmi.RemoteException,
                                                       MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • getYNCOptionValue

        public static java.lang.Integer getYNCOptionValue(java.lang.String optionChosen)
      • getContentTypeFrom

        public static java.lang.String getContentTypeFrom(java.lang.String fileName)
                                                   throws java.rmi.RemoteException,
                                                          MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • setCORSHeaders

        public static void setCORSHeaders(javax.servlet.http.HttpServletRequest request,
                                          javax.servlet.http.HttpServletResponse response)
      • addRelationJSONSchema

        public static void addRelationJSONSchema(com.ibm.json.java.JSONArray ja,
                                                 java.lang.String objectName)
                                          throws java.rmi.RemoteException,
                                                 MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • getCOSAttachmentBucketName

        public static java.lang.String getCOSAttachmentBucketName()
      • getDomainId

        public static java.lang.String getDomainId(MboRemote mbo,
                                                   java.lang.String attrName)
                                            throws java.rmi.RemoteException,
                                                   MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • getAttachmentStore

        public static java.lang.String getAttachmentStore()
      • getApiModules

        public static java.util.Map getApiModules()
      • createThumbNail

        public static byte[] createThumbNail(java.io.InputStream origImage,
                                             java.lang.String ext,
                                             int scaleWidth,
                                             int scaleHeight,
                                             int scaleSize)
      • checkForEsig

        public static void checkForEsig(java.lang.String optionName,
                                        MboRemote mbo,
                                        OslcRequest oslcRequest)
                                 throws MXException,
                                        java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • isEsigVerified

        public static boolean isEsigVerified()
      • setEsigVerified

        public static void setEsigVerified()
      • setupAllowedExtensionsForAttachments

        public static void setupAllowedExtensionsForAttachments()
      • canStream

        public static boolean canStream(java.util.Map resourceProperties)
      • validateOrgAndSite

        public static void validateOrgAndSite(java.lang.String osName,
                                              MboSetRemote mboSet,
                                              com.ibm.json.java.JSONObject ja,
                                              java.lang.String messageType)
                                       throws java.rmi.RemoteException,
                                              MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • restGET

        public static byte[] restGET(UserInfo processUserInfo,
                                     java.lang.String osName,
                                     java.util.Map headers,
                                     java.util.Map queryParams,
                                     boolean schema)
                              throws MXException,
                                     java.io.IOException
        Throws:
        MXException
        java.io.IOException
      • handleRoute

        public static OslcResourceResponse handleRoute(RouteInfo routeInfo,
                                                       java.lang.String routeClazzName,
                                                       java.lang.String provider,
                                                       java.lang.String resourceReq,
                                                       java.util.List resPath,
                                                       byte[] resourceBytes,
                                                       OslcRequest oslcRequest,
                                                       MXCorrelator correlator,
                                                       javax.servlet.http.HttpServletRequest request)
                                                throws MXException,
                                                       java.io.IOException
        Throws:
        MXException
        java.io.IOException
      • xorEncode

        public static java.lang.String xorEncode(java.lang.String s,
                                                 java.lang.String key)
      • xorDecode

        public static java.lang.String xorDecode(java.lang.String s,
                                                 java.lang.String key)