001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.convert;
016    
017    import com.liferay.portal.kernel.exception.SystemException;
018    import com.liferay.registry.Registry;
019    import com.liferay.registry.RegistryUtil;
020    
021    import java.util.ArrayList;
022    import java.util.Collection;
023    import java.util.Iterator;
024    
025    /**
026     * @author Iv??n Zaera
027     */
028    public class ConvertProcessUtil {
029    
030            public static Collection<ConvertProcess> getConvertProcesses() {
031                    try {
032                            Registry registry = RegistryUtil.getRegistry();
033    
034                            return registry.getServices(ConvertProcess.class, null);
035                    }
036                    catch (Exception e) {
037                            throw new SystemException(e);
038                    }
039            }
040    
041            public static Collection<ConvertProcess> getEnabledConvertProcesses() {
042                    Collection<ConvertProcess> convertProcesses = new ArrayList<>(
043                            getConvertProcesses());
044    
045                    Iterator<ConvertProcess> iterator = convertProcesses.iterator();
046    
047                    while (iterator.hasNext()) {
048                            ConvertProcess convertProcess = iterator.next();
049    
050                            if (!convertProcess.isEnabled()) {
051                                    iterator.remove();
052                            }
053                    }
054    
055                    return convertProcesses;
056            }
057    
058    }