Package org.modeshape.jcr.api.value

Examples of org.modeshape.jcr.api.value.DateTime


            List<DateTime> versionDates = new ArrayList<DateTime>(versions.keySet());
            Collections.sort(versionDates);

            Version versionSameDateTime = null;
            for (int i = versionDates.size() - 1; i >= 0; i--) {
                DateTime versionDate = versionDates.get(i);
                if (versionDate.isBefore(checkinTime)) {
                    Version version = versions.get(versionDate);
                    return ((JcrVersionNode)version).getFrozenNode();
                } else if (versionDate.equals(checkinTime)) {
                    versionSameDateTime = versions.get(versionDate);
                }
            }

            // we weren't able to find a version with a "before" timestamp, so check for one with the same timestamp
View Full Code Here


    @Test
    public void shouldTestEventIteratorTest_testSkip() throws Exception {
        // create events
        List<Event> events = new ArrayList<Event>();
        DateTime now = session.dateFactory().create();
        JcrEventBundle bundle = new JcrEventBundle(now, "userId", null);
        String id1 = UUID.randomUUID().toString();
        String id2 = UUID.randomUUID().toString();
        String id3 = UUID.randomUUID().toString();
        events.add(new JcrObservationManager.JcrEvent(bundle, Event.NODE_ADDED, "/testroot/node1",
View Full Code Here

        // Compute the save meta-info ...
        ExecutionContext context = context();
        String userId = context.getSecurityContext().getUserName();
        Map<String, String> userData = context.getData();
        final boolean acquireLock = false; // we already pre-locked all of the existing documents that we'll edit ...
        DateTime timestamp = context.getValueFactories().getDateFactory().create();
        String workspaceName = persistedCache.getWorkspaceName();
        String repositoryKey = persistedCache.getRepositoryKey();
        RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), repositoryKey, workspaceName,
                                                        sessionContext().journalId());
View Full Code Here

                // could happen if not enough permissions, for example
                if (commit != null) {
                    // Add the properties for this node ...
                    String committer = commiterName(commit);
                    String author = authorName(commit);
                    DateTime committed = values.dateFrom(commit.getCommitTime());
                    writer.setPrimaryType(GitLexicon.FOLDER);
                    writer.addProperty(JcrLexicon.CREATED, committed);
                    writer.addProperty(JcrLexicon.CREATED_BY, committer);
                    writer.addProperty(GitLexicon.OBJECT_ID, objId.name());
                    writer.addProperty(GitLexicon.AUTHOR, author);
View Full Code Here

                // could happen if not enough permissions, for example
                if (folderCommit != null) {
                    // Add folder-related properties ...
                    String committer = commiterName(folderCommit);
                    String author = authorName(folderCommit);
                    DateTime committed = values.dateFrom(folderCommit.getCommitTime());
                    writer.addProperty(JcrLexicon.CREATED, committed);
                    writer.addProperty(JcrLexicon.CREATED_BY, committer);
                    writer.addProperty(GitLexicon.OBJECT_ID, folderCommit.getId().name());
                    writer.addProperty(GitLexicon.AUTHOR, author);
                    writer.addProperty(GitLexicon.COMMITTER, committer);
                    writer.addProperty(GitLexicon.COMMITTED, committed);
                    writer.addProperty(GitLexicon.TITLE, folderCommit.getShortMessage());
                } else {
                    connector.getLogger().warn(GitI18n.cannotReadCommit, path);
                }

                // And now walk the contents of the directory ...
                while (tw.next()) {
                    String childName = tw.getNameString();
                    String childId = spec.childId(childName);
                    writer.addChild(childId, childName);
                }
            } else {
                // The path specifies a file (or a content node) ...

                // Find the commit in which this folder was last modified ...
                // This may not be terribly efficient, but it seems to work faster on subsequent runs ...
                RevCommit fileCommit = git.log().addPath(path).call().iterator().next();

                if (isContentNode) {
                    writer.setPrimaryType(GitLexicon.RESOURCE);
                    if (fileCommit == null) {
                        // could happen if not enough permissions, for example
                        connector.getLogger().warn(GitI18n.cannotReadCommit, path);
                        return;
                    }
                    // Add file-related properties ...
                    String committer = commiterName(fileCommit);
                    String author = authorName(fileCommit);
                    DateTime committed = values.dateFrom(fileCommit.getCommitTime());

                    writer.addProperty(JcrLexicon.LAST_MODIFIED, committed);
                    writer.addProperty(JcrLexicon.LAST_MODIFIED_BY, committer);
                    writer.addProperty(GitLexicon.OBJECT_ID, fileCommit.getId().name());
                    writer.addProperty(GitLexicon.AUTHOR, author);
                    writer.addProperty(GitLexicon.COMMITTER, committer);
                    writer.addProperty(GitLexicon.COMMITTED, committed);
                    writer.addProperty(GitLexicon.TITLE, fileCommit.getShortMessage());
                    // Create the BinaryValue ...
                    ObjectId fileObjectId = tw.getObjectId(0);
                    ObjectLoader fileLoader = repository.open(fileObjectId);
                    BinaryKey key = new BinaryKey(fileObjectId.getName());
                    BinaryValue value = values.binaryFor(key, fileLoader.getSize());
                    if (value == null) {
                        // It wasn't found in the binary store ...
                        if (fileLoader.isLarge()) {
                            // Too large to hold in memory, so use the binary store (which reads the file immediately) ...
                            value = values.binaryFrom(fileLoader.openStream());
                        } else {
                            // This is small enough to fit into a byte[], but it still may be pretty big ...
                            value = new GitBinaryValue(fileObjectId, fileLoader, connector.getSourceName(), name,
                                                       connector.getMimeTypeDetector());
                        }
                    }
                    writer.addProperty(JcrLexicon.DATA, value);
                    if (connector.includeMimeType()) {
                        try {
                            String filename = spec.parameter(spec.parameterCount() - 1); // the last is 'jcr:content'
                            String mimeType = value.getMimeType(filename);
                            if (mimeType != null) writer.addProperty(JcrLexicon.MIMETYPE, mimeType);
                        } catch (RepositoryException e) {
                            // do nothing
                        } catch (IOException e) {
                            // do nothing
                        }
                    }
                } else {
                    writer.setPrimaryType(GitLexicon.FILE);
                    if (fileCommit == null) {
                        // could happen if not enough permissions, for example
                        connector.getLogger().warn(GitI18n.cannotReadCommit, path);
                        return;
                    }
                    // Add file-related properties ...
                    String committer = commiterName(fileCommit);
                    String author = authorName(fileCommit);
                    DateTime committed = values.dateFrom(fileCommit.getCommitTime());

                    writer.addProperty(JcrLexicon.CREATED, committed);
                    writer.addProperty(JcrLexicon.CREATED_BY, committer);
                    writer.addProperty(GitLexicon.OBJECT_ID, fileCommit.getId().name());
                    writer.addProperty(GitLexicon.AUTHOR, author);
View Full Code Here

            String initializerId = UUID.randomUUID().toString();

            // Must be a new repository (or one created before 3.0.0.Final) ...
            this.repoKey = NodeKey.keyForSourceName(this.name);
            this.sourceKey = NodeKey.keyForSourceName(configuration.getStoreName());
            DateTime now = context.getValueFactories().getDateFactory().create();
            // Store this info in the repository info document ...
            EditableDocument doc = Schematic.newDocument();
            doc.setString(REPOSITORY_NAME_FIELD_NAME, this.name);
            doc.setString(REPOSITORY_KEY_FIELD_NAME, this.repoKey);
            doc.setString(REPOSITORY_SOURCE_NAME_FIELD_NAME, configuration.getStoreName());
            doc.setString(REPOSITORY_SOURCE_KEY_FIELD_NAME, this.sourceKey);
            doc.setDate(REPOSITORY_CREATED_AT_FIELD_NAME, now.toDate());
            doc.setString(REPOSITORY_INITIALIZER_FIELD_NAME, initializerId);
            doc.setString(REPOSITORY_CREATED_WITH_MODESHAPE_VERSION_FIELD_NAME, ModeShape.getVersion());
            doc.setNumber(REPOSITORY_UPGRADE_ID_FIELD_NAME, upgrades.getLatestAvailableUpgradeId());

            // store the repository info
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.api.value.DateTime

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.