Skip to content
Snippets Groups Projects
Commit 0cd10b14 authored by Guillaume Delhumeau's avatar Guillaume Delhumeau
Browse files

XWIKI-12071: Introduce a flavor manager.

parent 61242824
No related branches found
No related tags found
No related merge requests found
Showing
with 373 additions and 0 deletions
......@@ -543,6 +543,7 @@
<module>xwiki-platform-feed</module>
<module>xwiki-platform-filter</module>
<module>xwiki-platform-flamingo</module>
<module>xwiki-platform-flavor</module>
<module>xwiki-platform-formula</module>
<module>xwiki-platform-git</module>
<module>xwiki-platform-groovy</module>
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-core</artifactId>
<version>7.1-SNAPSHOT</version>
</parent>
<artifactId>xwiki-platform-flavor</artifactId>
<packaging>pom</packaging>
<name>XWiki Platform - Flavor</name>
<modules>
<module>xwiki-platform-flavor-api</module>
</modules>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!--
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-flavor</artifactId>
<version>7.1-SNAPSHOT</version>
</parent>
<artifactId>xwiki-platform-flavor-api</artifactId>
<name>XWiki Platform - Flavor - API</name>
<packaging>jar</packaging>
<description>API to get flavors from the repositories.</description>
<dependencies>
<dependency>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-extension-api</artifactId>
<version>${commons.version}</version>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-repository-server-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.platform.flavor;
import org.xwiki.component.annotation.Role;
import org.xwiki.extension.Extension;
import org.xwiki.extension.repository.result.IterableResult;
/**
* Find the flavors into the repositories, applying filters according to the configuration.
*
* @version $Id$
* @since 7.1M2
*/
@Role
public interface FlavorManager
{
/**
* Get all flavors matching a query.
* @param query query to execute
* @return flavors matching the query
*/
IterableResult<Extension> getFlavors(FlavorQuery query);
}
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.platform.flavor;
import org.xwiki.extension.repository.search.ExtensionQuery;
import org.xwiki.repository.internal.XWikiRepositoryModel;
import org.xwiki.stability.Unstable;
/**
* A query to an extension repository returning only flavors.
*
* @version $Id$
* @since 7.1M2
*/
@Unstable
public class FlavorQuery extends ExtensionQuery
{
/**
* No filtering. Usually return all flavors.
*/
public FlavorQuery()
{
super();
init();
}
/**
* @param query the query to execute
*/
public FlavorQuery(String query)
{
super(query);
init();
}
/**
* @param query the query to duplicate
*/
public FlavorQuery(ExtensionQuery query)
{
super(query);
init();
}
private void init()
{
addFilter(XWikiRepositoryModel.PROP_EXTENSION_CATEGORY, "flavor", ExtensionQuery.COMPARISON.EQUAL);
// A flavor must be a XAR, but we add this filter to be extra-sure (someone could have filled bad values in
// the repository)
addFilter(XWikiRepositoryModel.PROP_EXTENSION_TYPE, "xar", ExtensionQuery.COMPARISON.EQUAL);
}
/**
* Add a filter on the flavors' name.
* @param name name of the flavor to find
*/
public void filterByName(String name)
{
addFilter(XWikiRepositoryModel.PROP_EXTENSION_NAME, name, COMPARISON.MATCH);
}
/**
* Add a filter on the flavors' summary.
* @param summary a summary to find on the extension repository
*/
public void filterBySummary(String summary)
{
addFilter(XWikiRepositoryModel.PROP_EXTENSION_SUMMARY, summary, COMPARISON.MATCH);
}
/**
* Order the results by name.
* @param order asc or desc
*/
public void orderByName(ORDER order)
{
addSort(XWikiRepositoryModel.PROP_EXTENSION_NAME, order);
}
/**
* Order the results by rating.
* @param order asc or desc
*/
public void orderByRating(ORDER order)
{
addSort(XWikiRepositoryModel.PROP_RATING_AVERAGEVOTE, order);
}
}
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.platform.flavor.internal;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.xwiki.component.annotation.Component;
import org.xwiki.extension.Extension;
import org.xwiki.extension.repository.ExtensionRepositoryManager;
import org.xwiki.extension.repository.result.IterableResult;
import org.xwiki.platform.flavor.FlavorManager;
import org.xwiki.platform.flavor.FlavorQuery;
/**
* Default implementation of {@link org.xwiki.platform.flavor.FlavorManager}.
*
* @version $Id$
* @since 7.1M2
*/
@Component
@Singleton
public class DefaultFlavorManager implements FlavorManager
{
@Inject
private ExtensionRepositoryManager extensionRepositoryManager;
@Override
public IterableResult<Extension> getFlavors(FlavorQuery query)
{
return extensionRepositoryManager.search(query);
}
}
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.platform.flavor.script;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.xwiki.component.annotation.Component;
import org.xwiki.extension.Extension;
import org.xwiki.extension.repository.result.IterableResult;
import org.xwiki.platform.flavor.FlavorManager;
import org.xwiki.platform.flavor.FlavorQuery;
import org.xwiki.script.service.ScriptService;
import org.xwiki.stability.Unstable;
/**
* Script service to find flavors.
*
* @version $Id$
* @since 7.1M2
*/
@Component
@Named("flavor")
@Singleton
@Unstable
public class FlavorManagerScriptService implements ScriptService
{
@Inject
private FlavorManager flavorManager;
/**
* Creates a flavor query.
* @return a new flavor query
*/
public FlavorQuery createFlavorQuery()
{
return new FlavorQuery();
}
/**
* Get all flavors matching a query.
* @param query query to execute
* @return flavors matching the query
*/
public IterableResult<Extension> getFlavors(FlavorQuery query)
{
return flavorManager.getFlavors(query);
}
}
# ---------------------------------------------------------------------------
# See the NOTICE file distributed with this work for additional
# information regarding copyright ownership.
#
# This is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this software; if not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
# ---------------------------------------------------------------------------
flavor.selector.noflavor=No flavor, let the wiki empty.
flavor.selector.authorsBy=By
flavor.selector.website=Website
flavor.selector.ajaxError=Connexion error. Failed to get the list of flavors.
\ No newline at end of file
org.xwiki.platform.flavor.internal.DefaultFlavorManager
org.xwiki.platform.flavor.script.FlavorManagerScriptService
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment