<commit_before>/*
 * Copyright 2005 JBoss 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 org.drools.guvnor.server;

import com.google.gwt.user.client.rpc.SerializationException;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.drools.guvnor.server.standalonededitor.BRLRuleAssetProvider;
import org.drools.guvnor.server.standalonededitor.NewRuleAssetProvider;
import org.drools.guvnor.server.standalonededitor.RuleAssetProvider;
import org.drools.guvnor.server.standalonededitor.UUIDRuleAssetProvider;
import org.drools.ide.common.client.modeldriven.brl.RuleModel;
import org.drools.ide.common.server.util.BRLPersistence;
import org.drools.ide.common.server.util.BRXMLPersistence;
import org.drools.repository.RulesRepository;

import javax.servlet.http.HttpSession;
import java.util.Map;
import java.util.UUID;
import javax.inject.Inject;
import org.drools.guvnor.client.rpc.*;
import org.drools.guvnor.server.util.LoggingHelper;

/**
 * All the needed Services in order to get Guvnor's Editors running as standalone
 * app.
 */
public class StandaloneEditorServiceImplementation extends RemoteServiceServlet
        implements
        StandaloneEditorService {

    private static final LoggingHelper log = LoggingHelper.getLogger(StandaloneEditorServiceImplementation.class);
    
    @Inject
    public RulesRepository repository;

    @Inject
    private ServiceImplementation serviceImplementation;
    
    @Inject
    private RepositoryAssetService repositoryAssetService;
    
    private static final long serialVersionUID = 530l;

    public RulesRepository getRulesRepository() {
        return this.repository;
    }

    public StandaloneEditorInvocationParameters getInvocationParameters(String parametersUUID) throws DetailedSerializationException {

        HttpSession session = this.getThreadLocalRequest().getSession();

        try {
            //Get the parameters from the session
            @SuppressWarnings("unchecked")
            Map<String, Object> sessionParameters = (Map<String, Object>) session.getAttribute(parametersUUID);

            if (sessionParameters == null || sessionParameters.isEmpty()) {
                throw new DetailedSerializationException("Error initializing Guided Editor",
                        "No initial parameters were supplied");
            }

            boolean hideLHSInEditor = isHideLHSInEditor(sessionParameters);
            boolean hideRHSInEditor = isHideRHSInEditor(sessionParameters);
            boolean hideAttributesInEditor = isHideAttributesInEditor(sessionParameters);
            String clientName = getClientName(sessionParameters);
            
            RuleAsset[] activeWorkingSets = getActiveWorkingSets(sessionParameters);
            RuleAsset[] activeTemporalWorkingSets = getActiveTemporalWorkingSets(sessionParameters);
            
            StandaloneEditorInvocationParameters invocationParameters = new StandaloneEditorInvocationParameters();
            this.loadRuleAssetsFromSessionParameters(sessionParameters,
                    invocationParameters);
            invocationParameters.setHideLHS(hideLHSInEditor);<commit_msg>- Removed unused method. The method was also violating dependency injection principle<commit_after>/*
 * Copyright 2005 JBoss 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 org.drools.guvnor.server;

import com.google.gwt.user.client.rpc.SerializationException;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.drools.guvnor.server.standalonededitor.BRLRuleAssetProvider;
import org.drools.guvnor.server.standalonededitor.NewRuleAssetProvider;
import org.drools.guvnor.server.standalonededitor.RuleAssetProvider;
import org.drools.guvnor.server.standalonededitor.UUIDRuleAssetProvider;
import org.drools.ide.common.client.modeldriven.brl.RuleModel;
import org.drools.ide.common.server.util.BRLPersistence;
import org.drools.ide.common.server.util.BRXMLPersistence;
import org.drools.repository.RulesRepository;

import javax.servlet.http.HttpSession;
import java.util.Map;
import java.util.UUID;
import javax.inject.Inject;
import org.drools.guvnor.client.rpc.*;
import org.drools.guvnor.server.util.LoggingHelper;

/**
 * All the needed Services in order to get Guvnor's Editors running as standalone
 * app.
 */
public class StandaloneEditorServiceImplementation extends RemoteServiceServlet
        implements
        StandaloneEditorService {

    private static final LoggingHelper log = LoggingHelper.getLogger(StandaloneEditorServiceImplementation.class);
    
    @Inject
    public RulesRepository repository;

    @Inject
    private ServiceImplementation serviceImplementation;
    
    @Inject
    private RepositoryAssetService repositoryAssetService;
    
    private static final long serialVersionUID = 530l;

    public StandaloneEditorInvocationParameters getInvocationParameters(String parametersUUID) throws DetailedSerializationException {

        HttpSession session = this.getThreadLocalRequest().getSession();

        try {
            //Get the parameters from the session
            @SuppressWarnings("unchecked")
            Map<String, Object> sessionParameters = (Map<String, Object>) session.getAttribute(parametersUUID);

            if (sessionParameters == null || sessionParameters.isEmpty()) {
                throw new DetailedSerializationException("Error initializing Guided Editor",
                        "No initial parameters were supplied");
            }

            boolean hideLHSInEditor = isHideLHSInEditor(sessionParameters);
            boolean hideRHSInEditor = isHideRHSInEditor(sessionParameters);
            boolean hideAttributesInEditor = isHideAttributesInEditor(sessionParameters);
            String clientName = getClientName(sessionParameters);
            
            RuleAsset[] activeWorkingSets = getActiveWorkingSets(sessionParameters);
            RuleAsset[] activeTemporalWorkingSets = getActiveTemporalWorkingSets(sessionParameters);
            
            StandaloneEditorInvocationParameters invocationParameters = new StandaloneEditorInvocationParameters();
            this.loadRuleAssetsFromSessionParameters(sessionParameters,
                    invocationParameters);
            invocationParameters.setHideLHS(hideLHSInEditor);
{'fraction_non_alphanumeric': 0.0721072497722244, 'fraction_numerical': 0.0028634647923988024, 'mean_word_length': 3.9542230818826565, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, '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': '4632829', 'n_tokens_mistral': 1944, 'n_tokens_neox': 1914, 'n_words': 485}