<commit_before>/*******************************************************************************
 * Copyright (c) 2012-2016 Codenvy, S.A.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Codenvy, S.A. - initial API and implementation
 *******************************************************************************/
package org.eclipse.che.api.project.server.type;

import com.google.inject.Singleton;

import org.eclipse.che.api.core.ConflictException;
import org.eclipse.che.api.core.ForbiddenException;
import org.eclipse.che.api.core.NotFoundException;
import org.eclipse.che.api.core.ServerException;
import org.eclipse.che.api.project.server.FolderEntry;
import org.eclipse.che.api.project.server.ProjectRegistry;
import org.eclipse.che.api.project.server.handlers.ProjectInitHandler;

import java.util.List;

/**
 * Set {@link BaseProjectType} for all sub-projects.
 *
 * @author <NAME>
 */
@Singleton
public class InitBaseProjectTypeHandler implements ProjectInitHandler {

    @Override
    public String getProjectType() {
        return BaseProjectType.ID;
    }

    @Override
    public void onProjectInitialized(ProjectRegistry projectRegistry, FolderEntry projectFolder) throws ServerException,
                                                                                                        ForbiddenException,
                                                                                                        ConflictException,
                                                                                                        NotFoundException {
        List<String> projects = projectRegistry.getProjects(projectFolder.getPath().toString());
        for (String project : projects) {
            projectRegistry.setProjectType(project, BaseProjectType.ID, false);
        }
    }
}<commit_msg>CODENVY-365: base project initializer should change only detected projects<commit_after>/*******************************************************************************
 * Copyright (c) 2012-2016 Codenvy, S.A.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Codenvy, S.A. - initial API and implementation
 *******************************************************************************/
package org.eclipse.che.api.project.server.type;

import com.google.inject.Singleton;

import org.eclipse.che.api.core.ConflictException;
import org.eclipse.che.api.core.ForbiddenException;
import org.eclipse.che.api.core.NotFoundException;
import org.eclipse.che.api.core.ServerException;
import org.eclipse.che.api.project.server.FolderEntry;
import org.eclipse.che.api.project.server.ProjectRegistry;
import org.eclipse.che.api.project.server.RegisteredProject;
import org.eclipse.che.api.project.server.handlers.ProjectInitHandler;

import java.util.List;

/**
 * Set {@link BaseProjectType} for all sub-projects.
 *
 * @author <NAME>
 */
@Singleton
public class InitBaseProjectTypeHandler implements ProjectInitHandler {

    @Override
    public String getProjectType() {
        return BaseProjectType.ID;
    }

    @Override
    public void onProjectInitialized(ProjectRegistry projectRegistry, FolderEntry projectFolder) throws ServerException,
                                                                                                        ForbiddenException,
                                                                                                        ConflictException,
                                                                                                        NotFoundException {
        List<String> projects = projectRegistry.getProjects(projectFolder.getPath().toString());
        for (String project : projects) {
            RegisteredProject detected = projectRegistry.getProject(project);
            if (detected.isDetected()) {
                projectRegistry.setProjectType(project, BaseProjectType.ID, false);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.14888735948612067, 'fraction_numerical': 0.006194081211286993, 'mean_word_length': 2.3956386292834893, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5837669', 'n_tokens_mistral': 994, 'n_tokens_neox': 948, 'n_words': 225}