idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
14,400 | public < E > E load ( Class < E > entityClass , DatastoreKey parentKey , long id ) { EntityMetadata entityMetadata = EntityIntrospector . introspect ( entityClass ) ; Key nativeKey ; if ( parentKey == null ) { nativeKey = entityManager . newNativeKeyFactory ( ) . setKind ( entityMetadata . getKind ( ) ) . newKey ( id )... | Loads and returns the entity with the given ID . The entity kind is determined from the supplied class . |
14,401 | public < E > E load ( Class < E > entityClass , DatastoreKey key ) { return fetch ( entityClass , key . nativeKey ( ) ) ; } | Retrieves and returns the entity with the given key . |
14,402 | public < E > List < E > loadByKey ( Class < E > entityClass , List < DatastoreKey > keys ) { Key [ ] nativeKeys = DatastoreUtils . toNativeKeys ( keys ) ; return fetch ( entityClass , nativeKeys ) ; } | Retrieves and returns the entities for the given keys . |
14,403 | private < E > E fetch ( Class < E > entityClass , Key nativeKey ) { try { Entity nativeEntity = nativeReader . get ( nativeKey ) ; E entity = Unmarshaller . unmarshal ( nativeEntity , entityClass ) ; entityManager . executeEntityListeners ( CallbackType . POST_LOAD , entity ) ; return entity ; } catch ( DatastoreExcept... | Fetches the entity given the native key . |
14,404 | private < E > List < E > fetch ( Class < E > entityClass , Key [ ] nativeKeys ) { try { List < Entity > nativeEntities = nativeReader . fetch ( nativeKeys ) ; List < E > entities = DatastoreUtils . toEntities ( entityClass , nativeEntities ) ; entityManager . executeEntityListeners ( CallbackType . POST_LOAD , entities... | Fetches a list of entities for the given native keys . |
14,405 | private Key [ ] longListToNativeKeys ( Class < ? > entityClass , List < Long > identifiers ) { if ( identifiers == null || identifiers . isEmpty ( ) ) { return new Key [ 0 ] ; } EntityMetadata entityMetadata = EntityIntrospector . introspect ( entityClass ) ; Key [ ] nativeKeys = new Key [ identifiers . size ( ) ] ; Ke... | Converts the given list of identifiers into an array of native Key objects . |
14,406 | private IncompleteKey getIncompleteKey ( Object entity ) { EntityMetadata entityMetadata = EntityIntrospector . introspect ( entity . getClass ( ) ) ; String kind = entityMetadata . getKind ( ) ; ParentKeyMetadata parentKeyMetadata = entityMetadata . getParentKeyMetadata ( ) ; DatastoreKey parentKey = null ; Incomplete... | Returns an IncompleteKey of the given entity . |
14,407 | public void executeEntityListeners ( CallbackType callbackType , Object entity ) { if ( entity == null ) { return ; } EntityListenersMetadata entityListenersMetadata = EntityIntrospector . getEntityListenersMetadata ( entity ) ; List < CallbackMetadata > callbacks = entityListenersMetadata . getCallbacks ( callbackType... | Executes the entity listeners associated with the given entity . |
14,408 | public void executeEntityListeners ( CallbackType callbackType , List < ? > entities ) { for ( Object entity : entities ) { executeEntityListeners ( callbackType , entity ) ; } } | Executes the entity listeners associated with the given list of entities . |
14,409 | private void executeGlobalListeners ( CallbackType callbackType , Object entity ) { if ( globalCallbacks == null ) { return ; } List < CallbackMetadata > callbacks = globalCallbacks . get ( callbackType ) ; if ( callbacks == null ) { return ; } for ( CallbackMetadata callback : callbacks ) { Object listener = ListenerF... | Executes the global listeners for the given event type for the given entity . |
14,410 | private static void invokeCallbackMethod ( Method callbackMethod , Object listener , Object entity ) { try { callbackMethod . invoke ( listener , entity ) ; } catch ( Exception exp ) { String message = String . format ( "Failed to execute callback method %s of class %s" , callbackMethod . getName ( ) , callbackMethod .... | Invokes the given callback method on the given target object . |
14,411 | @ SuppressWarnings ( "unchecked" ) private < T extends Indexer > T createIndexer ( Class < T > indexerClass ) { synchronized ( indexerClass ) { Indexer indexer = cache . get ( indexerClass ) ; if ( indexer == null ) { indexer = ( Indexer ) IntrospectionUtils . instantiateObject ( indexerClass ) ; cache . put ( indexerC... | Creates the Indexer of the given class . |
14,412 | private Indexer getDefaultIndexer ( Field field ) { Type type = field . getGenericType ( ) ; if ( type instanceof Class && type . equals ( String . class ) ) { return getIndexer ( LowerCaseStringIndexer . class ) ; } else if ( type instanceof ParameterizedType ) { ParameterizedType parameterizedType = ( ParameterizedTy... | Returns the default indexer for the given field . |
14,413 | private void copyRequestHeaders ( HttpServletRequest servletRequest , HttpRequest proxyRequest ) throws URISyntaxException { Enumeration < ? > enumerationOfHeaderNames = servletRequest . getHeaderNames ( ) ; while ( enumerationOfHeaderNames . hasMoreElements ( ) ) { String headerName = ( String ) enumerationOfHeaderNam... | Copy request headers from the servlet client to the proxy request . |
14,414 | private void copyResponseHeaders ( HttpResponse proxyResponse , final HttpServletResponse servletResponse ) { servletResponse . setCharacterEncoding ( getContentCharSet ( proxyResponse . getEntity ( ) ) ) ; from ( Arrays . asList ( proxyResponse . getAllHeaders ( ) ) ) . filter ( new Predicate < Header > ( ) { public b... | Copy proxied response headers back to the servlet client . |
14,415 | private String getContentCharSet ( final HttpEntity entity ) throws ParseException { if ( entity == null ) { return null ; } String charset = null ; if ( entity . getContentType ( ) != null ) { HeaderElement values [ ] = entity . getContentType ( ) . getElements ( ) ; if ( values . length > 0 ) { NameValuePair param = ... | Get the charset used to encode the http entity . |
14,416 | @ SuppressWarnings ( "unchecked" ) public T getDefaultObject ( ) { if ( defaultValue instanceof IModel ) { return ( ( IModel < T > ) defaultValue ) . getObject ( ) ; } else { return ( T ) defaultValue ; } } | Returns default value |
14,417 | public JsonResponse getEmail ( String email ) throws IOException { Email emailObj = new Email ( ) ; emailObj . setEmail ( email ) ; return apiGet ( emailObj ) ; } | Get information about one of your users . |
14,418 | public JsonResponse getSend ( String sendId ) throws IOException { Map < String , Object > data = new HashMap < String , Object > ( ) ; data . put ( Send . PARAM_SEND_ID , sendId ) ; return apiGet ( ApiAction . send , data ) ; } | Get the status of a transational send |
14,419 | public JsonResponse cancelSend ( String sendId ) throws IOException { Map < String , Object > data = new HashMap < String , Object > ( ) ; data . put ( Send . PARAM_SEND_ID , sendId ) ; return apiDelete ( ApiAction . send , data ) ; } | Cancel a send that was scheduled for a future time . |
14,420 | public JsonResponse getBlast ( Integer blastId ) throws IOException { Blast blast = new Blast ( ) ; blast . setBlastId ( blastId ) ; return apiGet ( blast ) ; } | get information about a blast |
14,421 | public JsonResponse scheduleBlastFromTemplate ( String template , String list , Date scheduleTime , Blast blast ) throws IOException { blast . setCopyTemplate ( template ) ; blast . setList ( list ) ; blast . setScheduleTime ( scheduleTime ) ; return apiPost ( blast ) ; } | Schedule a mass mail from a template |
14,422 | public JsonResponse scheduleBlastFromBlast ( Integer blastId , Date scheduleTime , Blast blast ) throws IOException { blast . setCopyBlast ( blastId ) ; blast . setScheduleTime ( scheduleTime ) ; return apiPost ( blast ) ; } | Schedule a mass mail blast from previous blast |
14,423 | public JsonResponse updateBlast ( Integer blastId ) throws IOException { Blast blast = new Blast ( ) ; blast . setBlastId ( blastId ) ; return apiPost ( blast ) ; } | Update existing blast |
14,424 | public JsonResponse deleteBlast ( Integer blastId ) throws IOException { Blast blast = new Blast ( ) ; blast . setBlastId ( blastId ) ; return apiDelete ( blast ) ; } | Delete existing blast |
14,425 | public JsonResponse cancelBlast ( Integer blastId ) throws IOException { Blast blast = new Blast ( ) ; Date d = null ; blast . setBlastId ( blastId ) . setScheduleTime ( d ) ; return apiPost ( blast ) ; } | Cancel a scheduled Blast |
14,426 | public JsonResponse getTemplate ( String template ) throws IOException { Map < String , Object > data = new HashMap < String , Object > ( ) ; data . put ( Template . PARAM_TEMPLATE , template ) ; return apiGet ( ApiAction . template , data ) ; } | Get template information |
14,427 | public JsonResponse deleteTemplate ( String template ) throws IOException { Map < String , Object > data = new HashMap < String , Object > ( ) ; data . put ( Template . PARAM_TEMPLATE , template ) ; return apiDelete ( ApiAction . template , data ) ; } | Delete existing template |
14,428 | public JsonResponse getAlert ( String email ) throws IOException { Map < String , Object > data = new HashMap < String , Object > ( ) ; data . put ( Alert . PARAM_EMAIL , email ) ; return apiGet ( ApiAction . alert , data ) ; } | Retrieve a user s alert settings |
14,429 | public JsonResponse deleteAlert ( String email , String alertId ) throws IOException { Map < String , Object > data = new HashMap < String , Object > ( ) ; data . put ( Alert . PARAM_EMAIL , email ) ; data . put ( Alert . PARAM_ALERT_ID , alertId ) ; return apiDelete ( ApiAction . alert , data ) ; } | Delete existing user alert |
14,430 | public Map < String , Object > listStats ( ListStat stat ) throws IOException { return ( Map < String , Object > ) this . stats ( stat ) ; } | get list stats information |
14,431 | public Map < String , Object > blastStats ( BlastStat stat ) throws IOException { return ( Map < String , Object > ) this . stats ( stat ) ; } | get blast stats information |
14,432 | public JsonResponse getJobStatus ( String jobId ) throws IOException { Map < String , Object > params = new HashMap < String , Object > ( ) ; params . put ( Job . JOB_ID , jobId ) ; return apiGet ( ApiAction . job , params ) ; } | Get status of a job |
14,433 | public OSchemaHelper linkedClass ( String className ) { checkOProperty ( ) ; OClass linkedToClass = schema . getClass ( className ) ; if ( linkedToClass == null ) throw new IllegalArgumentException ( "Target OClass '" + className + "' to link to not found" ) ; if ( ! Objects . equal ( linkedToClass , lastProperty . get... | Set linked class to a current property |
14,434 | public OSchemaHelper linkedType ( OType linkedType ) { checkOProperty ( ) ; if ( ! Objects . equal ( linkedType , lastProperty . getLinkedType ( ) ) ) { lastProperty . setLinkedType ( linkedType ) ; } return this ; } | Set linked type to a current property |
14,435 | public OSchemaHelper field ( String field , Object value ) { checkODocument ( ) ; lastDocument . field ( field , value ) ; return this ; } | Sets a field value for a current document |
14,436 | public static < R > R sudo ( Function < ODatabaseDocument , R > func ) { return new DBClosure < R > ( ) { protected R execute ( ODatabaseDocument db ) { return func . apply ( db ) ; } } . execute ( ) ; } | Simplified function to execute under admin |
14,437 | public static void sudoConsumer ( Consumer < ODatabaseDocument > consumer ) { new DBClosure < Void > ( ) { protected Void execute ( ODatabaseDocument db ) { consumer . accept ( db ) ; return null ; } } . execute ( ) ; } | Simplified consumer to execute under admin |
14,438 | public static void sudoSave ( final ODocument ... docs ) { if ( docs == null || docs . length == 0 ) return ; new DBClosure < Boolean > ( ) { protected Boolean execute ( ODatabaseDocument db ) { db . begin ( ) ; for ( ODocument doc : docs ) { db . save ( doc ) ; } db . commit ( ) ; return true ; } } . execute ( ) ; } | Allow to save set of document under admin |
14,439 | public static void sudoSave ( final ODocumentWrapper ... dws ) { if ( dws == null || dws . length == 0 ) return ; new DBClosure < Boolean > ( ) { protected Boolean execute ( ODatabaseDocument db ) { db . begin ( ) ; for ( ODocumentWrapper dw : dws ) { dw . save ( ) ; } db . commit ( ) ; return true ; } } . execute ( ) ... | Allow to save set of document wrappers under admin |
14,440 | public static String buitify ( String string ) { char [ ] chars = string . toCharArray ( ) ; StringBuilder sb = new StringBuilder ( ) ; int lastApplied = 0 ; for ( int i = 0 ; i < chars . length ; i ++ ) { char pCh = i > 0 ? chars [ i - 1 ] : 0 ; char ch = chars [ i ] ; if ( ch == '_' || ch == '-' || Character . isWhit... | Utility method to make source string more human readable |
14,441 | protected Object getDefaultValue ( String propName , Class < ? > returnType ) { Object ret = null ; if ( returnType . isPrimitive ( ) ) { if ( returnType . equals ( boolean . class ) ) { return false ; } else if ( returnType . equals ( char . class ) ) { return '\0' ; } else { try { Class < ? > wrapperClass = Primitive... | Method for obtaining default value of required property |
14,442 | public static boolean isAllowed ( ORule . ResourceGeneric resource , String specific , OrientPermission ... permissions ) { return OrientDbWebSession . get ( ) . getEffectiveUser ( ) . checkIfAllowed ( resource , specific , OrientPermission . combinedPermission ( permissions ) ) != null ; } | Check that all required permissions present for specified resource and specific |
14,443 | public static String getResourceSpecific ( String name ) { ORule . ResourceGeneric generic = getResourceGeneric ( name ) ; String specific = generic != null ? Strings . afterFirst ( name , '.' ) : name ; return Strings . isEmpty ( specific ) ? null : specific ; } | Extract specific from resource string |
14,444 | public String resolveOrientDBRestApiUrl ( ) { OrientDbWebApplication app = OrientDbWebApplication . get ( ) ; OServer server = app . getServer ( ) ; if ( server != null ) { OServerNetworkListener http = server . getListenerByProtocol ( ONetworkProtocolHttpAbstract . class ) ; if ( http != null ) { return "http://" + ht... | Resolve OrientDB REST API URL to be used for OrientDb REST bridge |
14,445 | public boolean isInProgress ( RequestCycle cycle ) { Boolean inProgress = cycle . getMetaData ( IN_PROGRESS_KEY ) ; return inProgress != null ? inProgress : false ; } | Is current transaction in progress? |
14,446 | public OClass probeOClass ( int probeLimit ) { Iterator < ODocument > it = iterator ( 0 , probeLimit , null ) ; return OSchemaUtils . probeOClass ( it , probeLimit ) ; } | Probe the dataset and returns upper OClass for sample |
14,447 | public long size ( ) { if ( size == null ) { ODatabaseDocument db = OrientDbWebSession . get ( ) . getDatabase ( ) ; OSQLSynchQuery < ODocument > query = new OSQLSynchQuery < ODocument > ( queryManager . getCountSql ( ) ) ; List < ODocument > ret = db . query ( enhanceContextByVariables ( query ) , prepareParams ( ) ) ... | Get the size of the data |
14,448 | public OQueryModel < K > setSort ( String sortableParameter , SortOrder order ) { setSortableParameter ( sortableParameter ) ; setAscending ( SortOrder . ASCENDING . equals ( order ) ) ; return this ; } | Set sorting configration |
14,449 | public static String md5 ( String data ) { try { return DigestUtils . md5Hex ( data . toString ( ) . getBytes ( "UTF-8" ) ) ; } catch ( UnsupportedEncodingException e ) { return DigestUtils . md5Hex ( data . toString ( ) ) ; } } | generates MD5 Hash |
14,450 | public static String arrayListToCSV ( List < String > list ) { StringBuilder csv = new StringBuilder ( ) ; for ( String str : list ) { csv . append ( str ) ; csv . append ( "," ) ; } int lastIndex = csv . length ( ) - 1 ; char last = csv . charAt ( lastIndex ) ; if ( last == ',' ) { return csv . substring ( 0 , lastInd... | Converts String ArrayList to CSV string |
14,451 | protected Scheme getScheme ( ) { String scheme ; try { URI uri = new URI ( this . apiUrl ) ; scheme = uri . getScheme ( ) ; } catch ( URISyntaxException e ) { scheme = "http" ; } if ( scheme . equals ( "https" ) ) { return new Scheme ( scheme , DEFAULT_HTTPS_PORT , SSLSocketFactory . getSocketFactory ( ) ) ; } else { r... | Get Scheme Object |
14,452 | protected Object httpRequest ( ApiAction action , HttpRequestMethod method , Map < String , Object > data ) throws IOException { String url = this . apiUrl + "/" + action . toString ( ) . toLowerCase ( ) ; Type type = new TypeToken < Map < String , Object > > ( ) { } . getType ( ) ; String json = GSON . toJson ( data ,... | Make Http request to Sailthru API for given resource with given method and data |
14,453 | protected Object httpRequest ( HttpRequestMethod method , ApiParams apiParams ) throws IOException { ApiAction action = apiParams . getApiCall ( ) ; String url = apiUrl + "/" + action . toString ( ) . toLowerCase ( ) ; String json = GSON . toJson ( apiParams , apiParams . getType ( ) ) ; Map < String , String > params ... | Make HTTP Request to Sailthru API but with Api Params rather than generalized Map this is recommended way to make request if data structure is complex |
14,454 | private Map < String , String > buildPayload ( String jsonPayload ) { Map < String , String > params = new HashMap < String , String > ( ) ; params . put ( "api_key" , apiKey ) ; params . put ( "format" , handler . getSailthruResponseHandler ( ) . getFormat ( ) ) ; params . put ( "json" , jsonPayload ) ; params . put (... | Build HTTP Request Payload |
14,455 | protected String getSignatureHash ( Map < String , String > parameters ) { List < String > values = new ArrayList < String > ( ) ; StringBuilder data = new StringBuilder ( ) ; data . append ( this . apiSecret ) ; for ( Entry < String , String > entry : parameters . entrySet ( ) ) { values . add ( entry . getValue ( ) )... | Get Signature Hash from given Map |
14,456 | public JsonResponse apiGet ( ApiAction action , Map < String , Object > data ) throws IOException { return httpRequestJson ( action , HttpRequestMethod . GET , data ) ; } | HTTP GET Request with Map |
14,457 | public JsonResponse apiPost ( ApiAction action , Map < String , Object > data ) throws IOException { return httpRequestJson ( action , HttpRequestMethod . POST , data ) ; } | HTTP POST Request with Map |
14,458 | public JsonResponse apiPost ( ApiParams data , ApiFileParams fileParams ) throws IOException { return httpRequestJson ( HttpRequestMethod . POST , data , fileParams ) ; } | HTTP POST Request with Interface implementation of ApiParams and ApiFileParams |
14,459 | public JsonResponse apiDelete ( ApiAction action , Map < String , Object > data ) throws IOException { return httpRequestJson ( action , HttpRequestMethod . DELETE , data ) ; } | HTTP DELETE Request |
14,460 | static public int obtainNextIncrementInteger ( Connection connection , ColumnData autoIncrementIntegerColumn ) throws Exception { try { String sqlQuery = "SELECT nextval(?);" ; PreparedStatement pstmt = null ; { pstmt = connection . prepareStatement ( sqlQuery ) ; pstmt . setString ( 1 , autoIncrementIntegerColumn . ge... | Performs a database query to find the next integer in the sequence reserved for the given column . |
14,461 | static String unescapeEntity ( String e ) { if ( e == null || e . isEmpty ( ) ) { return "" ; } if ( e . charAt ( 0 ) == '#' ) { int cp ; if ( e . charAt ( 1 ) == 'x' ) { cp = Integer . parseInt ( e . substring ( 2 ) , 16 ) ; } else { cp = Integer . parseInt ( e . substring ( 1 ) ) ; } return new String ( new int [ ] {... | Unescapes an XML entity encoding ; |
14,462 | private String convertLastSeqObj ( Object lastSeqObj ) throws Exception { if ( null == lastSeqObj ) { return null ; } else if ( lastSeqObj instanceof String ) { return ( String ) lastSeqObj ; } else if ( lastSeqObj instanceof Number ) { return "" + lastSeqObj ; } else { throw new Exception ( "Do not know how to handle ... | Converts the object last_seq found in the change feed to a String . In CouchDB 1 . x last_seq is an integer . In CouchDB 2 . x last_seq is a string . |
14,463 | public void renameAttachmentTo ( String newAttachmentName ) throws Exception { JSONObject doc = documentDescriptor . getJson ( ) ; JSONObject _attachments = doc . optJSONObject ( "_attachments" ) ; JSONObject nunaliit_attachments = doc . getJSONObject ( UploadConstants . KEY_DOC_ATTACHMENTS ) ; JSONObject files = nunal... | Renames an attachment . This ensures that there is no collision and that all references to this attachment are updated properly within this document . |
14,464 | static public FSEntry getPositionedFile ( String path , File file ) throws Exception { List < String > pathFrags = FSEntrySupport . interpretPath ( path ) ; int index = pathFrags . size ( ) - 1 ; FSEntry root = new FSEntryFile ( pathFrags . get ( index ) , file ) ; -- index ; while ( index >= 0 ) { FSEntryVirtualDirect... | Create a virtual tree hierarchy with a file supporting the leaf . |
14,465 | private String computeSelectScore ( List < String > searchFields ) throws Exception { StringWriter sw = new StringWriter ( ) ; PrintWriter pw = new PrintWriter ( sw ) ; if ( 0 == searchFields . size ( ) ) { throw new Exception ( "Must supply at least one search field" ) ; } else if ( 1 == searchFields . size ( ) ) { pw... | Create a SQL fragment that can be used to compute a score based on a search . |
14,466 | private String computeWhereFragment ( List < String > searchFields ) throws Exception { StringWriter sw = new StringWriter ( ) ; PrintWriter pw = new PrintWriter ( sw ) ; boolean first = true ; for ( int loop = 0 ; loop < searchFields . size ( ) ; ++ loop ) { if ( first ) { first = false ; pw . print ( " WHERE " ) ; } ... | Given a number of search fields compute the SQL fragment used to filter the searched rows |
14,467 | private JSONArray executeStatementToJson ( PreparedStatement stmt , List < SelectedColumn > selectFields ) throws Exception { if ( stmt . execute ( ) ) { ResultSet rs = stmt . getResultSet ( ) ; JSONArray array = new JSONArray ( ) ; try { Map < Integer , JSONObject > contributorMap = new HashMap < Integer , JSONObject ... | This method executes a prepared SQL statement and returns a JSON array that contains the result . |
14,468 | public JSONObject getAudioMediaFromPlaceId ( String place_id ) throws Exception { List < SelectedColumn > selectFields = new Vector < SelectedColumn > ( ) ; selectFields . add ( new SelectedColumn ( SelectedColumn . Type . INTEGER , "id" ) ) ; selectFields . add ( new SelectedColumn ( SelectedColumn . Type . INTEGER , ... | Finds and returns all audio media associated with a place id . |
14,469 | static public boolean hasDocumentBeenModified ( JSONObject targetDoc ) { JSONObject targetManifest = targetDoc . optJSONObject ( MANIFEST_KEY ) ; if ( null == targetManifest ) { return true ; } String targetDigest = targetManifest . optString ( "digest" ) ; if ( null == targetDigest ) { return true ; } DigestComputer d... | Analyzes a document and determines if the document has been modified since the time the manifest was computed . |
14,470 | static public Integer getAttachmentPosition ( JSONObject targetDoc , String attachmentName ) { JSONObject targetAttachments = targetDoc . optJSONObject ( "_attachments" ) ; if ( null == targetAttachments ) { return null ; } JSONObject targetAttachment = targetAttachments . optJSONObject ( attachmentName ) ; if ( null =... | Given a JSON document and an attachment name returns the revision position associated with the attachment . |
14,471 | public static void setCompressionType ( ImageWriteParam param , BufferedImage image ) { if ( image . getType ( ) == BufferedImage . TYPE_BYTE_BINARY && image . getColorModel ( ) . getPixelSize ( ) == 1 ) { param . setCompressionType ( "CCITT T.6" ) ; } else { param . setCompressionType ( "LZW" ) ; } } | Sets the ImageIO parameter compression type based on the given image . |
14,472 | static public FSEntry getPositionedResource ( String path , ClassLoader classLoader , String resourceName ) throws Exception { List < String > pathFrags = FSEntrySupport . interpretPath ( path ) ; int index = pathFrags . size ( ) - 1 ; FSEntry root = create ( pathFrags . get ( index ) , classLoader , resourceName ) ; -... | Create a virtual tree hierarchy with a resource supporting the leaf . |
14,473 | static public FSEntryResource create ( ClassLoader classLoader , String resourceName ) throws Exception { return create ( null , classLoader , resourceName ) ; } | Creates an instance of FSEntryResource to represent an entry based on the resource specified by the classLoader and resource name . |
14,474 | static public FSEntryResource create ( String name , ClassLoader classLoader , String resourceName ) throws Exception { URL url = classLoader . getResource ( resourceName ) ; if ( "jar" . equals ( url . getProtocol ( ) ) ) { String path = url . getPath ( ) ; if ( path . startsWith ( "file:" ) ) { int bangIndex = path .... | Creates an instance of FSEntryResource to represent an entry based on the resource specified by the classLoader and resource name . This resource can be a file or a directory . Furthermore this resource can be located on file system or inside a JAR file . |
14,475 | private void performAdjustCookies ( HttpServletRequest request , HttpServletResponse response ) throws Exception { boolean loggedIn = false ; User user = null ; try { Cookie cookie = getCookieFromRequest ( request ) ; if ( null != cookie ) { user = CookieAuthentication . verifyCookieString ( userRepository , cookie . g... | Adjusts the information cookie based on the authentication token |
14,476 | static public TreeRebalanceProcess . Result createTree ( List < ? extends TreeElement > elements ) throws Exception { Result results = new Result ( ) ; TimeInterval fullRegularInterval = null ; TimeInterval fullOngoingInterval = null ; results . nextClusterId = 1 ; Map < Integer , TreeNodeRegular > legacyRegularNodes =... | Creates a new cluster tree given the provided elements . If these elements were already part of a cluster then legacy cluster nodes are created to account for those elements . This is the perfect process in case the previous tree was lost . |
14,477 | synchronized public Connection getDb ( String db ) throws Exception { Connection con = null ; if ( nameToConnection . containsKey ( db ) ) { con = nameToConnection . get ( db ) ; } else { ConnectionInfo info = nameToInfo . get ( db ) ; if ( null == info ) { throw new Exception ( "No information provided for database na... | This method checks for the presence of a Connection associated with the input db parameter . It attempts to create the Connection and adds it to the connection map if it does not already exist . If the Connection exists or is created it is returned . |
14,478 | static public void captureReponseErrors ( Object response , String errorMessage ) throws Exception { if ( null == response ) { throw new Exception ( "Capturing errors from null response" ) ; } if ( false == ( response instanceof JSONObject ) ) { return ; } JSONObject obj = ( JSONObject ) response ; if ( JSONSupport . c... | Analyze a CouchDb response and raises an exception if an error was returned in the response . |
14,479 | static public File computeAtlasDir ( String name ) { File atlasDir = null ; if ( null == name ) { atlasDir = new File ( "." ) ; } else { atlasDir = new File ( name ) ; } if ( false == atlasDir . isAbsolute ( ) ) { atlasDir = atlasDir . getAbsoluteFile ( ) ; } return atlasDir ; } | Computes the directory where the atlas resides given a command - line argument provided by the user . If the argument is not given then this method should be called with a null argument . |
14,480 | static public File computeInstallDir ( ) { File installDir = null ; File knownResourceFile = null ; { URL url = Main . class . getClassLoader ( ) . getResource ( "commandResourceDummy.txt" ) ; if ( null == url ) { } else if ( "jar" . equals ( url . getProtocol ( ) ) ) { String path = url . getPath ( ) ; if ( path . sta... | Computes the installation directory for the command line tool . This is done by looking for a known resource in a JAR file that ships with the command - line tool . When the resource is found the location of the associated JAR file is derived . From there the root directory of the installation is deduced . If the comma... |
14,481 | static public File computeContentDir ( File installDir ) { if ( null != installDir ) { File contentDir = new File ( installDir , "content" ) ; if ( contentDir . exists ( ) && contentDir . isDirectory ( ) ) { return contentDir ; } File nunaliit2Dir = computeNunaliitDir ( installDir ) ; contentDir = new File ( nunaliit2D... | Finds the content directory from the installation location and returns it . If the command - line tool is packaged and deployed then the content directory is found at the root of the installation . If the command - line tool is run from the development environment then the content directory is found in the SDK sub - pr... |
14,482 | static public File computeBinDir ( File installDir ) { if ( null != installDir ) { File binDir = new File ( installDir , "bin" ) ; if ( binDir . exists ( ) && binDir . isDirectory ( ) ) { return binDir ; } File nunaliit2Dir = computeNunaliitDir ( installDir ) ; binDir = new File ( nunaliit2Dir , "nunaliit2-couch-sdk/ta... | Finds the bin directory from the installation location and returns it . If the command - line tool is packaged and deployed then the bin directory is found at the root of the installation . If the command - line tool is run from the development environment then the bin directory is found in the SDK sub - project . |
14,483 | static public File computeSiteDesignDir ( File installDir ) { if ( null != installDir ) { File templatesDir = new File ( installDir , "internal/siteDesign" ) ; if ( templatesDir . exists ( ) && templatesDir . isDirectory ( ) ) { return templatesDir ; } File nunaliit2Dir = computeNunaliitDir ( installDir ) ; templatesDi... | Finds the siteDesign directory from the installation location and returns it . If the command - line tool is packaged and deployed then the siteDesign directory is found at the root of the installation . If the command - line tool is run from the development environment then the siteDesign directory is found in the SDK... |
14,484 | static public File computeNunaliitDir ( File installDir ) { while ( null != installDir ) { boolean commandExists = ( new File ( installDir , "nunaliit2-couch-command" ) ) . exists ( ) ; boolean sdkExists = ( new File ( installDir , "nunaliit2-couch-sdk" ) ) . exists ( ) ; boolean jsExists = ( new File ( installDir , "n... | Given an installation directory find the root directory for the nunaliit2 project . This makes sense only in the context that the command - line tool is run from a development environment . |
14,485 | static public Set < String > getDescendantPathNames ( File dir , boolean includeDirectories ) { Set < String > paths = new HashSet < String > ( ) ; if ( dir . exists ( ) && dir . isDirectory ( ) ) { String [ ] names = dir . list ( ) ; for ( String name : names ) { File child = new File ( dir , name ) ; getPathNames ( c... | Given a directory returns a set of strings which are the paths to all elements within the directory . This process recurses through all sub - directories . |
14,486 | static public void emptyDirectory ( File dir ) throws Exception { String [ ] fileNames = dir . list ( ) ; if ( null != fileNames ) { for ( String fileName : fileNames ) { File file = new File ( dir , fileName ) ; if ( file . isDirectory ( ) ) { emptyDirectory ( file ) ; } boolean deleted = false ; try { deleted = file ... | Given a directory removes all the content found in the directory . |
14,487 | static public MailVetterDailyNotificationTask scheduleTask ( CouchDesignDocument serverDesignDoc , MailNotification mailNotification ) { Timer timer = new Timer ( ) ; MailVetterDailyNotificationTask installedTask = new MailVetterDailyNotificationTask ( timer , serverDesignDoc , mailNotification ) ; Calendar calendar = ... | 24 hours in ms |
14,488 | public Geometry simplifyGeometryAtResolution ( Geometry geometry , double resolution ) throws Exception { double inverseRes = 1 / resolution ; double p = Math . log10 ( inverseRes ) ; double exp = Math . ceil ( p ) ; if ( exp < 0 ) exp = 0 ; double factor = Math . pow ( 10 , exp ) ; Geometry simplifiedGeometry = simpli... | Accepts a geometry and a resolution . Returns a version of the geometry which is simplified for the given resolution . If the initial geometry is already simplified enough then return null . |
14,489 | private void performQuery ( HttpServletRequest request , HttpServletResponse response ) throws Exception { User user = AuthenticationUtils . getUserFromRequest ( request ) ; String tableName = getTableNameFromRequest ( request ) ; DbTableAccess tableAccess = DbTableAccess . getAccess ( dbSecurity , tableName , new DbUs... | Perform a SQL query of a specified table that must be accessible via dbSec . |
14,490 | private void performMultiQuery ( HttpServletRequest request , HttpServletResponse response ) throws Exception { User user = AuthenticationUtils . getUserFromRequest ( request ) ; String [ ] queriesStrings = request . getParameterValues ( "queries" ) ; if ( 1 != queriesStrings . length ) { throw new Exception ( "Paramet... | Perform multiple SQL queries via dbSec . |
14,491 | private List < FieldSelector > getFieldSelectorsFromRequest ( HttpServletRequest request ) throws Exception { String [ ] fieldSelectorStrings = request . getParameterValues ( "select" ) ; if ( null == fieldSelectorStrings ) { return null ; } if ( 0 == fieldSelectorStrings . length ) { return null ; } List < FieldSelect... | Return a list of column names to be included in a select clause . |
14,492 | private List < OrderSpecifier > getOrderByList ( HttpServletRequest request ) throws Exception { String [ ] orderByStrings = request . getParameterValues ( "orderBy" ) ; if ( null == orderByStrings ) { return null ; } if ( 0 == orderByStrings . length ) { return null ; } List < OrderSpecifier > result = new Vector < Or... | Return a list of order specifiers found in request |
14,493 | public TableSchema getTableSchemaFromName ( String tableName , DbUser user ) throws Exception { List < String > tableNames = new Vector < String > ( ) ; tableNames . add ( tableName ) ; Map < String , TableSchemaImpl > nameToTableMap = getTableDataFromGroups ( user , tableNames ) ; if ( false == nameToTableMap . contai... | Computes from the database the access to a table for a given user . In this call a user is represented by the set of groups it belongs to . |
14,494 | public List < TableSchema > getAvailableTablesFromGroups ( DbUser user ) throws Exception { Map < String , TableSchemaImpl > nameToTableMap = getTableDataFromGroups ( user , null ) ; List < TableSchema > result = new Vector < TableSchema > ( ) ; result . addAll ( nameToTableMap . values ( ) ) ; return result ; } | Computes from the database the access to all tables for a given user . In this call a user is represented by the set of groups it belongs to . |
14,495 | static public List < String > breakUpCommand ( String command ) throws Exception { try { List < String > commandTokens = new Vector < String > ( ) ; StringBuilder currentToken = null ; boolean isTokenQuoted = false ; StringReader sr = new StringReader ( command ) ; int b = sr . read ( ) ; while ( b >= 0 ) { char c = ( ... | Takes a single line command as a string and breaks it up in tokens acceptable for the java . lang . ProcessBuilder . ProcessBuilder |
14,496 | private UserAndPassword executeStatementToUser ( PreparedStatement preparedStmt ) throws Exception { if ( preparedStmt . execute ( ) ) { ResultSet rs = preparedStmt . getResultSet ( ) ; ResultSetMetaData rsmd = rs . getMetaData ( ) ; int numColumns = rsmd . getColumnCount ( ) ; if ( numColumns != 5 ) { throw new Except... | This method executes a prepared SQL statement against the user table and returns a User . |
14,497 | private void writeNumber ( PrintWriter pw , NumberFormat numFormat , Number num ) { if ( num . doubleValue ( ) == Math . round ( num . doubleValue ( ) ) ) { if ( null != numFormat ) { pw . print ( numFormat . format ( num . intValue ( ) ) ) ; } else { pw . print ( num . intValue ( ) ) ; } } else { if ( null != numForma... | Writes a number to the print writer . If the number is an integer do not write the decimal points . |
14,498 | static public Date parseGpsTimestamp ( String gpsTimestamp ) throws Exception { try { Matcher matcherTime = patternTime . matcher ( gpsTimestamp ) ; if ( matcherTime . matches ( ) ) { int year = Integer . parseInt ( matcherTime . group ( 1 ) ) ; int month = Integer . parseInt ( matcherTime . group ( 2 ) ) ; int day = I... | Parses a GPS timestamp with a 1 second precision . |
14,499 | static public String safeSqlQueryStringValue ( String in ) throws Exception { if ( null == in ) { return "NULL" ; } if ( in . indexOf ( '\0' ) >= 0 ) { throw new Exception ( "Null character found in string value" ) ; } in = in . replace ( "'" , "''" ) ; return "'" + in + "'" ; } | This method converts a string into a new one that is safe for a SQL query . It deals with strings that are expected to be string values . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.