idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
125,000 | public static boolean isManagedProperty ( final Node property ) { return property . isURI ( ) && isManagedPredicate . test ( createProperty ( property . getURI ( ) ) ) ; } | Test if a Predicate is managed |
125,001 | private FedoraBinary getBinary ( final String extUrl ) { if ( wrappedBinary == null ) { wrappedBinary = getBinaryImplementation ( extUrl ) ; } return wrappedBinary ; } | Get the proxied binary content object wrapped by this object |
125,002 | private FedoraBinary getBinaryImplementation ( final String extUrl ) { String url = extUrl ; if ( url == null || url . isEmpty ( ) ) { url = getURLInfo ( ) ; } if ( url != null ) { if ( url . toLowerCase ( ) . startsWith ( LOCAL_FILE_ACCESS_TYPE ) ) { return new LocalFileBinary ( getNode ( ) ) ; } else if ( url . toLow... | Return the proper object that can handle this type of binary |
125,003 | private String getURLInfo ( ) { try { if ( hasProperty ( PROXY_FOR ) ) { return getNode ( ) . getProperty ( PROXY_FOR ) . getValue ( ) . getString ( ) ; } else if ( hasProperty ( REDIRECTS_TO ) ) { return getNode ( ) . getProperty ( REDIRECTS_TO ) . getValue ( ) . getString ( ) ; } } catch ( RepositoryException e ) { t... | Fetch the URL of the external binary |
125,004 | private void addURIToAuthorize ( final HttpServletRequest httpRequest , final URI uri ) { @ SuppressWarnings ( "unchecked" ) Set < URI > targetURIs = ( Set < URI > ) httpRequest . getAttribute ( URIS_TO_AUTHORIZE ) ; if ( targetURIs == null ) { targetURIs = new HashSet < > ( ) ; httpRequest . setAttribute ( URIS_TO_AUT... | Add URIs to collect permissions information for . |
125,005 | private boolean isPayloadIndirectOrDirect ( final HttpServletRequest request ) { return Collections . list ( request . getHeaders ( "Link" ) ) . stream ( ) . map ( Link :: valueOf ) . map ( Link :: getUri ) . anyMatch ( l -> directOrIndirect . contains ( l ) ) ; } | Is the request to create an indirect or direct container . |
125,006 | private boolean isResourceIndirectOrDirect ( final FedoraResource resource ) { return resource . getTypes ( ) . stream ( ) . anyMatch ( l -> directOrIndirect . contains ( l ) ) ; } | Is the current resource a direct or indirect container |
125,007 | private boolean isAuthorizedForMembershipResource ( final HttpServletRequest request , final Subject currentUser ) throws IOException { if ( resourceExists ( request ) && request . getMethod ( ) . equalsIgnoreCase ( "POST" ) ) { if ( isResourceIndirectOrDirect ( resource ( request ) ) ) { final URI membershipResource =... | Check if we are authorized to access the target of membershipRelation if required . Really this is a test for failure . The default is true because we might not be looking at an indirect or direct container . |
125,008 | private URI getHasMemberFromRequest ( final HttpServletRequest request ) throws IOException { final String baseUri = request . getRequestURL ( ) . toString ( ) ; final RDFReader reader ; final String contentType = request . getContentType ( ) ; final Lang format = contentTypeToLang ( contentType ) ; final Model inputMo... | Get the memberRelation object from the contents . |
125,009 | private URI getHasMemberFromPatch ( final HttpServletRequest request ) throws IOException { final String sparqlString = IOUtils . toString ( request . getInputStream ( ) , UTF_8 ) ; final String baseURI = request . getRequestURL ( ) . toString ( ) . replace ( request . getContextPath ( ) , "" ) . replaceAll ( request .... | Get the membershipRelation from a PATCH request |
125,010 | public static URI asURI ( final String algorithm , final String value ) { try { final String scheme = DIGEST_ALGORITHM . getScheme ( algorithm ) ; return new URI ( scheme , value , null ) ; } catch ( final URISyntaxException unlikelyException ) { LOGGER . warn ( "Exception creating checksum URI: {}" , unlikelyException... | Convert a MessageDigest algorithm and checksum value to a URN |
125,011 | public static String getAlgorithm ( final URI digestUri ) { if ( digestUri == null ) { return DEFAULT_ALGORITHM ; } return DIGEST_ALGORITHM . fromScheme ( digestUri . getScheme ( ) + ":" + digestUri . getSchemeSpecificPart ( ) . split ( ":" , 2 ) [ 0 ] ) . algorithm ; } | Given a digest URI get the corresponding MessageDigest algorithm |
125,012 | private Node getMemberResource ( final FedoraResource parent ) throws RepositoryException { final Node membershipResource ; if ( parent . hasProperty ( LDP_MEMBER_RESOURCE ) ) { final Property memberResource = getJcrNode ( parent ) . getProperty ( LDP_MEMBER_RESOURCE ) ; if ( REFERENCE_TYPES . contains ( memberResource... | Get the membership resource relation asserted by the container |
125,013 | public static javax . jcr . Node nodeForValue ( final Session session , final Value v ) throws RepositoryException { if ( v . getType ( ) == PATH ) { return session . getNode ( v . getString ( ) ) ; } else if ( v . getType ( ) == REFERENCE || v . getType ( ) == WEAKREFERENCE ) { return session . getNodeByIdentifier ( v... | Get the node that a property value refers to . |
125,014 | public Map < String , Collection < String > > getRoles ( final Node node ) { return getAgentRoles ( nodeConverter . convert ( node ) ) ; } | Get the roles assigned to this Node . |
125,015 | private static Stream < String > getAgentMembers ( final IdentifierConverter < Resource , FedoraResource > translator , final FedoraResource resource , final String hashPortion ) { final List < Triple > triples = resource . getTriples ( translator , PROPERTIES ) . filter ( triple -> hashPortion == null || triple . getS... | Given a FedoraResource return a list of agents . |
125,016 | private static Stream < String > nodeToStringStream ( final org . apache . jena . graph . Node object ) { if ( object . isURI ( ) ) { return of ( object . getURI ( ) ) ; } else if ( object . isLiteral ( ) ) { return of ( object . getLiteralValue ( ) . toString ( ) ) ; } else { return empty ( ) ; } } | Map a Jena Node to a Stream of Strings . Any non - URI non - Literals map to an empty Stream making this suitable to use with flatMap . |
125,017 | static Optional < ACLHandle > getEffectiveAcl ( final FedoraResource resource , final boolean ancestorAcl , final SessionFactory sessionFactory ) { try { final FedoraResource aclResource = resource . getAcl ( ) ; if ( aclResource != null ) { final List < WebACAuthorization > authorizations = getAuthorizations ( aclReso... | Recursively find the effective ACL as a URI along with the FedoraResource that points to it . This way if the effective ACL is pointed to from a parent resource the child will inherit any permissions that correspond to access to that parent . This ACL resource may or may not exist and it may be external to the fedora r... |
125,018 | public Response runRestore ( final InputStream bodyStream ) throws IOException { if ( null == bodyStream ) { throw new WebApplicationException ( serverError ( ) . entity ( "Request body must not be null" ) . build ( ) ) ; } final String body = IOUtils . toString ( bodyStream ) ; final File backupDirectory = new File ( ... | This method runs a repository restore . |
125,019 | public PreferTag getReturn ( ) { return preferTags ( ) . stream ( ) . filter ( x -> x . getTag ( ) . equals ( "return" ) ) . findFirst ( ) . orElse ( emptyTag ( ) ) ; } | Get the return tag or a blank default if none exists . |
125,020 | public void addResponseHeaders ( final HttpServletResponse servletResponse ) { final String receivedParam = ofNullable ( params . get ( "received" ) ) . orElse ( "" ) ; final List < String > includes = asList ( ofNullable ( params . get ( "include" ) ) . orElse ( " " ) . split ( " " ) ) ; final List < String > omits = ... | Add appropriate response headers to indicate that the incoming preferences were acknowledged |
125,021 | public void publishJCREvent ( final FedoraEvent fedoraEvent ) throws JMSException { LOGGER . debug ( "Received an event from the internal bus." ) ; final Message tm = eventFactory . getMessage ( fedoraEvent , jmsSession ) ; LOGGER . debug ( "Transformed the event to a JMS message." ) ; producer . send ( tm ) ; LOGGER .... | When an EventBus mesage is received map it to our JMS message payload and push it onto the queue . |
125,022 | public void acquireConnections ( ) throws JMSException { LOGGER . debug ( "Initializing: {}" , this . getClass ( ) . getCanonicalName ( ) ) ; connection = connectionFactory . createConnection ( ) ; connection . start ( ) ; jmsSession = connection . createSession ( false , Session . AUTO_ACKNOWLEDGE ) ; producer = jmsSe... | Connect to JCR Repostory and JMS queue |
125,023 | public void releaseConnections ( ) throws JMSException { LOGGER . debug ( "Tearing down: {}" , this . getClass ( ) . getCanonicalName ( ) ) ; producer . close ( ) ; jmsSession . close ( ) ; connection . close ( ) ; eventBus . unregister ( this ) ; } | Close external connections |
125,024 | public Long getRepositorySize ( ) { try { LOGGER . debug ( "Calculating repository size from index" ) ; final Repository repo = getJcrRepository ( repository ) ; return ServiceHelpers . getRepositorySize ( repo ) ; } catch ( final RepositoryException e ) { throw new RepositoryRuntimeException ( e ) ; } } | Calculate the total size of all the binary properties in the repository |
125,025 | public FedoraResource getResourceFromPath ( final String externalPath ) { final Resource resource = translator ( ) . toDomain ( externalPath ) ; final FedoraResource fedoraResource = translator ( ) . convert ( resource ) ; if ( fedoraResource instanceof Tombstone ) { final String resourceURI = TRAILING_SLASH_REGEX . ma... | Get the FedoraResource for the resource at the external path |
125,026 | protected void setUpJMSInfo ( final UriInfo uriInfo , final HttpHeaders headers ) { try { String baseURL = getBaseUrlProperty ( uriInfo ) ; if ( baseURL . length ( ) == 0 ) { baseURL = uriInfo . getBaseUri ( ) . toString ( ) ; } LOGGER . debug ( "setting baseURL = " + baseURL ) ; session . getFedoraSession ( ) . addSes... | Set the baseURL for JMS events . |
125,027 | public static RdfStream fromModel ( final Node node , final Model model ) { return new DefaultRdfStream ( node , stream ( spliteratorUnknownSize ( model . listStatements ( ) , IMMUTABLE ) , false ) . map ( Statement :: asTriple ) ) ; } | Create an RdfStream from an existing Model . |
125,028 | public static Converter < Node , Resource > nodeToResource ( final Converter < Resource , FedoraResource > c ) { return nodeConverter . andThen ( c . reverse ( ) ) ; } | Get a converter that can transform a Node to a Resource |
125,029 | private void monitorForChanges ( ) { if ( monitorRunning ) { return ; } final Path path ; try { path = Paths . get ( configPath ) ; } catch ( final Exception e ) { LOGGER . warn ( "Cannot monitor configuration {}, disabling monitoring; {}" , configPath , e . getMessage ( ) ) ; return ; } if ( ! path . toFile ( ) . exis... | Starts up monitoring of the configuration for changes . |
125,030 | public void setConfigPath ( final String configPath ) { if ( configPath != null && configPath . startsWith ( "classpath:" ) ) { final String relativePath = configPath . substring ( 10 ) ; this . configPath = this . getClass ( ) . getResource ( relativePath ) . getPath ( ) ; } else { this . configPath = configPath ; } } | Set the file path for the configuration |
125,031 | public String get ( ) { final String s = randomUUID ( ) . toString ( ) ; final String id ; if ( count > 0 && length > 0 ) { final StringJoiner joiner = new StringJoiner ( "/" , "" , "/" + s ) ; IntStream . rangeClosed ( 0 , count - 1 ) . forEach ( x -> joiner . add ( s . substring ( x * length , ( x + 1 ) * length ) ) ... | Mint a unique identifier as a UUID |
125,032 | public FedoraResource find ( final FedoraSession session , final String path ) { final Session jcrSession = getJcrSession ( session ) ; try { return new FedoraResourceImpl ( jcrSession . getNode ( path ) ) ; } catch ( final RepositoryException e ) { throw new RepositoryRuntimeException ( e ) ; } } | Retrieve an existing Fedora resource at the given path |
125,033 | public void copyObject ( final FedoraSession session , final String source , final String destination ) { final Session jcrSession = getJcrSession ( session ) ; try { jcrSession . getWorkspace ( ) . copy ( source , destination ) ; touchLdpMembershipResource ( getJcrNode ( find ( session , destination ) ) ) ; } catch ( ... | Copy an existing object from the source path to the destination path |
125,034 | public void moveObject ( final FedoraSession session , final String source , final String destination ) { final Session jcrSession = getJcrSession ( session ) ; try { final FedoraResource srcResource = find ( session , source ) ; final Node sourceNode = getJcrNode ( srcResource ) ; final String name = sourceNode . getN... | Move an existing object from the source path to the destination path |
125,035 | private javax . jcr . Binary getBinaryContent ( ) { try { return getProperty ( JCR_DATA ) . getBinary ( ) ; } catch ( final PathNotFoundException e ) { throw new PathNotFoundRuntimeException ( e ) ; } catch ( final RepositoryException e ) { throw new RepositoryRuntimeException ( e ) ; } } | Retrieve the JCR Binary object |
125,036 | private void verifyChecksums ( final Collection < URI > checksums , final Property dataProperty ) throws InvalidChecksumException { final Map < URI , URI > checksumErrors = new HashMap < > ( ) ; checksums . forEach ( checksum -> { final String algorithm = ContentDigest . getAlgorithm ( checksum ) ; try { if ( algorithm... | This method ensures that the arg checksums are valid against the binary associated with the arg dataProperty . If one or more of the checksums are invalid an InvalidChecksumException is thrown . |
125,037 | private static void decorateContentNode ( final Node dsNode , final Node descNode , final Collection < URI > checksums ) throws RepositoryException { if ( dsNode == null ) { LOGGER . warn ( "{} node appears to be null!" , JCR_CONTENT ) ; return ; } if ( dsNode . hasProperty ( JCR_DATA ) ) { final Property dataProperty ... | Add necessary information to node |
125,038 | private Stream < Triple > memberRelations ( final FedoraResource container ) throws RepositoryException { final org . apache . jena . graph . Node memberRelation ; if ( container . hasProperty ( LDP_HAS_MEMBER_RELATION ) ) { final Property property = getJcrNode ( container ) . getProperty ( LDP_HAS_MEMBER_RELATION ) ; ... | Get the member relations assert on the subject by the given node |
125,039 | @ SuppressWarnings ( "unchecked" ) private Stream < FedoraResource > nodeToGoodChildren ( final Node input ) throws RepositoryException { return iteratorToStream ( input . getNodes ( ) ) . filter ( nastyChildren . negate ( ) ) . flatMap ( uncheck ( ( final Node child ) -> child . isNodeType ( FEDORA_PAIRTREE ) ? nodeTo... | Get the good children for a node by skipping all pairtree nodes in the way . |
125,040 | private static Stream < FedoraResource > getAllChildren ( final FedoraResource resource ) { return concat ( of ( resource ) , resource . getChildren ( ) . flatMap ( FedoraResourceImpl :: getAllChildren ) ) ; } | Get all children recursively and flatten into a single Stream . |
125,041 | public void touch ( final boolean includeMembershipResource , final Calendar createdDate , final String createdUser , final Calendar modifiedDate , final String modifyingUser ) throws RepositoryException { FedoraTypesUtils . touch ( getNode ( ) , createdDate , createdUser , modifiedDate , modifyingUser ) ; if ( include... | Touches a resource to ensure that the implicitly updated properties are updated if not explicitly set . |
125,042 | protected static Function < Triple , Triple > convertMementoReferences ( final IdentifierConverter < Resource , FedoraResource > translator , final IdentifierConverter < Resource , FedoraResource > internalTranslator ) { return t -> { final String subjectURI = t . getSubject ( ) . getURI ( ) ; final String subjectPath ... | Returns a function that converts the subject to the original URI and the object of a triple from an undereferenceable internal identifier back to it s original external resource path . If the object is not an internal identifier the object is returned . |
125,043 | private static long dateTimeDifference ( final Temporal d1 , final Temporal d2 ) { return ChronoUnit . SECONDS . between ( d1 , d2 ) ; } | Calculate the difference between two datetime to the unit . |
125,044 | public void validate ( final String extPath ) throws ExternalMessageBodyException { if ( allowedList == null || allowedList . size ( ) == 0 ) { throw new ExternalMessageBodyException ( "External content is disallowed by the server" ) ; } if ( isEmpty ( extPath ) ) { throw new ExternalMessageBodyException ( "External co... | Validates that an external path is valid . The path must be an HTTP or file URI within the allow list of paths be absolute and contain no relative modifier . |
125,045 | protected synchronized void loadConfiguration ( ) throws IOException { LOGGER . info ( "Loading list of allowed external content locations from {}" , configPath ) ; try ( final Stream < String > stream = Files . lines ( Paths . get ( configPath ) ) ) { allowedList = stream . map ( line -> normalizePath ( line . trim ( ... | Loads the allowed list . |
125,046 | public static void validatePath ( final Session session , final String path ) { final NamespaceRegistry namespaceRegistry = getNamespaceRegistry ( session ) ; final String [ ] pathSegments = path . replaceAll ( "^/+" , "" ) . replaceAll ( "/+$" , "" ) . split ( "/" ) ; for ( final String segment : pathSegments ) { fina... | Validate resource path for unregistered namespace prefixes |
125,047 | public static Map < String , String > getNamespaces ( final Session session ) { final NamespaceRegistry registry = getNamespaceRegistry ( session ) ; final Map < String , String > namespaces = new HashMap < > ( ) ; try { stream ( registry . getPrefixes ( ) ) . filter ( internalPrefix . negate ( ) ) . forEach ( x -> { t... | Retrieve the namespaces as a Map |
125,048 | private static Map < String , String > filterNamespacesToPresent ( final Model model , final Map < String , String > nsPrefixes ) { final Map < String , String > resultNses = new HashMap < > ( ) ; final Set < Entry < String , String > > nsSet = nsPrefixes . entrySet ( ) ; final NsIterator nsIt = model . listNameSpaces ... | Filters the map of namespace prefix mappings to just those containing namespace URIs present in the model |
125,049 | public Response runBackup ( final InputStream bodyStream ) throws IOException { File backupDirectory ; if ( null != bodyStream ) { final String body = IOUtils . toString ( bodyStream ) . trim ( ) ; backupDirectory = new File ( body . trim ( ) ) ; if ( body . isEmpty ( ) ) { backupDirectory = createTempDir ( ) ; } else ... | This method runs a repository backup . |
125,050 | protected synchronized void loadConfiguration ( ) throws IOException { final ObjectMapper mapper = new ObjectMapper ( new YAMLFactory ( ) ) ; final TypeReference < HashMap < String , String > > typeRef = new TypeReference < HashMap < String , String > > ( ) { } ; namespaces = mapper . readValue ( new File ( configPath ... | Load the namespace prefix to URI configuration file |
125,051 | private FedoraResource getResourceFromSubject ( final String subjectUri ) { final UriTemplate uriTemplate = new UriTemplate ( uriInfo . getBaseUriBuilder ( ) . clone ( ) . path ( FedoraLdp . class ) . toTemplate ( ) ) ; final Map < String , String > values = new HashMap < > ( ) ; uriTemplate . match ( subjectUri , valu... | Get a FedoraResource for the subject of the graph if it exists . |
125,052 | public void buildRepository ( ) { try { LOGGER . info ( "Using repo config (classpath): {}" , repositoryConfiguration . getURL ( ) ) ; getPropertiesLoader ( ) . loadSystemProperties ( ) ; final RepositoryConfiguration config = RepositoryConfiguration . read ( repositoryConfiguration . getURL ( ) ) ; repository = modeSh... | Generate a JCR repository from the given configuration |
125,053 | public void stopRepository ( ) throws InterruptedException { LOGGER . info ( "Initiating shutdown of ModeShape" ) ; final String repoName = repository . getName ( ) ; try { final Future < Boolean > futureUndeployRepo = modeShapeEngine . undeploy ( repoName ) ; if ( futureUndeployRepo . get ( ) ) { LOGGER . info ( "Mode... | Attempts to undeploy the repository and shutdown the ModeShape engine on context destroy . |
125,054 | private static Long getNodePropertySize ( final Node node ) throws RepositoryException { Long size = 0L ; for ( final PropertyIterator i = node . getProperties ( ) ; i . hasNext ( ) ; ) { final Property p = i . nextProperty ( ) ; if ( p . isMultiple ( ) ) { for ( final Value v : p . getValues ( ) ) { size += v . getBin... | Get the total size of a Node s properties |
125,055 | private static Long getContentSize ( final Node ds ) { try { long size = 0L ; if ( ds . hasNode ( JCR_CONTENT ) ) { final Node contentNode = ds . getNode ( JCR_CONTENT ) ; if ( contentNode . hasProperty ( JCR_DATA ) ) { size = ds . getNode ( JCR_CONTENT ) . getProperty ( JCR_DATA ) . getBinary ( ) . getSize ( ) ; } } r... | Get the size of the JCR content binary property |
125,056 | public Response createTransaction ( @ PathParam ( "path" ) final String externalPath ) throws URISyntaxException { if ( batchService . exists ( session . getId ( ) , getUserPrincipal ( ) ) ) { LOGGER . debug ( "renewing transaction {}" , session . getId ( ) ) ; batchService . refresh ( session . getId ( ) , getUserPrin... | Create a new transaction resource and add it to the registry |
125,057 | @ Path ( "fcr:commit" ) public Response commit ( @ PathParam ( "path" ) final String externalPath ) { LOGGER . info ( "Commit transaction '{}'" , externalPath ) ; return finalizeTransaction ( externalPath , getUserPrincipal ( ) , true ) ; } | Commit a transaction resource |
125,058 | @ Path ( "fcr:rollback" ) public Response rollback ( @ PathParam ( "path" ) final String externalPath ) { LOGGER . info ( "Rollback transaction '{}'" , externalPath ) ; return finalizeTransaction ( externalPath , getUserPrincipal ( ) , false ) ; } | Rollback a transaction |
125,059 | public static Session getJcrSession ( final FedoraSession session ) { if ( session instanceof FedoraSessionImpl ) { return ( ( FedoraSessionImpl ) session ) . getJcrSession ( ) ; } throw new ClassCastException ( "FedoraSession is not a " + FedoraSessionImpl . class . getCanonicalName ( ) ) ; } | Get the internal JCR session from an existing FedoraSession |
125,060 | public static Triple mapSubject ( final Triple t , final String resourceUri , final String destinationUri ) { final Node destinationNode = createURI ( destinationUri ) ; return mapSubject ( t , resourceUri , destinationNode ) ; } | Maps the subject of t from resourceUri to destinationUri to produce a new Triple . If the triple does not have the subject resourceUri then the triple is unchanged . |
125,061 | public static Triple mapSubject ( final Triple t , final String resourceUri , final Node destinationNode ) { final Node tripleSubj = t . getSubject ( ) ; final String tripleSubjUri = tripleSubj . getURI ( ) ; final Node subject ; if ( tripleSubjUri . equals ( resourceUri ) ) { subject = destinationNode ; } else if ( tr... | Maps the subject of t from resourceUri to destinationNode to produce a new Triple . If the triple does not have the subject resourceUri then the triple is unchanged . |
125,062 | public String serialize ( final FedoraEvent evt ) { try { final Model model = EventSerializer . toModel ( evt ) ; final ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; model . write ( out , "TTL" ) ; return out . toString ( "UTF-8" ) ; } catch ( final UnsupportedEncodingException ex ) { throw new Repository... | Serialize a FedoraEvent in RDF using Turtle syntax |
125,063 | public static Link buildConstraintLink ( final ConstraintViolationException e , final ServletContext context , final UriInfo uriInfo ) { String path = context . getContextPath ( ) ; if ( path . equals ( "/" ) ) { path = "" ; } final String constraintURI = uriInfo == null ? "" : String . format ( "%s://%s%s%s%s.rdf" , u... | Creates a constrainedBy link header with the appropriate RDF URL for the exception . |
125,064 | public static Optional < Integer > getPropertyType ( final Node node , final String propertyName ) throws RepositoryException { LOGGER . debug ( "Getting type of property: {} from node: {}" , propertyName , node ) ; return getDefinitionForPropertyName ( node , propertyName ) . map ( PropertyDefinition :: getRequiredTyp... | Get the JCR property type ID for a given property name . If unsure mark it as UNDEFINED . |
125,065 | public static String getReferencePropertyOriginalName ( final String refPropertyName ) { final int i = refPropertyName . lastIndexOf ( REFERENCE_PROPERTY_SUFFIX ) ; return i < 0 ? refPropertyName : refPropertyName . substring ( 0 , i ) ; } | Given an internal reference node property get the original name |
125,066 | public static boolean isReferenceProperty ( final Node node , final String propertyName ) throws RepositoryException { final Optional < PropertyDefinition > propertyDefinition = getDefinitionForPropertyName ( node , propertyName ) ; return propertyDefinition . isPresent ( ) && ( propertyDefinition . get ( ) . getRequir... | Check if a property definition is a reference property |
125,067 | public static Node getClosestExistingAncestor ( final Session session , final String path ) throws RepositoryException { String potentialPath = path . startsWith ( "/" ) ? path : "/" + path ; while ( ! potentialPath . isEmpty ( ) ) { if ( session . nodeExists ( potentialPath ) ) { return session . getNode ( potentialPa... | Get the closest ancestor that current exists |
125,068 | public static Node getJcrNode ( final FedoraResource resource ) { if ( resource instanceof FedoraResourceImpl ) { return ( ( FedoraResourceImpl ) resource ) . getNode ( ) ; } throw new IllegalArgumentException ( "FedoraResource is of the wrong type" ) ; } | Retrieve the underlying JCR Node from the FedoraResource |
125,069 | public static Function < Resource , Optional < String > > resourceToProperty ( final Session session ) { return resource -> { try { final NamespaceRegistry registry = getNamespaceRegistry ( session ) ; return Optional . of ( registry . getPrefix ( resource . getNameSpace ( ) ) + ":" + resource . getLocalName ( ) ) ; } ... | Using a JCR session return a function that maps an RDF Resource to a corresponding property name . |
125,070 | private static void touch ( final Node node , final Calendar modified , final String modifyingUser ) { touch ( node , null , null , modified , modifyingUser ) ; } | Updates the LAST_MODIFIED_DATE and LAST_MODIFIED_BY properties to the provided values . |
125,071 | public static void touch ( final Node node , final Calendar created , final String creatingUser , final Calendar modified , final String modifyingUser ) { try { if ( created != null ) { node . setProperty ( FEDORA_CREATED , created ) ; } if ( creatingUser != null ) { node . setProperty ( FEDORA_CREATEDBY , creatingUser... | Updates the LAST_MODIFIED_DATE LAST_MODIFIED_BY CREATED_DATE and CREATED_BY properties to the provided values . |
125,072 | public static Optional < Node > getContainingNode ( final Node node ) { try { if ( node . getDepth ( ) == 0 ) { return empty ( ) ; } final Node parent = node . getParent ( ) ; if ( parent . isNodeType ( FEDORA_PAIRTREE ) || parent . isNodeType ( FEDORA_NON_RDF_SOURCE_DESCRIPTION ) ) { return getContainingNode ( parent ... | Get the JCR Node that corresponds to the containing node in the repository . This may be the direct parent node but it may also be a more distant ancestor . |
125,073 | public static EventType valueOf ( final Integer i ) { final EventType type = translation . get ( i ) ; if ( isNull ( type ) ) { throw new IllegalArgumentException ( "Invalid event type: " + i ) ; } return type ; } | Get the Fedora event type for a JCR type |
125,074 | public static FedoraEvent from ( final Event event ) { requireNonNull ( event ) ; try { @ SuppressWarnings ( "unchecked" ) final Map < String , String > info = new HashMap < > ( event . getInfo ( ) ) ; final String userdata = event . getUserData ( ) ; try { if ( userdata != null && ! userdata . isEmpty ( ) ) { final Js... | Convert a JCR Event to a FedoraEvent |
125,075 | public static Stream < String > getResourceTypes ( final Event event ) { if ( event instanceof org . modeshape . jcr . api . observation . Event ) { try { final org . modeshape . jcr . api . observation . Event modeEvent = ( org . modeshape . jcr . api . observation . Event ) event ; final Stream . Builder < NodeType >... | Get the RDF Types of the resource corresponding to this JCR Event |
125,076 | @ SuppressWarnings ( "resource" ) public InputStream retrieveExternalContent ( final URI sourceUri ) throws IOException { final HttpGet httpGet = new HttpGet ( sourceUri ) ; final CloseableHttpClient client = getCloseableHttpClient ( ) ; final HttpResponse response = client . execute ( httpGet ) ; return response . get... | Retrieve the content at the URI using the global connection pool . |
125,077 | public static Object toBean ( JSONObject jsonObject ) { if ( jsonObject == null || jsonObject . isNullObject ( ) ) { return null ; } DynaBean dynaBean = null ; JsonConfig jsonConfig = new JsonConfig ( ) ; Map props = JSONUtils . getProperties ( jsonObject ) ; dynaBean = JSONUtils . newDynaBean ( jsonObject , jsonConfig... | Creates a JSONDynaBean from a JSONObject . |
125,078 | protected final String shaveOffNonJavaIdentifierStartChars ( String str ) { String str2 = str ; boolean ready = false ; while ( ! ready ) { if ( ! Character . isJavaIdentifierStart ( str2 . charAt ( 0 ) ) ) { str2 = str2 . substring ( 1 ) ; if ( str2 . length ( ) == 0 ) { throw new JSONException ( "Can't convert '" + s... | Removes all non JavaIdentifier chars from the start of the string . |
125,079 | public JSON read ( String xml ) { JSON json = null ; try { Document doc = new Builder ( ) . build ( new StringReader ( xml ) ) ; Element root = doc . getRootElement ( ) ; if ( isNullObject ( root ) ) { return JSONNull . getInstance ( ) ; } String defaultType = getType ( root , JSONTypes . STRING ) ; if ( isArray ( root... | Creates a JSON value from a XML string . |
125,080 | public JSON readFromStream ( InputStream stream ) { try { StringBuffer xml = new StringBuffer ( ) ; BufferedReader in = new BufferedReader ( new InputStreamReader ( stream ) ) ; String line = null ; while ( ( line = in . readLine ( ) ) != null ) { xml . append ( line ) ; } return read ( xml . toString ( ) ) ; } catch (... | Creates a JSON value from an input stream . |
125,081 | private boolean canAutoExpand ( JSONArray array ) { for ( int i = 0 ; i < array . size ( ) ; i ++ ) { if ( ! ( array . get ( i ) instanceof JSONObject ) ) { return false ; } } return true ; } | Only perform auto expansion if all children are objects . |
125,082 | public static String getFunctionBody ( String function ) { return RegexpUtils . getMatcher ( FUNCTION_BODY_PATTERN , true ) . getGroupIfMatches ( function , 1 ) ; } | Returns the body of a function literal . |
125,083 | public static String getFunctionParams ( String function ) { return RegexpUtils . getMatcher ( FUNCTION_PARAMS_PATTERN , true ) . getGroupIfMatches ( function , 1 ) ; } | Returns the params of a function literal . |
125,084 | public static Class getInnerComponentType ( Class type ) { if ( ! type . isArray ( ) ) { return type ; } return getInnerComponentType ( type . getComponentType ( ) ) ; } | Returns the inner - most component type of an Array . |
125,085 | public static Map getProperties ( JSONObject jsonObject ) { Map properties = new HashMap ( ) ; for ( Iterator keys = jsonObject . keys ( ) ; keys . hasNext ( ) ; ) { String key = ( String ) keys . next ( ) ; properties . put ( key , getTypeClass ( jsonObject . get ( key ) ) ) ; } return properties ; } | Creates a Map with all the properties of the JSONObject . |
125,086 | public static boolean isArray ( Class clazz ) { return clazz != null && ( clazz . isArray ( ) || Collection . class . isAssignableFrom ( clazz ) || ( JSONArray . class . isAssignableFrom ( clazz ) ) ) ; } | Tests if a Class represents an array or Collection . |
125,087 | public static boolean isArray ( Object obj ) { if ( ( obj != null && obj . getClass ( ) . isArray ( ) ) || ( obj instanceof Collection ) || ( obj instanceof JSONArray ) ) { return true ; } return false ; } | Tests if obj is an array or Collection . |
125,088 | public static boolean isBoolean ( Class clazz ) { return clazz != null && ( Boolean . TYPE . isAssignableFrom ( clazz ) || Boolean . class . isAssignableFrom ( clazz ) ) ; } | Tests if Class represents a Boolean or primitive boolean |
125,089 | public static boolean isBoolean ( Object obj ) { if ( ( obj instanceof Boolean ) || ( obj != null && obj . getClass ( ) == Boolean . TYPE ) ) { return true ; } return false ; } | Tests if obj is a Boolean or primitive boolean |
125,090 | public static boolean isJavaIdentifier ( String str ) { if ( str . length ( ) == 0 || ! Character . isJavaIdentifierStart ( str . charAt ( 0 ) ) ) { return false ; } for ( int i = 1 ; i < str . length ( ) ; i ++ ) { if ( ! Character . isJavaIdentifierPart ( str . charAt ( i ) ) ) { return false ; } } return true ; } | Returns trus if str represents a valid Java identifier . |
125,091 | public static boolean isNull ( Object obj ) { if ( obj instanceof JSONObject ) { return ( ( JSONObject ) obj ) . isNullObject ( ) ; } return JSONNull . getInstance ( ) . equals ( obj ) ; } | Tests if the obj is a javaScript null . |
125,092 | public static boolean isObject ( Object obj ) { return ! isNumber ( obj ) && ! isString ( obj ) && ! isBoolean ( obj ) && ! isArray ( obj ) && ! isFunction ( obj ) || isNull ( obj ) ; } | Tests if obj is not a boolean number string or array . |
125,093 | public static boolean isString ( Class clazz ) { return clazz != null && ( String . class . isAssignableFrom ( clazz ) || ( Character . TYPE . isAssignableFrom ( clazz ) || Character . class . isAssignableFrom ( clazz ) ) ) ; } | Tests if Class represents a String or a char |
125,094 | public static boolean isString ( Object obj ) { if ( ( obj instanceof String ) || ( obj instanceof Character ) || ( obj != null && ( obj . getClass ( ) == Character . TYPE || String . class . isAssignableFrom ( obj . getClass ( ) ) ) ) ) { return true ; } return false ; } | Tests if obj is a String or a char |
125,095 | public static DynaBean newDynaBean ( JSONObject jsonObject , JsonConfig jsonConfig ) { Map props = getProperties ( jsonObject ) ; for ( Iterator entries = props . entrySet ( ) . iterator ( ) ; entries . hasNext ( ) ; ) { Map . Entry entry = ( Map . Entry ) entries . next ( ) ; String key = ( String ) entry . getKey ( )... | Creates a new MorphDynaBean from a JSONObject . The MorphDynaBean will have all the properties of the original JSONObject with the most accurate type . Values of properties are not copied . |
125,096 | public static String quoteCanonical ( String s ) { if ( s == null || s . length ( ) == 0 ) { return "\"\"" ; } int len = s . length ( ) ; StringBuilder sb = new StringBuilder ( len + 4 ) ; sb . append ( '"' ) ; for ( int i = 0 ; i < len ; i += 1 ) { char c = s . charAt ( i ) ; switch ( c ) { case '\\' : case '"' : sb .... | Minimal escape form . |
125,097 | public static String stripQuotes ( String input ) { if ( input . length ( ) < 2 ) { return input ; } else if ( input . startsWith ( SINGLE_QUOTE ) && input . endsWith ( SINGLE_QUOTE ) ) { return input . substring ( 1 , input . length ( ) - 1 ) ; } else if ( input . startsWith ( DOUBLE_QUOTE ) && input . endsWith ( DOUB... | Strips any single - quotes or double - quotes from both sides of the string . |
125,098 | public static boolean hasQuotes ( String input ) { if ( input == null || input . length ( ) < 2 ) { return false ; } return input . startsWith ( SINGLE_QUOTE ) && input . endsWith ( SINGLE_QUOTE ) || input . startsWith ( DOUBLE_QUOTE ) && input . endsWith ( DOUBLE_QUOTE ) ; } | Returns true if the input has single - quotes or double - quotes at both sides . |
125,099 | private static boolean isDouble ( Number n ) { if ( n instanceof Double ) { return true ; } try { double d = Double . parseDouble ( String . valueOf ( n ) ) ; return ! Double . isInfinite ( d ) ; } catch ( NumberFormatException e ) { return false ; } } | Finds out if n represents a Double . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.