<commit_before>/*
 * Copyright 2015 <NAME>, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.twcable.jackalope.impl.jcr;

import com.twcable.jackalope.impl.common.Paths;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;

import javax.annotation.Nonnull;
import javax.jcr.Credentials;
import javax.jcr.InvalidSerializedDataException;
import javax.jcr.Item;
import javax.jcr.ItemExistsException;
import javax.jcr.ItemNotFoundException;
import javax.jcr.LoginException;
import javax.jcr.NamespaceException;
import javax.jcr.Node;
import javax.jcr.PathNotFoundException;
import javax.jcr.Property;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.UnsupportedRepositoryOperationException;
import javax.jcr.ValueFactory;
import javax.jcr.Workspace;
import javax.jcr.lock.LockException;
import javax.jcr.nodetype.ConstraintViolationException;
import javax.jcr.retention.RetentionManager;
import javax.jcr.security.AccessControlManager;
import javax.jcr.version.VersionException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.AccessControlException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Simple implementation of an {@link Session}
 */
@SuppressWarnings("DuplicateThrows")
public class SessionImpl implements Session {
    private final Repository repository;
    private final Map<String, ItemImpl> itemStore = new HashMap<>();
    private boolean isLive = true;

    private Set<String> addedItems = new HashSet<>();
    private Set<String> changedItems = new HashSet<>();

    private Workspace workspace = null;


    @Override
    public Repository getRepository() {
        return repository;
    }


    @Override
    public String getUserID() {
        return null;
    }


    @Override
    public String[] getAttributeNames() {
        return new String[0];
    }


    @Override
    public Object getAttribute(String name) {
        return null;
    }

<commit_msg>Preserve the order of nodes in the repository to match the order they were created, so that tests can count on node order when using functions such as page.listChildren() or node.getNodes()<commit_after>/*
 * Copyright 2015 Time Warner Cable, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.twcable.jackalope.impl.jcr;

import com.twcable.jackalope.impl.common.Paths;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;

import javax.annotation.Nonnull;
import javax.jcr.Credentials;
import javax.jcr.InvalidSerializedDataException;
import javax.jcr.Item;
import javax.jcr.ItemExistsException;
import javax.jcr.ItemNotFoundException;
import javax.jcr.LoginException;
import javax.jcr.NamespaceException;
import javax.jcr.Node;
import javax.jcr.PathNotFoundException;
import javax.jcr.Property;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.UnsupportedRepositoryOperationException;
import javax.jcr.ValueFactory;
import javax.jcr.Workspace;
import javax.jcr.lock.LockException;
import javax.jcr.nodetype.ConstraintViolationException;
import javax.jcr.retention.RetentionManager;
import javax.jcr.security.AccessControlManager;
import javax.jcr.version.VersionException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.AccessControlException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Simple implementation of an {@link Session}
 */
@SuppressWarnings("DuplicateThrows")
public class SessionImpl implements Session {
    private final Repository repository;
    private final Map<String, ItemImpl> itemStore = new LinkedHashMap<>();
    private boolean isLive = true;

    private Set<String> addedItems = new LinkedHashSet<>();
    private Set<String> changedItems = new LinkedHashSet<>();

    private Workspace workspace = null;


    @Override
    public Repository getRepository() {
        return repository;
    }


    @Override
    public String getUserID() {
        return null;
    }


    @Override
    public String[] getAttributeNames() {
        return new String[0];
    }


    @Override
    public Object getAttribute(String name) {
        return null;
    }


{'fraction_non_alphanumeric': 0.08846222860218912, 'fraction_numerical': 0.0032298582451103534, 'mean_word_length': 4.459353574926543, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6270812', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1534, 'n_words': 480}