Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
systemsmanagement:Uyuni:Master
spacewalk-search
spacewalk-search-git-0.5949a9b.obscpio
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File spacewalk-search-git-0.5949a9b.obscpio of Package spacewalk-search
07070100000000000041FD0000000000000000000000056615495400000000000000000000000000000000000000000000001100000000spacewalk-search07070100000001000081B40000000000000000000000016615495400000347000000000000000000000000000000000000002100000000spacewalk-search/Makefile.pythonTHIS_MAKEFILE := $(realpath $(lastword $(MAKEFILE_LIST))) CURRENT_DIR := $(dir $(THIS_MAKEFILE)) include $(CURRENT_DIR)../../rel-eng/Makefile.python # Docker tests variables DOCKER_CONTAINER_BASE = uyuni-master DOCKER_REGISTRY = registry.mgr.suse.de DOCKER_RUN_EXPORT = "PYTHONPATH=$PYTHONPATH" DOCKER_VOLUMES = -v "$(CURDIR)/../../:/manager" __pylint :: $(call update_pip_env) pylint --rcfile=pylintrc $(shell find -name '*.py') > reports/pylint.log || true docker_pylint :: docker run --rm -e $(DOCKER_RUN_EXPORT) $(DOCKER_VOLUMES) $(DOCKER_REGISTRY)/$(DOCKER_CONTAINER_BASE)-pgsql /bin/sh -c "cd /manager/search-server/spacewalk-search; make -f Makefile.python __pylint" docker_shell :: docker run -t -i --rm -e $(DOCKER_RUN_EXPORT) $(DOCKER_VOLUMES) $(DOCKER_REGISTRY)/$(DOCKER_CONTAINER_BASE)-pgsql /bin/bash 07070100000002000081B40000000000000000000000016615495400000330000000000000000000000000000000000000001800000000spacewalk-search/READMEsearch-server is the new server used to search packages, and ultimately all content including systems, errata, and documentation. build.properties - build configuration build.xml - master ant build script buildconf/exclude - list of files excluded from compilation (temp solution) buildconf/build-utils.xml - ant macro definitions checkstyle.xml - checkstyle code style definition ivy.xml - ivy repo configuration file libsrc - src code for the libraries used nutch - configuration files for nutch crawler (not currently used) spacewalk-search.spec - search server RPM spec file rhn_search_daemon_dev.conf - development based configuration file run.sh - script used to run the software, especially during development scripts - useful scripts src - the source code task-lib - the libraries used by the search-server 07070100000003000081B40000000000000000000000016615495400000247000000000000000000000000000000000000002200000000spacewalk-search/build.propertiesjava.src.dir=src/java config.src.dir=src/config java.lib.dir=lib java.task.lib.dir=task-lib report.dir=report build.dir=build build.instrument.dir=instrumented dist.dir=dist jar.name=spacewalk-search jar.version=1.0 jar.file.name=${jar.name}-${jar.version}.jar ivyserver= http://partha.fedorapeople.org ivy.log.module.when.found=false ivy.log.resolved.revision=false # Checkstyle config entries checkstyle.cache.file=.checkstyle_cache checkstyle.header.file=./buildconf/LICENSE.txt javadoc.method.scope=public javadoc.type.scope=package javadoc.var.scope=package javadoc.lazy=true 07070100000004000081B40000000000000000000000016615495400001F73000000000000000000000000000000000000001B00000000spacewalk-search/build.xml<project name="search-server" basedir="." default="all"> <condition property="java_libdir" value="${JAVA_LIBDIR}" else="/usr/share/java"> <isset property="JAVA_LIBDIR"/> </condition> <import file="buildconf/build-utils.xml" /> <import file="buildconf/build-props.xml" /> <property file="build.properties" /> <property name="deploy.host" value="deployhost" /> <property name="deploy.port" value="22" /> <property name="deploy.dir" value="/usr/share/rhn/search/lib" /> <property name="deploy.user" value="root" /> <property name="ssh.socket.file" value="${user.home}/.ssh/manager-build-tunnel-${deploy.host}-${deploy.user}"/> <property name="ssh.socket.option" value="-o ControlPath=${ssh.socket.file}"/> <property name="ssh.command.args" value="${ssh.socket.option} -p ${deploy.port} ${deploy.user}@${deploy.host}"/> <property name="rsync.arg.rsh" value="ssh ${ssh.socket.option} -p ${deploy.port}"/> <path id="project.classpath"> <fileset dir="${java.lib.dir}" includes="**/*.jar" /> </path> <path id="test.classpath"> <pathelement location="${build.dir}" /> <path refid="project.classpath" /> <pathelement location="${basedir}/src/config" /> </path> <target name="init-ivy" unless="installbuild"> <mkdir dir="${java.lib.dir}" /> <jpackage-deps jars="ivy" dir="${java.lib.dir}" /> <taskdef name="ivy-retrieve" classname="org.apache.ivy.ant.IvyRetrieve"/> </target> <target name="make-eclipse-project" depends="resolve-ivy" description="Generate eclipse project files"> <copy file="buildconf/eclipse.project" tofile=".project" /> <copy file="buildconf/eclipse.classpath" tofile=".classpath" /> <copy toDir="${basedir}"> <fileset dir="${basedir}/../../java/conf/eclipse"> <include name=".checkstyle"/> <include name=".settings/*"/> </fileset> </copy> </target> <target name="check-testcase-name" if="testcase" depends=""> <propertyregex property="valid.testcase" input="${testcase}" regexp="(.*)Test$" select="\1" casesensitive="true" /> </target> <target name="check-testcase" depends="check-testcase-name" if="testcase" unless="valid.testcase"> <fail message="Invalid testcase name: ${testcase}. Class name must look like .*Test"/> </target> <target name="test" depends="compile, check-testcase" description="Run the tests (use -Dtestcase=<testcase>)"> <mkdir dir="${report.dir}" /> <!-- set testcase to wildcard "*" to test everything, unless a specific testcase name was supplied. --> <if> <not> <isset property="${testcase}" /> </not> <then> <property name="testcase" value="*Test"/> </then> </if> <junit> <sysproperty key="rhn.config.dir" value="/etc/rhn" /> <sysproperty key="search.config.dir" value="src/config/search" /> <sysproperty key="log4j2.configuration" value="log4j2.test.xml" /> <classpath refid="test.classpath" /> <formatter type="brief" usefile="false" /> <formatter type="xml" /> <batchtest fork="yes" todir="${report.dir}"> <fileset dir="${build.dir}" includes="**/${testcase}.class" /> </batchtest> </junit> </target> <target name="resolve-local" description="resolve jars via jpackage" if="installbuild"> <jpackage-deps jars="${jpackage.jars}" dir="${java.lib.dir}" /> </target> <target name="obs-to-maven" description="Updates local maven repository with OBS jars" unless="installbuild"> <exec failonerror="true" executable="obs-to-maven"> <arg line="${basedir}/buildconf/obs-maven-config.yaml ${basedir}/buildconf/repository" /> </exec> </target> <target name="resolve-ivy" description="retrieve dependencies with ivy" depends="init-ivy,obs-to-maven" unless="installbuild"> <!-- properties set here to show we are overriding default ivy values --> <property name="ivy.default.ivy.user.dir" value="${user.home}/.ivy/search-server"/> <property name="ivy.local.default.artifact.pattern" value="[artifact]-[revision].[ext]" /> <property name="ivy.ivyrep.default.ivy.root" value="${ivyserver}/ivy/" /> <property name="ivy.ivyrep.default.artifact.root" value="${ivyserver}/ivy/" /> <property name="ivy.ivyrep.default.artifact.pattern" value="[artifact]-[revision].[ext]" /> <ivy-retrieve/> </target> <target name="resolve" depends="resolve-ivy,resolve-local" /> <target name="prep"> <mkdir dir="${build.dir}" /> <mkdir dir="${dist.dir}" /> <mkdir dir="${java.lib.dir}" /> </target> <target name="clean"> <delete dir="${build.dir}" /> <delete dir="${build.instrument.dir}" /> <delete dir="${dist.dir}" /> <delete dir="${java.lib.dir}" /> <delete dir="${report.dir}" /> <delete file="coverage.ec" /> <delete file="rhn_search_daemon.log" /> </target> <target name="compile" depends="prep, resolve"> <javac srcdir="${java.src.dir}" classpathref="project.classpath" destdir="${build.dir}" deprecation="on" excludesfile="buildconf/exclude" debug="on"> <compilerarg value="-Xlint:unchecked" /> </javac> <copy todir="${build.dir}/com/redhat/satellite/search/db"> <fileset dir="${config.src.dir}/com/redhat/satellite/search/db/"> <include name="*.xml" /> </fileset> </copy> <copy file="${config.src.dir}/quartz.properties" todir="${build.dir}" /> </target> <target name="package" depends="compile"> <jar basedir="${build.dir}" destfile="${dist.dir}/${jar.file.name}" excludes="**/tests/**" includes="**/**" /> </target> <target name="create-local-repo" description="Create a local Ivy repo"> <mkdir dir="${user.home}/.ivy/search-server/local/" /> </target> <target name="clean-cache" description="Removes the Ivy jar cache"> <delete dir="${lib.dir}" quiet="true" /> <delete dir="${user.home}/.ivy/search-server/cache/" quiet="true" /> </target> <target name="all" depends="package" /> <target name="init-install"> <property name="installbuild" value="true"/> </target> <target name="install" depends="init-install,package" /> <target name="check-ssh-socket"> <available file="${ssh.socket.file}" property="ssh-socket.present"/> </target> <target name="open-ssh-socket" depends="check-ssh-socket" unless="ssh-socket.present"> <exec executable="ssh"> <arg line="-M -f -N -C ${ssh.command.args}" /> </exec> </target> <target name="deploy" depends="open-ssh-socket" description="Deploy a new copy of SUSE Manager"> <echo message="Copying files to remote host..." /> <exec failonerror="true" executable="rsync"> <arg line="-a --rsh '${rsync.arg.rsh}' ${dist.dir}/ ${deploy.user}@${deploy.host}:${deploy.dir}/" /> </exec> <exec failonerror="true" executable="ssh"> <arg line="${ssh.command.args} ln -sf ${deploy.dir}/${jar.file.name} /usr/share/rhn/search/lib/spacewalk-search.jar"/> </exec> </target> <target name="restart-rhn-search" depends="open-ssh-socket" description="Restart the rhn-search process"> <echo message="Launching rhn-search restart..."/> <exec executable="ssh"> <arg line="${ssh.command.args} nohup rcrhn-search restart > /dev/null 2>&1 &"/> </exec> </target> <target name="deploy-restart" depends="deploy, restart-rhn-search" /> </project> 07070100000005000041FD0000000000000000000000026615495400000000000000000000000000000000000000000000001B00000000spacewalk-search/buildconf07070100000006000081B40000000000000000000000016615495400000275000000000000000000000000000000000000002700000000spacewalk-search/buildconf/LICENSE.txt/** * Copyright (c) 2008--2010 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ 07070100000007000081B400000000000000000000000166154954000003E4000000000000000000000000000000000000002B00000000spacewalk-search/buildconf/build-props.xml<project name="build-props"> <available file="${java_libdir}/log4j/log4j-core.jar" type="file" property="log4j-core" value="log4j/log4j-core" /> <available file="${java_libdir}/log4j/log4j-api.jar" type="file" property="log4j-api" value="log4j/log4j-api" /> <property name="log4j-jars" value="${log4j-core} ${log4j-api}"/> <property name="ivy.settings.file" value="buildconf/ivyconf.xml" /> <property name="c3p0" value="c3p0"/> <available file="${java_libdir}/mchange-commons/mchange-commons-java.jar" type="file" property="c3p0" value="${c3p0} mchange-commons/mchange-commons-java"/> <property name="jpackage.jars" value="${c3p0} cglib commons-cli commons-codec commons-lang3 commons-logging ${log4j-jars} objectweb-asm/asm oro quartz redstone-xmlrpc redstone-xmlrpc-client simple-core slf4j/api slf4j/simple junit picocontainer lucene lucene-analyzers lucene-misc mybatis javassist apache-commons-ognl" /> </project> 07070100000008000081B40000000000000000000000016615495400000227000000000000000000000000000000000000002B00000000spacewalk-search/buildconf/build-utils.xml<project name="build-utils.xml"> <!-- creates symlinks for jpackage jars requires: jpackage-utils other: requires rpms of the jars specified to be installed --> <macrodef name="jpackage-deps"> <attribute name="jars" /> <attribute name="dir" /> <sequential> <exec executable="build-jar-repository" failonerror="true" > <arg value="--preserve-naming" /> <arg value="-s @{dir}" /> <arg line="@{jars}" /> </exec> </sequential> </macrodef> </project> 07070100000009000081B400000000000000000000000166154954000003C6000000000000000000000000000000000000002D00000000spacewalk-search/buildconf/eclipse.classpath<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src/java"/> <classpathentry kind="src" path="src/config"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> <attributes> <attribute name="module" value="true"/> </attributes> </classpathentry> <classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=spacewalk-search&ivyXmlPath=ivy.xml&confs=*&ivySettingsPath=buildconf%2Fivyconf.xml&loadSettingsOnDemand=false&ivyUserDir=&propertyFiles=&acceptedTypes=jar%2Cbundle%2Cejb%2Cmaven-plugin&alphaOrder=false&resolveInWorkspace=false&transitiveResolve=true&readOSGiMetadata=false&retrievedClasspath=true&retrievedClasspathPattern=lib%2F%5Bartifact%5D-%5Brevision%5D.%5Bext%5D&retrievedClasspathSync=true&retrievedClasspathTypes=jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> 0707010000000A000081B40000000000000000000000016615495400000177000000000000000000000000000000000000002B00000000spacewalk-search/buildconf/eclipse.project<?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>spacewalk-search</name> <comment></comment> <projects> </projects> <buildSpec> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> </natures> </projectDescription> 0707010000000B000081B40000000000000000000000016615495400000000000000000000000000000000000000000000002300000000spacewalk-search/buildconf/exclude0707010000000C000081B400000000000000000000000166154954000001B2000000000000000000000000000000000000002700000000spacewalk-search/buildconf/ivyconf.xml<ivysettings> <settings defaultResolver="central" /> <resolvers> <filesystem name="suse" m2compatible="true" local="true"> <artifact pattern="${ivy.conf.dir}/repository/[organization]/[artifact]/[revision]/[artifact]-[revision].[ext]" /> </filesystem> <ibiblio name="central" m2compatible="true"/> </resolvers> <modules> <module organisation="suse" name="*" resolver="suse"/> </modules> </ivysettings> 0707010000000D000081B40000000000000000000000016615495400000558000000000000000000000000000000000000003100000000spacewalk-search/buildconf/obs-maven-config.yamlrepositories: Leap: project: openSUSE:Leap:15.4 repository: standard Uyuni_Other: project: systemsmanagement:Uyuni:Master:Other repository: openSUSE_Leap_15.4 Uyuni: project: systemsmanagement:Uyuni:Master repository: openSUSE_Leap_15.4 artifacts: - artifact: simple-core # How comes that package is not noarch? arch: x86_64 repository: Uyuni_Other - artifact: lucene-core jar: lucene-core package: lucene repository: Uyuni_Other - artifact: lucene-analyzers jar: lucene-analyzers package: lucene repository: Uyuni_Other - artifact: commons-lang3 package: apache-commons-lang3 repository: Leap - artifact: commons-logging package: apache-commons-logging jar: apache-commons-logging\.jar repository: Leap - artifact: redstone-xmlrpc jar: redstone-xmlrpc-[0-9.]+ repository: Uyuni_Other - artifact: mybatis package: mybatis repository: Uyuni_Other - artifact: quartz repository: Uyuni_Other - artifact: log4j-core jar: log4j-core.jar package: log4j repository: Leap - artifact: log4j-api jar: log4j-api.jar package: log4j repository: Leap - artifact: c3p0 repository: Leap - artifact: mchange-commons-java package: mchange-commons repository: Leap - artifact: picocontainer repository: Uyuni_Other 0707010000000E000081B40000000000000000000000016615495400002650000000000000000000000000000000000000002000000000spacewalk-search/checkstyle.xml<?xml version="1.0"?> <!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.1//EN" "http://www.puppycrawl.com/dtds/configuration_1_1.dtd"> <!-- Checkstyle configuration that checks the sun coding conventions from: - the Java Language Specification at http://java.sun.com/docs/books/jls/second_edition/html/index.html - the Sun Code Conventions at http://java.sun.com/docs/codeconv/ - the Javadoc guidelines at http://java.sun.com/j2se/javadoc/writingdoccomments/index.html - the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html - some best practices Checkstyle is very configurable. Be sure to read the documentation at http://checkstyle.sf.net (or in your downloaded distribution). Most Checks are configurable, be sure to consult the documentation. To completely disable a check, just comment it out or delete it from the file. Finally, it is worth reading the documentation. --> <module name="Checker"> <!-- Checks that a package.html file exists for each package. --> <!-- See http://checkstyle.sf.net/config_javadoc.html#PackageHtml --> <!-- <module name="PackageHtml"/> --> <!-- Checks whether files end with a new line. --> <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile --> <module name="NewlineAtEndOfFile"/> <!-- Checks that property files contain the same keys. --> <!-- See http://checkstyle.sf.net/config_misc.html#Translation --> <module name="Translation"/> <module name="TreeWalker"> <property name="cacheFile" value="${checkstyle.cache.file}"/> <!-- ************************************************************** --> <!-- Checks that are different from the sun coding conventions ones --> <!-- ************************************************************** --> <property name="tabWidth" value="4"/> <module name="LeftCurly" /> <module name="RightCurly"> <property name="option" value="alone"/> </module> <module name="LineLength"> <property name="ignorePattern" value="import"/> <property name="max" value="92"/> </module> <!-- ************************************************************** --> <!-- Default Sun coding conventions checks --> <!-- ************************************************************** --> <!-- Checks for Javadoc comments. --> <!-- See http://checkstyle.sf.net/config_javadoc.html --> <module name="JavadocMethod"> <property name="scope" value="${javadoc.method.scope}" /> <property name="allowUndeclaredRTE" value="true" /> <property name="allowThrowsTagsForSubclasses" value="${javadoc.lazy}" /> <property name="allowMissingParamTags" value="${javadoc.lazy}" /> <property name="allowMissingThrowsTags" value="${javadoc.lazy}" /> <property name="allowMissingReturnTag" value="${javadoc.lazy}" /> </module> <module name="JavadocType"> <property name="versionFormat" value="\$Rev.*\$"/> <property name="scope" value="${javadoc.type.scope}" /> </module> <module name="JavadocVariable"> <property name="scope" value="${javadoc.var.scope}" /> <property name="severity" value="ignore"/> </module> <!-- JavadocStyle not supported by some versions. --> <!-- <module name="JavadocStyle"/> --> <!-- Checks for Naming Conventions. --> <!-- See http://checkstyle.sf.net/config_naming.html --> <module name="ConstantName"/> <module name="LocalFinalVariableName"/> <module name="LocalVariableName"/> <module name="MethodName"/> <module name="PackageName"> <property name="format" value="^[a-z]+(\.[A-Za-z][A-Za-z0-9]*)*$"/> </module> <module name="ParameterName"/> <module name="StaticVariableName"/> <module name="TypeName"/> <!-- Checks for Headers --> <!-- See http://checkstyle.sf.net/config_header.html --> <module name="Header"> <!-- The follow property value demonstrates the ability --> <!-- to have access to ANT properties. In this case it uses --> <!-- the ${basedir} property to allow Checkstyle to be run --> <!-- from any directory within a project. --> <property name="headerFile" value="${checkstyle.header.file}"/> </module> <!-- Following interprets the header file as regular expressions. --> <!-- <module name="RegexpHeader"/> --> <!-- Checks for imports --> <!-- See http://checkstyle.sf.net/config_import.html --> <module name="AvoidStarImport"/> <module name="IllegalImport"/> <!-- defaults to sun.* packages --> <module name="RedundantImport"/> <module name="UnusedImports"/> <!-- Checks for Size Violations. --> <!-- See http://checkstyle.sf.net/config_sizes.html --> <module name="MethodLength"> <property name="tokens" value="METHOD_DEF"/> <property name="max" value="150"/> <property name="countEmpty" value="false"/> </module> <module name="ParameterNumber"/> <!-- Checks for whitespace --> <!-- See http://checkstyle.sf.net/config_whitespace.html --> <module name="EmptyForIteratorPad"/> <module name="NoWhitespaceAfter"> <property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS, TYPECAST, GENERIC_START"/> </module> <module name="NoWhitespaceBefore"> <property name="tokens" value="SEMI, POST_DEC, POST_INC, GENERIC_START, GENERIC_END"/> </module> <module name="OperatorWrap"> <property name="option" value="eol" /> </module> <module name="ParenPad"/> <!-- <module name="TypecastParenPad"/> --> <module name="TabCharacter"/> <module name="WhitespaceAfter"> <property name="tokens" value="COMMA, SEMI, GENERIC_END"/> </module> <module name="WhitespaceAround"> <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN, TYPE_EXTENSION_AND, WILDCARD_TYPE"/> </module> <module name="MethodParamPad"> <property name="allowLineBreaks" value="true"/> </module> <!-- Modifier Checks --> <!-- See http://checkstyle.sf.net/config_modifiers.html --> <module name="ModifierOrder"/> <module name="RedundantModifier"/> <!-- Checks for blocks. You know, those {}'s --> <!-- See http://checkstyle.sf.net/config_blocks.html --> <module name="AvoidNestedBlocks"/> <module name="EmptyBlock"> <property name="option" value="text"/> </module> <module name="NeedBraces"/> <!-- Checks for common coding problems --> <!-- See http://checkstyle.sf.net/config_coding.html --> <!-- <module name="AvoidInlineConditionals"/> --> <!-- <module name="CovariantEquals"/> --> <module name="DoubleCheckedLocking"/> <!-- MY FAVOURITE --> <module name="EmptyStatement"/> <module name="EqualsHashCode"/> <module name="HiddenField"/> <module name="IllegalInstantiation"/> <module name="InnerAssignment"/> <!-- <module name="MagicNumber" /> --> <module name="MissingSwitchDefault"/> <!-- <module name="RedundantThrows"/> --> <module name="SimplifyBooleanExpression"/> <module name="SimplifyBooleanReturn"/> <!-- <module name="IllegalCatch"/> --> <!-- <module name="PackageDeclaration"/> --> <!-- Checks for class design --> <!-- See http://checkstyle.sf.net/config_design.html --> <!-- <module name="DesignForExtension"/>--> <!-- <module name="FinalClass"/> --> <module name="HideUtilityClassConstructor"/> <module name="InterfaceIsType"/> <module name="VisibilityModifier"> <property name="protectedAllowed" value="true" /> </module> <!-- Miscellaneous other checks. --> <!-- See http://checkstyle.sf.net/config_misc.html --> <module name="ArrayTypeStyle"/> <!-- <module name="FinalParameters"/> --> <!-- <module name="GenericIllegalRegexp"> <property name="format" value="System\.out\.println"/> </module> --> <module name="UpperEll"/> <!-- Optional Checks --> <!-- (gack, not available until version 3 of checkstyle --> <!-- <module name="usage.OneMethodPrivateField"/> <module name="usage.UnusedLocalVariable"/> <module name="usage.UnusedParameter"/> <module name="usage.UnusedPrivateField"/> --> </module> </module> 0707010000000F000081B40000000000000000000000016615495400000429000000000000000000000000000000000000001900000000spacewalk-search/ivy.xml<ivy-module version="1.0"> <info organisation="suse" module="manager" /> <dependencies> <dependency org="suse" name="simple-core" rev="3.1.3" /> <dependency org="suse" name="lucene-core" rev="2.4" /> <dependency org="suse" name="lucene-analyzers" rev="2.4" /> <dependency org="suse" name="commons-lang3" rev="3.8.1" /> <dependency org="suse" name="commons-logging" rev="1.2" /> <dependency org="suse" name="redstone-xmlrpc" rev="1.1_20071120" /> <dependency org="suse" name="mybatis" rev="3.5.6" /> <dependency org="suse" name="quartz" rev="2.3.0" /> <dependency org="suse" name="log4j-api" rev="2.17.1" /> <dependency org="suse" name="log4j-core" rev="2.17.1" /> <dependency org="suse" name="c3p0" rev="0.9.5.5" /> <dependency org="suse" name="mchange-commons-java" rev="0.2.20" /> <dependency org="suse" name="picocontainer" rev="1.3" /> <dependency org="junit" name="junit" rev="3.8.2" transitive="false"/> </dependencies> </ivy-module> 07070100000010000041FD0000000000000000000000026615495400000000000000000000000000000000000000000000001A00000000spacewalk-search/licenses07070100000011000081B40000000000000000000000016615495400002C5E000000000000000000000000000000000000002900000000spacewalk-search/licenses/apache-2.0.txt Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. 07070100000012000081B40000000000000000000000016615495400004643000000000000000000000000000000000000002600000000spacewalk-search/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. <signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. 07070100000013000081B4000000000000000000000001661549540000139E000000000000000000000000000000000000001A00000000spacewalk-search/pylintrc# spacewalk-search package pylint configuration [MASTER] # Profiled execution. profile=no # Pickle collected data for later comparisons. persistent=no [MESSAGES CONTROL] # Disable the message(s) with the given id(s). disable=I0011, C0302, C0111, R0801, R0902, R0903, R0904, R0912, R0913, R0914, R0915, R0921, R0922, W0142, W0403, W0603, C1001, W0121, useless-else-on-loop, bad-whitespace, unpacking-non-sequence, superfluous-parens, cyclic-import, redefined-variable-type, no-else-return, # Uyuni disabled E0203, E0611, E1101, E1102 # list of disabled messages: #I0011: 62: Locally disabling R0201 #C0302: 1: Too many lines in module (2425) #C0111: 1: Missing docstring #R0902: 19:RequestedChannels: Too many instance attributes (9/7) #R0903: Too few public methods #R0904: 26:Transport: Too many public methods (22/20) #R0912:171:set_slots_from_cert: Too many branches (59/20) #R0913:101:GETServer.__init__: Too many arguments (11/10) #R0914:171:set_slots_from_cert: Too many local variables (38/20) #R0915:171:set_slots_from_cert: Too many statements (169/50) #W0142:228:MPM_Package.write: Used * or ** magic #W0403: 28: Relative import 'rhnLog', should be 'backend.common.rhnLog' #W0603: 72:initLOG: Using the global statement # for pylint-1.0 we also disable #C1001: 46, 0: Old-style class defined. (old-style-class) #W0121: 33,16: Use raise ErrorClass(args) instead of raise ErrorClass, args. (old-raise-syntax) #W:243, 8: Else clause on loop without a break statement (useless-else-on-loop) # pylint-1.1 checks #C:334, 0: No space allowed after bracket (bad-whitespace) #W:162, 8: Attempting to unpack a non-sequence defined at line 6 of (unpacking-non-sequence) #C: 37, 0: Unnecessary parens after 'not' keyword (superfluous-parens) #C:301, 0: Unnecessary parens after 'if' keyword (superfluous-parens) [REPORTS] # Set the output format. Available formats are text, parseable, colorized, msvs # (visual studio) and html output-format=parseable # Include message's id in output include-ids=yes # Tells whether to display a full report or only the messages reports=yes # Template used to display messages. This is a python new-style format string # used to format the message information. See doc for all details msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" [VARIABLES] # A regular expression matching names used for dummy variables (i.e. not used). dummy-variables-rgx=_|dummy [BASIC] # Regular expression which should only match correct module names #module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ module-rgx=([a-zA-Z_][a-zA-Z0-9_]+)$ # Regular expression which should only match correct module level names const-rgx=(([a-zA-Z_][a-zA-Z0-9_]*)|(__.*__))$ # Regular expression which should only match correct class names class-rgx=[a-zA-Z_][a-zA-Z0-9_]+$ # Regular expression which should only match correct function names function-rgx=[a-z_][a-zA-Z0-9_]{,42}$ # Regular expression which should only match correct method names method-rgx=[a-z_][a-zA-Z0-9_]{,42}$ # Regular expression which should only match correct instance attribute names attr-rgx=[a-z_][a-zA-Z0-9_]{,30}$ # Regular expression which should only match correct argument names argument-rgx=[a-z_][a-zA-Z0-9_]{,30}$ # Regular expression which should only match correct variable names variable-rgx=[a-z_][a-zA-Z0-9_]{,30}$ # Regular expression which should only match correct list comprehension / # generator expression variable names inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ # Regular expression which should only match correct class sttribute names class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,42}|(__.*__))$ # Good variable names which should always be accepted, separated by a comma good-names=i,j,k,ex,Run,_ # Bad variable names which should always be refused, separated by a comma bad-names=foo,bar,baz,toto,tutu,tata # List of builtins function names that should not be used, separated by a comma bad-functions=apply,input [DESIGN] # Maximum number of arguments for function / method max-args=10 # Maximum number of locals for function / method body max-locals=20 # Maximum number of return / yield for function / method body max-returns=6 # Maximum number of branch for function / method body max-branchs=20 # Maximum number of statements in function / method body max-statements=50 # Maximum number of parents for a class (see R0901). max-parents=7 # Maximum number of attributes for a class (see R0902). max-attributes=7 # Minimum number of public methods for a class (see R0903). min-public-methods=1 # Maximum number of public methods for a class (see R0904). max-public-methods=20 [CLASSES] [FORMAT] # Maximum number of characters on a single line. max-line-length=120 # Maximum number of lines in a module max-module-lines=1000 # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 # tab). indent-string=' ' [MISCELLANEOUS] # List of note tags to take in consideration, separated by a comma. notes= 07070100000014000081B40000000000000000000000016615495400000767000000000000000000000000000000000000002C00000000spacewalk-search/rhn_search_daemon_dev.confwrapper.java.command=/usr/bin/java wrapper.java.mainclass=com.redhat.satellite.search.Main wrapper.java.classpath.1=%PWD%/build/ wrapper.java.classpath.2=%PWD%/lib/commons-lang3.jar wrapper.java.classpath.3=%PWD%/lib/commons-logging-1.1.jar wrapper.java.classpath.4=%PWD%/lib/ibatis-2.3.0.677.jar wrapper.java.classpath.5=%PWD%/lib/log4j-api-2.17.1.jar wrapper.java.classpath.5=%PWD%/lib/log4j-core-2.17.1.jar wrapper.java.classpath.6=%PWD%/lib/lucene-core-2.3.2.jar wrapper.java.classpath.7=%PWD%/lib/ojdbc14-1.10.jar wrapper.java.classpath.8=%PWD%/lib/picocontainer-1.3.jar wrapper.java.classpath.9=%PWD%/lib/quartz-1.5.1.jar wrapper.java.classpath.10=%PWD%/lib/redstone-xmlrpc-1.1_20071120.jar wrapper.java.classpath.11=%PWD%/lib/redstone-xmlrpc-client-1.1_20071120.jar wrapper.java.classpath.12=%PWD%/lib/simple-core-3.1.3.jar wrapper.java.classpath.13=/usr/share/java/tanukiwrapper.jar wrapper.java.classpath.14=%PWD%/lib/logdriver-0.1.jar wrapper.java.classpath.15=%PWD%/lib/lucene-analyzers-2.3.2.jar wrapper.java.classpath.21=%PWD%/lib/oro-2.0.8.jar wrapper.java.classpath.22=%PWD%/lib/icu4j-3_8_1.jar wrapper.java.classpath.23=%PWD%/lib/icu4j-charsets-3_8_1.jar wrapper.java.classpath.24=%PWD%/lib/commons-cli-1.0.jar wrapper.java.classpath.25=%PWD%/lib/commons-codec-1.2.jar wrapper.java.classpath.26=%PWD%/lib/tika-0.1-incubating.jar wrapper.java.library.path.1=/usr/lib wrapper.java.library.path.2=/usr/lib64 wrapper.console.format=PM wrapper.console.loglevel=INFO wrapper.logfile=%PWD%/rhn_search_daemon.log wrapper.logfile.format=LPTM wrapper.logfile.loglevel=DEBUG wrapper.logfile.maxsize=5m wrapper.logfile.maxfiles=5 wrapper.syslog.loglevel=DEBUG wrapper.java.additional.1=-Dsearch.config.dir=%PWD%/src/config/search wrapper.java.additional.2=-Xdebug wrapper.java.additional.3=-Xnoagent wrapper.java.additional.4=-Xrunjdwp:transport=dt_socket,address=9999,server=y,suspend=n 07070100000015000081B40000000000000000000000016615495400003985000000000000000000000000000000000000002A00000000spacewalk-search/spacewalk-search.changes------------------------------------------------------------------- Thu Apr 04 19:04:59 CEST 2024 - marina.latini@suse.com - version 5.0.2-0 * Replace Java 11 with Java 17 ------------------------------------------------------------------- Tue Jan 16 08:34:26 CET 2024 - jgonzalez@suse.com - version 5.0.1-1 * update dependencies after package rename ------------------------------------------------------------------- Fri Dec 15 17:22:12 CET 2023 - rosuna@suse.com - version 4.4.7-1 * Include "uuid" as system search result attribute (bsc#1216380) ------------------------------------------------------------------- Wed Nov 01 21:01:45 CET 2023 - marina.latini@suse.com - version 4.4.6-1 * Add JAVA_OPTS configuration for rhn-search ------------------------------------------------------------------- Wed Apr 19 12:59:12 CEST 2023 - marina.latini@suse.com - version 4.4.5-1 * Add maxPoolSize option to search ------------------------------------------------------------------- Mon Jan 23 08:32:37 CET 2023 - jgonzalez@suse.com - version 4.4.4-1 * Updated logrotate configuration (bsc#1206470) ------------------------------------------------------------------- Wed Dec 14 14:17:08 CET 2022 - jgonzalez@suse.com - version 4.4.3-1 * fix logging configuration of the search daemon (bsc#1206336) * Remove unneeded sysv init script ------------------------------------------------------------------- Fri Nov 18 15:15:09 CET 2022 - jgonzalez@suse.com - version 4.4.2-1 * Remove unneeded toString() calls ------------------------------------------------------------------- Wed Sep 28 11:19:48 CEST 2022 - jgonzalez@suse.com - version 4.4.1-1 * change mybatis require string ------------------------------------------------------------------- Wed Jul 27 14:19:43 CEST 2022 - jgonzalez@suse.com - version 4.3.6-1 * Add method to handle session id as String * Migrated from log4j1.x.x to log4j2.x.x ------------------------------------------------------------------- Tue Jun 21 18:31:24 CEST 2022 - jgonzalez@suse.com - version 4.3.5-1 * update ivy development files ------------------------------------------------------------------- Fri May 20 00:10:13 CEST 2022 - jgonzalez@suse.com - version 4.3.4-1 * Removed Apache Commons httpclient requirements ------------------------------------------------------------------- Tue Apr 19 12:06:37 CEST 2022 - jgonzalez@suse.com - version 4.3.3-1 * Remove doc search functionality * adapt for new c3p0 and mchange-commons package ------------------------------------------------------------------- Tue Jan 18 13:59:26 CET 2022 - jgonzalez@suse.com - version 4.3.2-1 * Explicitly require and buildrequire log4j12 ------------------------------------------------------------------- Mon Aug 09 11:05:06 CEST 2021 - jgonzalez@suse.com - version 4.3.1-1 - Bump version to 4.3.0 ------------------------------------------------------------------- Mon May 24 12:38:26 CEST 2021 - jgonzalez@suse.com - version 4.2.4-1 - prevent writing error messages when just skipping the indexer run (bsc#1185628) ------------------------------------------------------------------- Thu Dec 03 13:50:06 CET 2020 - jgonzalez@suse.com - version 4.2.3-1 - Added RHEL8 build support. ------------------------------------------------------------------- Wed Nov 25 12:24:19 CET 2020 - jgonzalez@suse.com - version 4.2.2-1 - Add multi lang support to the document search - change default maximum memory to 512 MB, preventing OutOfMemoryError ------------------------------------------------------------------- Fri Sep 18 11:43:02 CEST 2020 - jgonzalez@suse.com - version 4.2.1-1 - Update package version to 4.2.0 ------------------------------------------------------------------- Wed Jan 22 12:13:23 CET 2020 - jgonzalez@suse.com - version 4.1.2-1 - Require log4j12 for SLE15SP2 and openSUSE Leap 15.2 ------------------------------------------------------------------- Wed Nov 27 16:49:11 CET 2019 - jgonzalez@suse.com - version 4.1.1-1 - Make rhn-search log to correct file (bsc#1156751) - Enable aarch64 builds - Fix rhn-search to read memory variable from rhnconf (bsc#1154586) - Bump version to 4.1.0 (bsc#1154940) - require lucene version we use (bsc#1156176) - move /usr/share/rhn/config-defaults to uyuni-base-common - Add search server JDBC idle time config options to rhn_search.conf ------------------------------------------------------------------- Wed Jul 31 17:47:09 CEST 2019 - jgonzalez@suse.com - version 4.0.8-1 - Refactor: Drop unused class for Oracle ------------------------------------------------------------------- Wed May 15 15:17:46 CEST 2019 - jgonzalez@suse.com - version 4.0.7-1 - SPEC cleanup ------------------------------------------------------------------- Mon Apr 22 12:15:26 CEST 2019 - jgonzalez@suse.com - version 4.0.6-1 - modify file url translation to point correctly to the new documentation URLs - add makefile and pylint configuration ------------------------------------------------------------------- Mon Mar 25 16:45:08 CET 2019 - jgonzalez@suse.com - version 4.0.5-1 - Remove old file from spec file - Remove tanukiwrapper dependency for rhn-search ------------------------------------------------------------------- Thu Jan 31 09:42:13 CET 2019 - jgonzalez@suse.com - version 4.0.4-1 - Explicitly require JDK11 ------------------------------------------------------------------- Mon Dec 17 14:41:09 CET 2018 - jgonzalez@suse.com - version 4.0.3-1 - Fix nutch-core path (bsc#1112445) ------------------------------------------------------------------- Fri Oct 26 10:42:27 CEST 2018 - jgonzalez@suse.com - version 4.0.2-1 - limit number of old java logfiles (bsc#1107869) ------------------------------------------------------------------- Fri Aug 10 15:30:09 CEST 2018 - jgonzalez@suse.com - version 4.0.1-1 - Bump version to 4.0.0 (bsc#1104034) - Fix copyright for the package specfile (bsc#1103696) - Apply correct patch for "Fix the search when server is missing primary interface" (bsc#1103044) - Fix the search when server is missing primary interface (bsc#1099638) ------------------------------------------------------------------- Thu Mar 29 01:24:57 CEST 2018 - jgonzalez@suse.com - version 2.8.3.3-1 - remove lib jar files and add them as build dependencies on spec ------------------------------------------------------------------- Mon Mar 05 08:55:25 CET 2018 - jgonzalez@suse.com - version 2.8.3.2-1 - remove empty clean section from spec (bsc#1083294) ------------------------------------------------------------------- Wed Feb 28 09:51:55 CET 2018 - jgonzalez@suse.com - version 2.8.3.1-1 - Sync with upstream ------------------------------------------------------------------- Fri Feb 02 13:53:15 CET 2018 - jgonzalez@suse.com - version 2.8.2.2-1 - More rhnServerNetwork refactoring (bsc#1063419) ------------------------------------------------------------------- Wed Jan 17 12:57:38 CET 2018 - jgonzalez@suse.com - version 2.8.2.1-1 - Remove unused binary jars - Updated to use Quartz 2.3.0 API (bsc#1049431) ------------------------------------------------------------------- Tue Nov 28 14:38:11 CET 2017 - jgonzalez@suse.com - version 2.7.3.3-1 - rhnServerNetwork refactoring (bsc#1063419) ------------------------------------------------------------------- Tue Aug 08 11:31:54 CEST 2017 - fkobzik@suse.de - version 2.7.3.2-1 - remove executable bit from service files (bsc#1051518) ------------------------------------------------------------------- Wed May 03 16:42:51 CEST 2017 - michele.bologna@suse.com - version 2.7.3.1-1 - updated RHEL6 Requires after jpackage removal ------------------------------------------------------------------- Mon Apr 03 14:56:15 CEST 2017 - mc@suse.de - version 2.7.2.1-1 - simplify rhn-search jar list ------------------------------------------------------------------- Mon Mar 06 16:44:04 CET 2017 - mc@suse.de - version 2.7.0.3-1 - Migrating Fedorahosted to GitHub ------------------------------------------------------------------- Tue Feb 07 17:52:53 CET 2017 - michele.bologna@suse.com - version 2.7.0.2-1 - Align with upstream versioning ------------------------------------------------------------------- Wed Jan 11 16:35:37 CET 2017 - michele.bologna@suse.com - version 2.7.0.1-1 - Version 2.7 ------------------------------------------------------------------- Mon Jul 18 14:18:01 CEST 2016 - jrenner@suse.com - version 2.5.2.2-1 - round CPU MHz number to a long value - provide 12.1 instant client lib dir to search daemon ------------------------------------------------------------------- Wed Jun 15 10:43:10 CEST 2016 - mc@suse.de - round CPU MHz number correctly to a long value (bsc#979745) ------------------------------------------------------------------- Thu Jan 14 13:26:12 CET 2016 - mc@suse.de - version 2.5.2.1-1 - require log4j12, it will not download in build time on Fedora 23 otherwise ------------------------------------------------------------------- Mon Nov 30 10:46:32 CET 2015 - mc@suse.de - version 2.5.1.1-1 - run indexing tasks only after previous one finishes ------------------------------------------------------------------- Wed Oct 07 14:30:25 CEST 2015 - mc@suse.de - version 2.5.0.1-1 - require objectweb-asm instead of asm on SUSE also - systemd fixes for spacewalk-search - relax compiler errors to build on SLE12 ------------------------------------------------------------------- Mon Jun 22 15:43:43 CEST 2015 - jrenner@suse.de - version 2.1.14.7-1 - Fix snapshot tag rhn-search issue - Instantiate insert query only when needed ------------------------------------------------------------------- Fri Feb 20 16:15:56 UTC 2015 - dmacvicar@suse.de - workaround for bnc#918852 remove hardcoded commons-logging configuration loading the log4j adapter from the hadoop jar. ------------------------------------------------------------------- Tue Feb 03 13:18:55 CET 2015 - mc@suse.de - version 2.1.14.6-1 - Getting rid of trailing spaces ------------------------------------------------------------------- Tue Oct 14 15:13:41 CEST 2014 - mc@suse.de - version 2.1.14.5-1 - use StringUtils for checking non-empty values - set newly constructed "db_name" even if db_ssl_enabled is disabled ------------------------------------------------------------------- Fri Sep 12 14:54:22 CEST 2014 - mc@suse.de - version 2.1.14.4-1 - fix package searching in shared channels ------------------------------------------------------------------- Tue May 27 17:08:18 CEST 2014 - mc@suse.de - version 2.1.14.3-1 - Use maxDoc() to actually iterate over all documents - Do not skip in case the last record has been deleted (bnc#854956) - De-duplicate handleDeletedRecords() implementations ------------------------------------------------------------------- Wed May 21 11:03:39 CEST 2014 - mc@suse.de - version 2.1.14.2-1 - fix post script and set was_running variable ------------------------------------------------------------------- Thu Feb 13 15:11:43 CET 2014 - mc@suse.de - version 2.1.14.1-1 ------------------------------------------------------------------- Thu Feb 13 15:02:33 CET 2014 - mc@suse.de - make package search faster ------------------------------------------------------------------- Fri Feb 07 13:34:14 CET 2014 - mc@suse.de - version 2.1.13.1-1 - Allow null as createdBy and lastModifiedBy (bnc#834415) - %%attr() mode not applicaple to symlink ------------------------------------------------------------------- Mon Jan 13 09:24:07 CET 2014 - mc@suse.de - version 2.1.12.1-1 - adapt buildrequires for new distributions - fix rhn-search on fedora ------------------------------------------------------------------- Wed Dec 18 13:43:31 CET 2013 - mc@suse.de - version 2.1.9.1-1 - do not let cleanindex log into the console - let spacewalk-search require c3p0 >= 0.9.1 - have package search return all matching results ------------------------------------------------------------------- Mon Dec 09 16:44:52 CET 2013 - mc@suse.de - version 2.1.7.1-1 - no JAVA API version check - make init script SUSE aware - do not exclude s390x - switch to 2.1 ------------------------------------------------------------------- Thu Nov 28 16:12:04 CET 2013 - mc@suse.de - version 1.7.3.11-1 - Fix custom info value index removal in advanced search (bnc#834415) ------------------------------------------------------------------- Thu Apr 04 15:39:59 CEST 2013 - mc@suse.de - version 1.7.3.10-1 - proper quoting for the zero length test ------------------------------------------------------------------- Fri Feb 08 11:15:59 CET 2013 - mc@suse.de - version 1.7.3.9-1 - fix errata search by CVE (brc#905872) ------------------------------------------------------------------- Fri Sep 28 16:45:37 CEST 2012 - mc@suse.de - version 1.7.3.8-1 - Set owner/group of config-defaults dir consistently (bnc#776377) ------------------------------------------------------------------- Thu Aug 02 16:29:05 CEST 2012 - mc@suse.de - version 1.7.3.7-1 - Add license files for Apache and GPL (bnc#764868) - Fix license to "GPL-2.0 and Apache-2.0" (bnc#764868) ------------------------------------------------------------------- Mon Jul 16 15:22:43 CEST 2012 - ug@suse.de - version 1.7.3.6-1 - add support for external PostgreSQL database in search server. - search needs quartz < 2.0 as well ------------------------------------------------------------------- Thu May 31 11:00:02 CEST 2012 - mc@suse.de - version 1.7.3.5-1 - Start indexing XCCDF idents. ------------------------------------------------------------------- Thu May 03 17:41:15 CEST 2012 - mc@suse.de - version 1.7.3.4-1 - build only on x86_64 ------------------------------------------------------------------- Fri Apr 27 17:03:03 CEST 2012 - mc@suse.de - version 1.7.3.3-1 - Updating default config files with additional options for heapdump directory ------------------------------------------------------------------- Fri Mar 30 14:44:28 CEST 2012 - mc@suse.de - version 1.7.3.2-1 - correctly spell MHz ------------------------------------------------------------------- Wed Mar 21 16:25:56 CET 2012 - mc@suse.de - version 1.7.3.1-1 - Bumping package version ------------------------------------------------------------------- Mon Feb 7 15:59:56 CET 2011 - mc@suse.de - add rc link (bnc#669894) ------------------------------------------------------------------- Tue Jan 11 17:37:24 CET 2011 - mc@suse.de - fix requires ------------------------------------------------------------------- Wed Sep 15 09:58:01 CEST 2010 - mantel@suse.de - Initial release of spacewalk-search ------------------------------------------------------------------- 07070100000016000081B400000000000000000000000166154954000018C5000000000000000000000000000000000000002700000000spacewalk-search/spacewalk-search.spec# # spec file for package spacewalk-search # # Copyright (c) 2022--2024 SUSE LLC # Copyright (c) 2008-2018 Red Hat, Inc. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via https://bugs.opensuse.org/ # %{!?java_version: %global java_version 11} %if 0%{?suse_version} %global apache_group www %else %define java_version 1:%{java_version} %global apache_group apache %endif %define oro (oro or jakarta-oro) Name: spacewalk-search Summary: Spacewalk Full Text Search Server License: Apache-2.0 AND GPL-2.0-only Group: Applications/Internet Version: 5.0.2 Release: 0 # This src.rpm is cannonical upstream # You can obtain it using this set of commands # git clone https://github.com/spacewalkproject/spacewalk.git # cd search-server # make test-srpm URL: https://github.com/uyuni-project/uyuni Source0: %{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildArch: noarch BuildRequires: %{oro} BuildRequires: ant BuildRequires: apache-commons-cli BuildRequires: apache-commons-codec BuildRequires: apache-commons-lang3 BuildRequires: apache-commons-logging BuildRequires: c3p0 >= 0.9.1 BuildRequires: cglib BuildRequires: javapackages-tools BuildRequires: junit BuildRequires: lucene == 2.4.1 BuildRequires: objectweb-asm BuildRequires: picocontainer BuildRequires: quartz >= 2.0 BuildRequires: redstone-xmlrpc BuildRequires: simple-core BuildRequires: slf4j BuildRequires: systemd BuildRequires: (java-devel >= %{java_version} or java-%{java_version}-openjdk-devel) BuildRequires: mvn(javassist:javassist) BuildRequires: mvn(org.apache.commons:commons-ognl) BuildRequires: mvn(org.mybatis:mybatis) %if 0%{?rhel} BuildRequires: systemd-rpm-macros %endif BuildRequires: uyuni-base-common BuildRequires: zip Requires(pre): uyuni-base-common Requires: %{oro} Requires: apache-commons-cli Requires: apache-commons-codec Requires: apache-commons-lang3 Requires: apache-commons-logging Requires: c3p0 >= 0.9.1 Requires: cglib Requires: javapackages-tools Requires: lucene == 2.4.1 Requires: objectweb-asm Requires: picocontainer Requires: quartz >= 2.0 Requires: redstone-xmlrpc Requires: simple-core Requires: mvn(javassist:javassist) Requires: mvn(org.apache.commons:commons-ognl) Requires: mvn(org.mybatis:mybatis) Obsoletes: rhn-search < 5.3.0 Requires: log4j BuildRequires: log4j %description This package contains the code for the Full Text Search Server for Spacewalk Server. %prep %setup -n %{name}-%{version} %install %if 0%{?rhel} export JAVA_HOME=/usr/lib/jvm/java-%{java_version}-openjdk/ %endif rm -fr ${RPM_BUILD_ROOT} ant -Djar.version=%{version} install install -d -m 755 $RPM_BUILD_ROOT%{_prefix}/share/rhn/config-defaults install -d -m 755 $RPM_BUILD_ROOT%{_prefix}/share/rhn/search install -d -m 755 $RPM_BUILD_ROOT%{_prefix}/share/rhn/search/lib install -d -m 755 $RPM_BUILD_ROOT%{_prefix}/share/rhn/search/classes install -d -m 755 $RPM_BUILD_ROOT%{_var}/lib/rhn/search install -d -m 755 $RPM_BUILD_ROOT%{_var}/lib/rhn/search/indexes install -d -m 755 $RPM_BUILD_ROOT%{_sbindir} install -d -m 755 $RPM_BUILD_ROOT%{_unitdir} install -d -m 755 $RPM_BUILD_ROOT%{_bindir} install -d -m 755 $RPM_BUILD_ROOT%{_var}/log/rhn/search install -d -m 755 $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d install -p -m 644 dist/%{name}-%{version}.jar $RPM_BUILD_ROOT%{_prefix}/share/rhn/search/lib/ # using install -m does not preserve the symlinks cp -d lib/* $RPM_BUILD_ROOT/%{_prefix}/share/rhn/search/lib install -p -m 644 src/config/etc/logrotate.d/rhn-search $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/rhn-search install -p -m 755 src/config/rhn-search $RPM_BUILD_ROOT%{_sbindir} install -p -m 644 src/config/rhn-search.service $RPM_BUILD_ROOT%{_unitdir} install -p -m 644 src/config/search/rhn_search.conf $RPM_BUILD_ROOT%{_prefix}/share/rhn/config-defaults/rhn_search.conf install -p -m 644 src/config/search/rhn_search_daemon.conf $RPM_BUILD_ROOT%{_prefix}/share/rhn/config-defaults/rhn_search_daemon.conf install -p -m 644 src/config/log4j2.xml $RPM_BUILD_ROOT%{_prefix}/share/rhn/search/classes/log4j2.xml ln -s -f %{_prefix}/share/rhn/search/lib/spacewalk-search-%{version}.jar $RPM_BUILD_ROOT%{_prefix}/share/rhn/search/lib/spacewalk-search.jar # add rc link mkdir -p $RPM_BUILD_ROOT/%{_sbindir}/ ln -sf service $RPM_BUILD_ROOT/%{_sbindir}/rcrhn-search # cleanup unwanted jar rm -f $RPM_BUILD_ROOT%{_prefix}/share/rhn/search/lib/junit.jar %post %if 0%{?rhel} %systemd_post rhn-search.service %else %service_add_post rhn-search.service %endif %preun %if 0%{?rhel} %systemd_preun rhn-search.service %else %service_del_preun rhn-search.service %endif %postun %if 0%{?rhel} %systemd_preun rhn-search.service %else %service_del_postun rhn-search.service %endif %pre %if !0%{?rhel} %service_add_pre rhn-search.service %endif %files %defattr(644,root,root,755) %attr(755, root, root) %{_var}/log/rhn/search %dir /usr/share/rhn/search/classes/ %{_prefix}/share/rhn/search/lib/* %attr(755, root, root) %{_sbindir}/rhn-search %attr(644, root, root) %{_unitdir}/rhn-search.service %{_prefix}/share/rhn/config-defaults/rhn_search.conf %{_prefix}/share/rhn/config-defaults/rhn_search_daemon.conf %{_prefix}/share/rhn/search/classes/log4j2.xml %{_sysconfdir}/logrotate.d/rhn-search %dir %attr(755, root, root) %{_var}/lib/rhn/search %dir %attr(755, root, root) %{_var}/lib/rhn/search/indexes %dir %attr(755, root, root) %{_var}/lib/rhn %dir /usr/share/rhn %dir /usr/share/rhn/search %dir /usr/share/rhn/search/lib %if 0%{?rhel} %dir %{_var}/log/rhn %else %attr(770,root,%{apache_group}) %dir %{_var}/log/rhn %endif %{_sbindir}/rcrhn-search %changelog 07070100000017000041FD0000000000000000000000046615495400000000000000000000000000000000000000000000001500000000spacewalk-search/src07070100000018000041FD0000000000000000000000056615495400000000000000000000000000000000000000000000001C00000000spacewalk-search/src/config07070100000019000041FD0000000000000000000000036615495400000000000000000000000000000000000000000000002000000000spacewalk-search/src/config/com0707010000001A000041FD0000000000000000000000036615495400000000000000000000000000000000000000000000002700000000spacewalk-search/src/config/com/redhat0707010000001B000041FD0000000000000000000000036615495400000000000000000000000000000000000000000000003100000000spacewalk-search/src/config/com/redhat/satellite0707010000001C000041FD0000000000000000000000036615495400000000000000000000000000000000000000000000003800000000spacewalk-search/src/config/com/redhat/satellite/search0707010000001D000041FD0000000000000000000000026615495400000000000000000000000000000000000000000000003B00000000spacewalk-search/src/config/com/redhat/satellite/search/db0707010000001E000081B40000000000000000000000016615495400000A37000000000000000000000000000000000000004600000000spacewalk-search/src/config/com/redhat/satellite/search/db/config.xml<?xml version="1.0" encoding="UTF-8"?><!-- Always ensure to use the correct XML header as above! --><!--Converted at: Wed Dec 04 11:26:11 CET 2013--> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD SQL Map Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration><settings> <setting name="cacheEnabled" value="true"/> <setting name="lazyLoadingEnabled" value="true"/> </settings> <typeAliases> </typeAliases> <typeHandlers> </typeHandlers> <environments default="default"> <environment id="default"> <transactionManager type="JDBC" /> <dataSource type="com.redhat.satellite.search.config.translator.C3P0DataSourceFactory"> <property name="driverClass" value="${search.connection.driver_class}"/> <property name="jdbcUrl" value="${search.connection.driver_proto}:${db_name}"/> <property name="maxIdleTime" value="${search.connection.max_idle_time}"/> <property name="maxIdleTimeExcessConnections" value="${search.connection.max_idle_time_excess_connections}"/> <property name="user" value="${db_user}"/> <property name="password" value="${db_password}"/> <property name="maxPoolSize" value="${search.connection.maxPoolSize}"/> </dataSource> </environment> </environments> <mappers> <mapper resource="com/redhat/satellite/search/db/package.xml"/> <mapper resource="com/redhat/satellite/search/db/errata.xml"/> <mapper resource="com/redhat/satellite/search/db/server.xml"/> <mapper resource="com/redhat/satellite/search/db/errata_handler.xml"/> <mapper resource="com/redhat/satellite/search/db/hwdevice.xml"/> <mapper resource="com/redhat/satellite/search/db/snapshot_tag.xml"/> <mapper resource="com/redhat/satellite/search/db/server_custom_info.xml"/> <mapper resource="com/redhat/satellite/search/db/xccdf_ident.xml"/> </mappers> </configuration> 0707010000001F000081B40000000000000000000000016615495400000F76000000000000000000000000000000000000004600000000spacewalk-search/src/config/com/redhat/satellite/search/db/errata.xml<?xml version="1.0" encoding="UTF-8"?><!--Converted at: Wed Dec 04 11:26:11 CET 2013--> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="errata"> <select id="listErrataFromId" parameterType="long" resultType="com.redhat.satellite.search.db.models.Errata"> SELECT e.id, e.advisory, e.advisory_type as advisoryType, e.advisory_name as advisoryName, e.advisory_rel as advisoryRel, e.product, e.description, e.synopsis, e.topic, e.solution, e.issue_date as issueDate, e.update_date as updateDate, e.notes, e.org_id, e.created, e.modified, e.last_modified as lastModified FROM rhnErrata e WHERE e.id > #{id} ORDER by e.id ASC </select> <delete id="deleteLastErrata"> DELETE FROM rhnIndexerWork where object_type = 'errata' </delete> <insert id="createLastErrata" parameterType="java.util.Map"> INSERT INTO rhnIndexerWork values ('errata', #{id}, #{last_modified}) </insert> <update id="updateLastErrata" parameterType="java.util.Map"> UPDATE rhnIndexerWork SET last_id = #{id}, last_modified = #{last_modified} where object_type = 'errata' </update> <select id="getLastErrataId" resultType="java.lang.Long"> SELECT last_id from rhnIndexerWork where object_type='errata' </select> <select id="maxErrataId" resultType="java.lang.Long"> SELECT MAX(ID) FROM rhnErrata </select> <select id="verifyErrataVisibility" resultType="string"> select ce.errata_id from rhnChannelErrata ce, rhnChannel c where c.id = ce.channel_id -- channel in a trusted org and public and ((c.channel_access = 'public' and c.id in (select c2.id from rhnChannel c2, rhnTrustedOrgs rto, web_contact wc, pxtsessions ps where c2.org_id = rto.org_id and rto.org_trust_id = wc.org_id and wc.id = ps.web_user_id and ps.id = #{session_id})) -- or specific channel trust granted and protected or (c.channel_access = 'protected' and c.id in (select ct.channel_id from rhnChannelTrust ct, web_contact wc, pxtsessions ps where ct.org_trust_id = wc.org_id and wc.id = ps.web_user_id and ps.id = #{session_id})) -- or channel family is visible (null or this org) or c.id in (select cfm.channel_id from rhnChannelFamilyMembers cfm, rhnUserChannelFamilyPerms ucfp, pxtsessions ps where ps.id = #{session_id} and ucfp.user_id = ps.web_user_id and cfm.channel_family_id = ucfp.channel_family_id) ) and ce.errata_id IN <foreach collection="id_list" item="item" separator="," close=")" open="("> #{item} </foreach> </select> </mapper> 07070100000020000081B400000000000000000000000166154954000006F2000000000000000000000000000000000000004E00000000spacewalk-search/src/config/com/redhat/satellite/search/db/errata_handler.xml<?xml version="1.0" encoding="UTF-8"?><!--Converted at: Wed Dec 04 11:26:11 CET 2013--> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="errataHandler"> <select id="listErrataByCVE" parameterType="Map" resultType="com.redhat.satellite.search.index.Result"> SELECT DISTINCT ecve.errata_id as id from rhnErrataCVE ecve, rhnCVE cve, rhnErrata e, rhnChannelErrata ce, rhnAvailableChannels ac, pxtsessions ps, web_contact wc where cve.id = ecve.cve_id and e.id = ce.errata_id and e.id = ecve.errata_id and ce.channel_id = ac.channel_id and ac.org_id = wc.org_id and ps.web_user_id = wc.id and ps.id = #{sessionId} and LOWER(cve.name) like #{param0} </select> <select id="listErrataByIssueDateRange" parameterType="Map" resultType="com.redhat.satellite.search.index.Result"> SELECT E.id as id FROM rhnErrata E, rhnChannelErrata ce, rhnAvailableChannels ac, pxtsessions ps, web_contact wc WHERE e.id = ce.errata_id and ce.channel_id = ac.channel_id and ac.org_id = wc.org_id and ps.web_user_id = wc.id and ps.id = #{sessionId} and E.issue_date >= TO_TIMESTAMP(#{param0}, 'YYYY-MM-DD HH24:MI:SS') AND E.issue_date <= TO_TIMESTAMP(#{param1}, 'YYYY-MM-DD HH24:MI:SS') ORDER BY E.issue_date ASC </select> </mapper> 07070100000021000081B400000000000000000000000166154954000007B8000000000000000000000000000000000000004800000000spacewalk-search/src/config/com/redhat/satellite/search/db/hwdevice.xml<?xml version="1.0" encoding="UTF-8"?><!--Converted at: Wed Dec 04 11:26:11 CET 2013--> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="hwdevice"> <select id="getHardwareDeviceById" parameterType="java.util.Map" resultType="com.redhat.satellite.search.db.models.HardwareDevice"> SELECT rd.id as id, rd.server_id as serverId, rd.class as classInfo, rd.bus as bus, rd.detached as detached, rd.device as device, rd.driver as driver, rd.description as description, rd.prop1 as vendorId, rd.prop2 as deviceId, rd.prop3 as subVendorId, rd.prop4 as subDeviceId, rd.pcitype as pciType FROM rhnDevice rd WHERE rd.id > #{id} ORDER by rd.id ASC </select> <delete id="deleteLastHardwareDevice"> DELETE FROM rhnIndexerWork where object_type = 'hwdevice' </delete> <insert id="createLastHardwareDevice" parameterType="java.util.Map"> INSERT INTO rhnIndexerWork values ('hwdevice', #{id}, #{last_modified}) </insert> <update id="updateLastHardwareDevice" parameterType="java.util.Map"> UPDATE rhnIndexerWork SET last_id = #{id}, last_modified = #{last_modified} where object_type = 'hwdevice' </update> <select id="getLastHardwareDeviceId" resultType="java.lang.Long"> SELECT last_id from rhnIndexerWork where object_type='hwdevice' </select> <select id="getLastHardwareDeviceIndexRun" resultType="java.util.Date"> SELECT last_modified from rhnIndexerWork where object_type='hwdevice' </select> <select id="queryAllHwDeviceIds" resultType="Long"> SELECT id from rhnDevice </select> </mapper> 07070100000022000081B400000000000000000000000166154954000010C1000000000000000000000000000000000000004700000000spacewalk-search/src/config/com/redhat/satellite/search/db/package.xml<?xml version="1.0" encoding="UTF-8"?><!--Converted at: Wed Dec 04 11:26:12 CET 2013--> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="package"> <select id="getPackageById" parameterType="long" resultType="com.redhat.satellite.search.db.models.RhnPackage"> SELECT p.id as id, pn.name as name, pe.epoch as epoch, pe.version as version, pe.release as release, pa.label as arch, p.description as description, p.summary as summary FROM rhnPackage p, rhnPackageName pn, rhnPackageEVR pe, rhnPackageArch pa WHERE p.evr_id = pe.id and p.name_id = pn.id and p.package_arch_id = pa.id and p.id = #{id} </select> <select id="listPackagesFromId" parameterType="long" resultType="com.redhat.satellite.search.db.models.RhnPackage"> SELECT p.id as id, pn.name as name, pe.epoch as epoch, pe.version as version, pe.release as release, pa.label as arch, p.description as description, p.summary as summary FROM rhnPackage p, rhnPackageName pn, rhnPackageEVR pe, rhnPackageArch pa WHERE p.evr_id = pe.id and p.name_id = pn.id and p.package_arch_id = pa.id and p.id > #{id} ORDER by p.id ASC </select> <delete id="deleteLastPackage"> DELETE FROM rhnIndexerWork where object_type = 'package' </delete> <insert id="createLastPackage" parameterType="java.util.Map"> INSERT INTO rhnIndexerWork values ('package', #{id}, #{last_modified}) </insert> <update id="updateLastPackage" parameterType="java.util.Map"> UPDATE rhnIndexerWork SET last_id = #{id}, last_modified = #{last_modified} where object_type = 'package' </update> <select id="getLastPackageId" resultType="java.lang.Long"> SELECT last_id from rhnIndexerWork where object_type='package' </select> <select id="maxPackageId" resultType="java.lang.Long"> SELECT MAX(ID) FROM rhnPackage </select> <select id="verifyPackageVisibility" resultType="string"> select cp.package_id from rhnChannelPackage cp, rhnChannel c where c.id = cp.channel_id -- channel in a trusted org and public and ((c.channel_access = 'public' and c.id in (select c2.id from rhnChannel c2, rhnTrustedOrgs rto, web_contact wc, pxtsessions ps where c2.org_id = rto.org_id and rto.org_trust_id = wc.org_id and wc.id = ps.web_user_id and ps.id = #{session_id})) -- or specific channel trust granted and protected or (c.channel_access = 'protected' and c.id in (select ct.channel_id from rhnChannelTrust ct, web_contact wc, pxtsessions ps where ct.org_trust_id = wc.org_id and wc.id = ps.web_user_id and ps.id = #{session_id})) -- or channel family is visible (null or this org) or c.id in (select cfm.channel_id from rhnChannelFamilyMembers cfm, rhnUserChannelFamilyPerms ucfp, pxtsessions ps where ps.id = #{session_id} and ucfp.user_id = ps.web_user_id and cfm.channel_family_id = ucfp.channel_family_id) ) and cp.package_id IN <foreach collection="id_list" item="item" separator="," close=")" open="("> #{item} </foreach> </select> </mapper> 07070100000023000081B400000000000000000000000166154954000013EE000000000000000000000000000000000000004600000000spacewalk-search/src/config/com/redhat/satellite/search/db/server.xml<?xml version="1.0" encoding="UTF-8"?><!--Converted at: Wed Dec 04 11:26:12 CET 2013--> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="server"> <select id="getServerByIdOrDate" parameterType="java.util.Map" resultType="com.redhat.satellite.search.db.models.Server"> SELECT s.id as id, s.name as name, s.description as description, s.info as info, s.created as registered, s.running_kernel as runningKernel, sl.machine as machine, sl.rack as rack, sl.room as room, sl.building as building, sl.address1 as address1, sl.address2 as address2, sl.city as city, sl.state as state, sl.country as country, s.hostname as hostname, addresses.ipaddr as ipaddr, addresses.ip6addr as ip6addr, dmi.vendor as dmiVendor, dmi.system as dmiSystem, dmi.product as dmiProduct, dmi.bios_vendor as dmiBiosVendor, dmi.bios_version as dmiBiosVersion, dmi.bios_release as dmiBiosRelease, dmi.asset as dmiAsset, dmi.board as dmiBoard, cpu.bogomips as cpuBogoMIPS, cpu.cache as cpuCache, cpu.family as cpuFamily, cpu.mhz as cpuMHz, cpu.stepping as cpuStepping, cpu.flags as cpuFlags, cpu.model as cpuModel, cpu.version as cpuVersion, cpu.vendor as cpuVendor, cpu.nrcpu as cpuNumberOfCpus, cpu.acpiversion as cpuAcpiVersion, cpu.apic as cpuApic, cpu.apmversion as cpuApmVersion, cpu.chipset as cpuChipset, si.checkin as checkin, rr.ram as ram, rr.swap as swap, vi.uuid as uuid FROM rhnServer s LEFT OUTER JOIN rhnServerInfo si on s.id = si.server_id LEFT OUTER JOIN rhnRam rr on s.id = rr.server_id LEFT OUTER JOIN rhnServerLocation sl ON s.id = sl.server_id LEFT OUTER JOIN rhnServerDmi dmi ON s.id = dmi.server_id LEFT OUTER JOIN rhnCPU cpu on s.id = cpu.server_id LEFT OUTER JOIN rhnVirtualInstance vi on s.id = vi.virtual_system_id LEFT OUTER JOIN (SELECT rsni.server_id, rsni.modified, rsna4.address as ipaddr, rsna6.address as ip6addr FROM rhnservernetinterface rsni LEFT OUTER JOIN rhnservernetaddress4 rsna4 ON rsni.id = rsna4.interface_id LEFT OUTER JOIN rhnservernetaddress6 rsna6 ON rsni.id = rsna6.interface_id WHERE is_primary = 'Y') AS addresses ON addresses.server_id = s.id WHERE ( s.modified >= #{last_modified} or addresses.modified >= #{last_modified} or si.checkin >= #{last_modified} or rr.modified >= #{last_modified} or sl.modified >= #{last_modified} or dmi.modified >= #{last_modified} or cpu.modified >= #{last_modified} or s.id > #{id}) ORDER by s.id ASC </select> <delete id="deleteLastServer"> DELETE FROM rhnIndexerWork where object_type = 'server' </delete> <insert id="createLastServer" parameterType="java.util.Map"> INSERT INTO rhnIndexerWork values ('server', #{id}, #{last_modified}) </insert> <update id="updateLastServer" parameterType="java.util.Map"> UPDATE rhnIndexerWork SET last_id = #{id}, last_modified = #{last_modified} where object_type = 'server' </update> <select id="getLastServerId" resultType="java.lang.Long"> SELECT last_id from rhnIndexerWork where object_type='server' </select> <select id="getLastServerIndexRun" resultType="java.util.Date"> SELECT last_modified from rhnIndexerWork where object_type='server' </select> <select id="verifyServerVisibility" resultType="string"> SELECT usp.server_id FROM rhnUserServerPerms usp INNER JOIN pxtsessions ps ON ps.web_user_id = usp.user_id WHERE ps.id = #{session_id} AND usp.server_id IN <foreach collection="id_list" item="item" separator="," close=")" open="("> #{item} </foreach> </select> <select id="maxServerId" resultType="java.lang.Long"> SELECT MAX(ID) FROM rhnServer </select> <select id="queryAllServerIds" resultType="Long"> SELECT id from rhnServer </select> </mapper> 07070100000024000081B40000000000000000000000016615495400000896000000000000000000000000000000000000005200000000spacewalk-search/src/config/com/redhat/satellite/search/db/server_custom_info.xml<?xml version="1.0" encoding="UTF-8"?><!--Converted at: Wed Dec 04 11:26:12 CET 2013--> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="serverCustomInfo"> <select id="getServerCustomInfoByIdOrDate" parameterType="java.util.Map" resultType="com.redhat.satellite.search.db.models.ServerCustomInfo"> SELECT rscdv.key_id as keyId, rscdv.server_id as serverId, rscdv.value as value, rscdv.created_by as createdBy, rscdv.last_modified_by as lastModifiedBy, rcdk.label as label, TO_CHAR(rscdv.created, 'YYYY-MM-DD HH24-MI-SS') as created, TO_CHAR(rscdv.modified, 'YYYY-MM-DD HH24-MI-SS') as modified FROM rhnServerCustomDataValue rscdv INNER JOIN rhnCustomDataKey rcdk on rcdk.id = rscdv.key_id WHERE rscdv.modified > #{last_modified} ORDER by rscdv.key_id ASC </select> <delete id="deleteLastServerCustomInfo"> DELETE FROM rhnIndexerWork where object_type = 'server_custom_info' </delete> <insert id="createLastServerCustomInfo" parameterType="java.util.Map"> INSERT INTO rhnIndexerWork values ('server_custom_info', #{id}, #{last_modified}) </insert> <update id="updateLastServerCustomInfo" parameterType="java.util.Map"> UPDATE rhnIndexerWork SET last_id = #{id}, last_modified = #{last_modified} where object_type = 'server_custom_info' </update> <select id="getLastServerCustomInfoId" resultType="java.lang.Long"> SELECT last_id from rhnIndexerWork where object_type='server_custom_info' </select> <select id="getLastServerCustomInfoIndexRun" resultType="java.util.Date"> SELECT last_modified from rhnIndexerWork where object_type='server_custom_info' </select> <select id="queryAllServerCustomInfoIds" resultType="com.redhat.satellite.search.db.models.ServerCustomInfo"> SELECT server_id as serverId, key_id as keyId from rhnServerCustomDataValue </select> </mapper> 07070100000025000081B40000000000000000000000016615495400000861000000000000000000000000000000000000004C00000000spacewalk-search/src/config/com/redhat/satellite/search/db/snapshot_tag.xml<?xml version="1.0" encoding="UTF-8"?><!--Converted at: Wed Dec 04 11:26:12 CET 2013--> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="snapshotTag"> <select id="getSnapshotTagByIdOrDate" parameterType="java.util.Map" resultType="com.redhat.satellite.search.db.models.SnapshotTag"> SELECT rt.id as id, rst.snapshot_id as snapshotId, rtn.id as tagNameId, rst.server_id as serverId, rt.org_id as orgId, rtn.name as name, TO_CHAR(rst.created, 'YYYY-MM-DD HH24-MI-SS') as created, TO_CHAR(rst.modified, 'YYYY-MM-DD HH24-MI-SS') as modified FROM rhnSnapshotTag rst INNER JOIN rhnTag rt on rst.tag_id = rt.id INNER JOIN rhnTagName rtn on rt.name_id = rtn.id WHERE rst.tag_id > #{id} OR rst.modified > #{last_modified} ORDER by rst.snapshot_id ASC </select> <delete id="deleteLastSnapshotTag"> DELETE FROM rhnIndexerWork where object_type = 'snapshot_tag' </delete> <insert id="createLastSnapshotTag" parameterType="java.util.Map"> INSERT INTO rhnIndexerWork values ('snapshot_tag', #{id}, #{last_modified}) </insert> <update id="updateLastSnapshotTag" parameterType="java.util.Map"> UPDATE rhnIndexerWork SET last_id = #{id}, last_modified = #{last_modified} where object_type = 'snapshot_tag' </update> <select id="getLastSnapshotTagId" resultType="java.lang.Long"> SELECT last_id from rhnIndexerWork where object_type='snapshot_tag' </select> <select id="getLastSnapshotTagIndexRun" resultType="java.util.Date"> SELECT last_modified from rhnIndexerWork where object_type='snapshot_tag' </select> <select id="queryAllSnapshotTagIds" resultType="com.redhat.satellite.search.db.models.SnapshotTag"> SELECT server_id as serverId, snapshot_id as snapshotId from rhnSnapshotTag </select> </mapper> 07070100000026000081B40000000000000000000000016615495400000662000000000000000000000000000000000000004B00000000spacewalk-search/src/config/com/redhat/satellite/search/db/xccdf_ident.xml<?xml version="1.0" encoding="UTF-8"?><!--Converted at: Wed Dec 04 11:26:12 CET 2013--> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="xccdfIdent"> <select id="getXccdfIdentById" parameterType="java.util.Map" resultType="com.redhat.satellite.search.db.models.XccdfIdent"> SELECT id, identifier FROM rhnXccdfIdent WHERE id > #{id} ORDER BY id ASC </select> <select id="queryAllXccdfIdentIds" resultType="Long"> SELECT id FROM rhnXccdfIdent </select> <insert id="createLastXccdfIdent" parameterType="java.util.Map"> INSERT INTO rhnIndexerWork VALUES ('xccdf_ident', #{id}, #{last_modified}) </insert> <select id="getLastXccdfIdentId" resultType="java.lang.Long"> SELECT last_id FROM rhnIndexerWork WHERE object_type='xccdf_ident' </select> <select id="getLastXccdfIdentIndexRun" resultType="java.util.Date"> SELECT last_modified FROM rhnIndexerWork WHERE object_type='xccdf_ident' </select> <update id="updateLastXccdfIdent" parameterType="java.util.Map"> UPDATE rhnIndexerWork SET last_id = #{id}, last_modified = #{last_modified} WHERE object_type = 'xccdf_ident' </update> <delete id="deleteLastXccdfIdent"> DELETE FROM rhnIndexerWork WHERE object_type = 'xccdf_ident' </delete> </mapper> 07070100000027000041FD0000000000000000000000036615495400000000000000000000000000000000000000000000002000000000spacewalk-search/src/config/etc07070100000028000041FD0000000000000000000000026615495400000000000000000000000000000000000000000000002C00000000spacewalk-search/src/config/etc/logrotate.d07070100000029000081B4000000000000000000000001661549540000007E000000000000000000000000000000000000003700000000spacewalk-search/src/config/etc/logrotate.d/rhn-search/var/log/rhn/search/rhn_search.log { rotate 5 copytruncate compress notifempty missingok size 10M } 0707010000002A000081B400000000000000000000000166154954000004A0000000000000000000000000000000000000002C00000000spacewalk-search/src/config/log4j2.test.xml<?xml version="1.0" encoding="UTF-8" ?> <Configuration status="warn" name="UyuniConfig"> <Appenders> <Console name="rootAppender" > <PatternLayout pattern="%d [%t] %-5p %c - %m%n" /> <Filters> <ThresholdFilter level="WARN" /> </Filters> </Console> <RollingFile name="SearchAppender" fileName="test_rhn_search.log" filePattern="test_rhn_search-%i.log"> <PatternLayout pattern="[%d] %-5p - %m%n" /> <SizeBasedTriggeringPolicy size="10MB" /> <DefaultRolloverStrategy max="5" /> <Filters> <ThresholdFilter level="DEBUG" /> </Filters> </RollingFile> </Appenders> <Loggers> <Logger name="com.redhat.satellite" level="info" > <AppenderRef ref="SearchAppender" /> </Logger> <Logger name="java.sql.ResultSet" level="warn" /> <Logger name="com.redhat.satellite.search.index.ngram.tests" level="debug" > <AppenderRef ref="rootAppender" /> </Logger> <Root level="info"><AppenderRef ref="rootAppender" /></Root> </Loggers> </Configuration> 0707010000002B000081B40000000000000000000000016615495400000C2B000000000000000000000000000000000000002700000000spacewalk-search/src/config/log4j2.xml<?xml version="1.0" encoding="UTF-8" ?> <Configuration status="warn" name="UyuniConfig"> <Appenders> <RollingFile name="rootAppender" fileName="/var/log/rhn/search/rhn_search_daemon.log" filePattern="/var/log/rhn/search/rhn_search_daemon-%i.log"> <PatternLayout pattern="%d [%t] %-5p %c - %m%n" /> <SizeBasedTriggeringPolicy size="10MB" /> <DefaultRolloverStrategy max="5" /> </RollingFile> <RollingFile name="SearchAppender" fileName="/var/log/rhn/search/rhn_search.log" filePattern="/var/log/rhn/search/rhn_search-%i.log"> <PatternLayout pattern="[%d] %-5p - %m%n" /> <SizeBasedTriggeringPolicy size="10MB" /> <DefaultRolloverStrategy max="5" /> </RollingFile> </Appenders> <Loggers> <!-- XmlRpc Logging --> <Logger name="com.redhat.satellite" level="info" > <AppenderRef ref="SearchAppender" /> </Logger> <Logger name="org.quartz" level="warn" > <AppenderRef ref="SearchAppender" /> </Logger> <!-- <Logger name="net.rkbloom.logdriver.LogPreparedStatement" level="debug" /> <Logger name="net.rkbloom.logdriver.LogStatement" level="debug" /> <Logger name="net.rkbloom.logdriver.LogCallableStatement" level="debug" /> <Logger name="net.rkbloom.logdriver.LogConnection" level="debug" /> <Logger name="com.redhat.satellite.search.rpc.handlers" level="debug" > <AppenderRef ref="SearchAppender" /> </Logger> <Logger name="com.redhat.satellite.search.index.IndexManager" level="debug" > <AppenderRef ref="SearchAppender" /> </Logger> <Logger name="com.redhat.satellite.search.ngram.NGramQueryParser" level="debug" > <AppenderRef ref="SearchAppender" /> </Logger> <Logger name="com.redhat.satellite.search.scheduler.tasks" level="debug" > <AppenderRef ref="SearchAppender" /> </Logger> <Logger name="com.redhat.satellite.search.rpc.handlers" level="debug" > <AppenderRef ref="SearchAppender" /> </Logger> --> <!-- SqlMap logging configuration --> <!-- <Logger name="com.ibatis" level="debug" /> <Logger name="com.ibatis.common.jdbc.SimpleDataSource" level="debug" /> <Logger name="com.ibatis.sqlmap.engine.cache.CacheModel" level="debug" /> <Logger name="com.ibatis.sqlmap.engine.impl.SqlMapClientImpl" level="debug" /> <Logger name="com.ibatis.sqlmap.engine.builder.xml.SqlMapParser" level="debug" > <Logger name="com.ibatis.common.util.StopWatch" level="debug" /> <Logger name="java.sql.Connection" level="debug" /> <Logger name="java.sql.Statement" level="debug" /> <Logger name="java.sql.PreparedStatement" level="debug" /> <Logger name="java.sql.ResultSet" level="debug" > --> <Root level="info"><AppenderRef ref="rootAppender" /></Root> </Loggers> </Configuration> 0707010000002C000081B40000000000000000000000016615495400000196000000000000000000000000000000000000002E00000000spacewalk-search/src/config/quartz.properties org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool org.quartz.threadPool.threadCount = 10 org.quartz.threadPool.threadPriority = 5 org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true # disable UpdateCheck job to be scheduled org.quartz.scheduler.skipUpdateCheck = true # disable the check within the UpdateCheck job org.terracotta.quartz.skipUpdateCheck = true 0707010000002D000081FD0000000000000000000000016615495400000431000000000000000000000000000000000000002700000000spacewalk-search/src/config/rhn-search#!/bin/sh echo "Sourcing config file..." . /usr/share/rhn/config-defaults/rhn_search_daemon.conf RHN_MEM=`grep ^[[:blank:]]*rhn-search.java.maxmemory /etc/rhn/rhn.conf | sed -e "s/.*=[[:blank:]]*//"` if [ "x$RHN_MEM" != "x" ]; then SEARCH_MAX_MEMORY=$RHN_MEM fi SEARCH_CLASSPATH="${SEARCH_JARS}:${SEARCH_RHN_CLASSPATH}:${SEARCH_RHN_JARS}" SEARCH_PARAMS="-Dfile.encoding=UTF-8 -Xms${SEARCH_INIT_MEMORY}m -Xmx${SEARCH_MAX_MEMORY}m" JAVACMD="/usr/bin/java ${JAVA_OPTS} -Djava.library.path=${SEARCH_LIBRARY_PATH} -classpath ${SEARCH_CLASSPATH} ${SEARCH_PARAMS}" if [[ $# -eq 0 ]]; then $JAVACMD -Dlog4j2.configurationFile=/usr/share/rhn/search/classes/log4j2.xml com.redhat.satellite.search.Main else case $1 in 'cleanindex') systemctl stop rhn-search $JAVACMD com.redhat.satellite.search.DeleteIndexes > /dev/null systemctl start rhn-search ;; *) echo "Invalid argument: To start the service use 'systemctl start rhn-search'... to clean the search indexes use 'rhn-search cleanindex'" esac fi 0707010000002E000081B400000000000000000000000166154954000000CF000000000000000000000000000000000000002F00000000spacewalk-search/src/config/rhn-search.service[Unit] Description=Spacewalk search engine After=local-fs.target network.target httpd.service [Service] Type=simple ExecStart=/usr/sbin/rhn-search Restart=on-failure [Install] WantedBy=multi-user.target 0707010000002F000041FD0000000000000000000000026615495400000000000000000000000000000000000000000000002300000000spacewalk-search/src/config/search07070100000030000081B40000000000000000000000016615495400000349000000000000000000000000000000000000003300000000spacewalk-search/src/config/search/rhn_search.confsearch.index_work_dir=/var/lib/rhn/search/indexes search.rpc_handlers=index:com.redhat.satellite.search.rpc.handlers.IndexHandler,db:com.redhat.satellite.search.rpc.handlers.DatabaseHandler,admin:com.redhat.satellite.search.rpc.handlers.AdminHandler search.connection.driver_class=oracle.jdbc.driver.OracleDriver # https://www.mchange.com/projects/c3p0/#maxIdleTime search.connection.max_idle_time=0 # https://www.mchange.com/projects/c3p0/#maxIdleTimeExcessConnections search.connection.max_idle_time_excess_connections=0 search.score_threshold=.10 search.system_score_threshold=.01 search.errata_score_threshold=.01 search.errata.advisory_score_threshold=.30 search.min_ngram = 1 search.max_ngram = 5 search.doc.limit_results = false search.schedule.interval = 300000 search.log.explain.results = false search.connection.maxPoolSize = 10 07070100000031000081B40000000000000000000000016615495400000232000000000000000000000000000000000000003A00000000spacewalk-search/src/config/search/rhn_search_daemon.conf#******************************************************************** # rhn-search daemon config options #******************************************************************** # Java Application SEARCH_LIBRARY_PATH="/usr/lib:/usr/lib64:/usr/lib/gcj/postgresql-jdbc:/usr/lib64/gcj/postgresql-jdbc" SEARCH_RHN_CLASSPATH="/usr/share/rhn/classes" SEARCH_RHN_JARS="/usr/share/rhn/lib/spacewalk-asm.jar:/usr/share/rhn/lib/rhn.jar:/usr/share/rhn/lib/java-branding.jar" SEARCH_JARS="/usr/share/rhn/search/lib/*" SEARCH_INIT_MEMORY=32 SEARCH_MAX_MEMORY=512 JAVA_OPTS="" 07070100000032000081B4000000000000000000000001661549540000010A000000000000000000000000000000000000002C00000000spacewalk-search/src/config/test.properties# test config file DO NOT SHIP search.connection.username = spacewalk search.connection.password = spacewalk search.connection.url=jdbc:log:oracle.jdbc.driver.OracleDriver:oracle:thin:@localhost:1521:xe search.connection.driver_class=net.rkbloom.logdriver.LogDriver 07070100000033000041FD0000000000000000000000036615495400000000000000000000000000000000000000000000001A00000000spacewalk-search/src/java07070100000034000041FD0000000000000000000000036615495400000000000000000000000000000000000000000000001E00000000spacewalk-search/src/java/com07070100000035000041FD0000000000000000000000036615495400000000000000000000000000000000000000000000002500000000spacewalk-search/src/java/com/redhat07070100000036000041FD0000000000000000000000036615495400000000000000000000000000000000000000000000002F00000000spacewalk-search/src/java/com/redhat/satellite07070100000037000041FD0000000000000000000000086615495400000000000000000000000000000000000000000000003600000000spacewalk-search/src/java/com/redhat/satellite/search07070100000038000081B40000000000000000000000016615495400000626000000000000000000000000000000000000004B00000000spacewalk-search/src/java/com/redhat/satellite/search/ContainerRunner.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search; import org.picocontainer.defaults.DefaultPicoContainer; /** * Runs a PicoContainer instance in a separate thread * to prevent the main process from exiting * * @version $Rev$ */ class ContainerRunner implements Runnable { private DefaultPicoContainer container; /** * Constructor * @param containerIn PicoContainer instance to use */ ContainerRunner(DefaultPicoContainer containerIn) { container = containerIn; } /** * {@inheritDoc} */ public void run() { container.start(); try { synchronized (this) { this.wait(); } container.stop(); } catch (InterruptedException e) { container.stop(); } } /** * Stop the thread */ public void stop() { synchronized (this) { this.notify(); } } } 07070100000039000081B40000000000000000000000016615495400001A98000000000000000000000000000000000000004900000000spacewalk-search/src/java/com/redhat/satellite/search/DeleteIndexes.java/* * Copyright (c) 2008--2012 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search; import java.io.File; import java.io.IOException; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.redhat.satellite.search.db.DatabaseManager; import com.redhat.satellite.search.db.WriteQuery; import com.redhat.satellite.search.config.Configuration; /** * Reindex - cleans up indexes on filesystem and database so reindexing will occur * @version $Rev: 1 $ */ public class DeleteIndexes { private static Logger log = LogManager.getLogger(DeleteIndexes.class); private DeleteIndexes() { } protected static boolean deleteDirectory(File dir) { File[] files = dir.listFiles(); boolean warning = true; for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { deleteDirectory(files[i]); } if (files[i].delete()) { log.debug("Deleted: " + files[i].getAbsolutePath()); } else { log.warn("*ERROR* unable to delete: " + files[i].getAbsolutePath()); warning = false; } } if (!dir.delete()) { log.warn("*ERROR* unable to delete: " + dir.getAbsolutePath()); warning = false; } return warning; } protected static boolean deleteIndexPath(String path) { File dir = new File(path); if ("/".equals(dir.getAbsolutePath())) { log.warn("Error, passed in path is <" + path + "> this looks wrong"); return false; } if (!dir.exists()) { log.debug("Path <" + dir.getAbsolutePath() + "> doesn't exist"); return true; // dir doesn't exist, so just as good as deleted } if (!dir.isDirectory()) { log.warn("Error, passed in path <" + path + "> is not a directory"); return false; } log.info("Attempting to delete " + dir.getAbsolutePath()); return deleteDirectory(dir); } protected static void deleteQuery(DatabaseManager databaseManager, String queryName) throws SQLException { WriteQuery query = null; log.info("Running query: " + queryName); query = databaseManager.getWriterQuery(queryName); query.delete(null); query.close(); } /** * @param args */ public static void main(String[] args) { try { Configuration config = new Configuration(); DatabaseManager databaseManager = new DatabaseManager(config); String indexWorkDir = config.getString("search.index_work_dir", null); if (StringUtils.isBlank(indexWorkDir)) { log.warn("Couldn't find path for where index files are stored."); log.warn("Looked in config for property: search.index_work_dir"); return; } List<IndexInfo> indexes = new ArrayList<IndexInfo>(); indexes.add(new IndexInfo("deleteLastErrata", indexWorkDir + File.separator + "errata")); indexes.add(new IndexInfo("deleteLastPackage", indexWorkDir + File.separator + "package")); indexes.add(new IndexInfo("deleteLastServer", indexWorkDir + File.separator + "server")); indexes.add(new IndexInfo("deleteLastHardwareDevice", indexWorkDir + File.separator + "hwdevice")); indexes.add(new IndexInfo("deleteLastSnapshotTag", indexWorkDir + File.separator + "snapshotTag")); indexes.add(new IndexInfo("deleteLastServerCustomInfo", indexWorkDir + File.separator + "serverCustomInfo")); indexes.add(new IndexInfo("deleteLastXccdfIdent", indexWorkDir + File.separator + "xccdfIdent")); for (IndexInfo info : indexes) { deleteQuery(databaseManager, info.getQueryName()); if (!deleteIndexPath(info.getDirPath())) { log.warn("Failed to delete index for " + info.getDirPath()); } } } catch (SQLException e) { log.error("Caught Exception: ", e); if (e.getErrorCode() == 17002) { log.error("Unable to establish database connection."); log.error("Ensure database is available and connection details are " + "correct, then retry"); } System.exit(1); } catch (IOException e) { log.error("Caught Exception: ", e); System.exit(1); } log.info("Index files have been deleted and database has been cleaned up, " + "ready to reindex"); } /** * IndexInfo */ protected static class IndexInfo { protected String queryName; protected String dirPath; /** * * @param query query name to delete all records * @param path string pointing to where index files reside */ public IndexInfo(String query, String path) { queryName = query; dirPath = path; } /** * Set the query name to delete all records for this index * @param queryNameIn name of the query */ public void setQueryName(String queryNameIn) { queryName = queryNameIn; } /** * Returns the query name * @return */ public String getQueryName() { return queryName; } /** * Set the path where the index files exist * @param path String which points to index files */ public void setDirPath(String path) { dirPath = path; } /** * Returns the path * @return a string which points to the index files */ public String getDirPath() { return dirPath; } } } 0707010000003A000081B400000000000000000000000166154954000009C0000000000000000000000000000000000000004000000000spacewalk-search/src/java/com/redhat/satellite/search/Main.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search; import com.redhat.satellite.search.config.Configuration; import com.redhat.satellite.search.db.DatabaseManager; import com.redhat.satellite.search.index.IndexManager; import com.redhat.satellite.search.rpc.RpcServer; import com.redhat.satellite.search.scheduler.ScheduleManager; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.picocontainer.defaults.DefaultPicoContainer; /** * Entry point for the rhn-search daemon */ public class Main { private static Logger log = LogManager.getLogger(Main.class); private static final Class[] COMPONENTS = {DatabaseManager.class, IndexManager.class, RpcServer.class, ScheduleManager.class}; private DefaultPicoContainer container; private ContainerRunner runner; /** */ public Integer start(String[] argv) { Configuration config = new Configuration(); container = new DefaultPicoContainer(); container.registerComponentInstance(config); for (int x = 0; x < COMPONENTS.length; x++) { container.registerComponentImplementation(COMPONENTS[x]); } runner = new ContainerRunner(container); Thread t = new Thread(runner); t.setDaemon(false); t.start(); return null; } /** */ public int stop(int arg) { log.info("Stopping Main"); runner.stop(); return 0; } /** * Main entry point * @param argv command-line args */ public static void main(String[] argv) { Main m = new Main(); m.start(argv); if (log.isDebugEnabled()) { log.debug("Returned from Main.start"); } } } 0707010000003B000041FD0000000000000000000000046615495400000000000000000000000000000000000000000000003D00000000spacewalk-search/src/java/com/redhat/satellite/search/config0707010000003C000081B400000000000000000000000166154954000005A2000000000000000000000000000000000000005200000000spacewalk-search/src/java/com/redhat/satellite/search/config/ConfigException.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ /* * AUTOMATICALLY GENERATED FILE, DO NOT EDIT. */ package com.redhat.satellite.search.config; /** * Base class for all Config exceptions * <p> * * @version definition($Rev: 76724 $)/template($Rev: 67725 $) */ public class ConfigException extends RuntimeException { /** * Constructor * @param message exception message */ public ConfigException(String message) { super(message); } /** * Constructor * @param message exception message * @param cause the cause (which is saved for later retrieval * by the Throwable.getCause() method). (A null value is * permitted, and indicates that the cause is nonexistent or * unknown.) */ public ConfigException(String message, Throwable cause) { super(message, cause); } } 0707010000003D000081B40000000000000000000000016615495400004793000000000000000000000000000000000000005000000000spacewalk-search/src/java/com/redhat/satellite/search/config/Configuration.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.config; import com.redhat.satellite.search.config.translator.TranslatorRegistry; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.TreeSet; /** * The Config class acts as an abstraction layer between our configuration * system, and the actual implementation. The basic idea is that there is a * global config, but you can instantiate one of your own if you want. This * layer insulates us from changing the underlying implementation. * <p> * Config files are properties, with /usr/share/rhn/config-defaults/*.conf * setting defaults that can be overridden by /etc/rhn/rhn.conf. * * @version $Rev$ */ public class Configuration { private static Logger logger = LogManager.getLogger(Configuration.class); // // Location of config files // /** * The default directory in which to look for config files */ public static final String DEFAULT_CONF_DIR = "/etc/rhn"; /** * The directory in which to look for default config values */ public static final String DEFAULT_DEFAULT_CONF_DIR = "/usr/share/rhn/config-defaults"; /** * The system property containing the Spacewalk configuration directory. * If the property is not set, config files are read * from {@link #DEFAULT_CONF_DIR} */ private static final String RHN_CONF_DIR_PROPERTY = "rhn.config.dir"; /** * The system property containing the SearchServer configuration directory. * If the property is not set, config files are read * from /usr/share/rhn/config-defaults */ private static final String SEARCH_CONF_DIR_PROPERTY = "search.config.dir"; /** * List of values that are considered true, ignoring case. */ private static final String[] TRUE_VALUES = {"1", "y", "true", "yes", "on"}; /** * array of prefix in the order they should be search * if the given lookup string is without a namespace. */ private String[] prefixOrder = new String[] {"web", "server"}; /** hash of configuration properties */ private Properties configValues = new Properties(); private List<KeyTranslator> translators; /** set of configuration file names */ private TreeSet<File> fileList = new TreeSet<File>(new Comparator<File>() { /** {inheritDoc} */ public int compare(File f1, File f2) { // Need to make sure we read the child namespace before the base // namespace. To do that, we sort the list in reverse order based // on the length of the file name. If two filenames have the same // length, then we need to do a lexigraphical comparison to make // sure that the filenames themselves are different. int lenDif = f2.getAbsolutePath().length() - f1.getAbsolutePath().length(); if (lenDif != 0) { return lenDif; } return f2.compareTo(f1); } }); /** * public constructor. Rereads config entries every time it is called. * * @throws ConfigException error from the Configuration layers. the jakarta * commons conf system just throws Exception, which makes it hard to react. * sometimes it is an IOExceptions, sometimes a SAXParserException, * sometimes a VindictiveException. so we just turn them into our own * exception type and toss them up. as we discover ones we might * meaningfully want to react to, we can specialize ConfigException and catch * those */ public Configuration() throws ConfigException { translators = TranslatorRegistry.getTranslators(); addPath(getSearchConfigDir()); addPath(getDefaultConfigFilePath()); parseFiles(); } /** * Construct from a Reader. * @param rdr Configuration data in Reader format. * @throws ConfigException thrown if a problem reading the configuration * occurs. */ public Configuration(Reader rdr) throws ConfigException { translators = TranslatorRegistry.getTranslators(); ReaderWrapper rdrwrap = new ReaderWrapper(rdr); Properties props = new Properties(); try { parseStream(props, "search", rdrwrap); } catch (IOException ioe) { throw new ConfigException(ioe.getMessage(), ioe); } } /** * Add a path to the config object for parsing * @param path The path to add */ public void addPath(String path) { addFiles(path); } /** * static method to get the singleton Config option * * @return the config option */ // public static synchronized Config get() { // if (singletonConfig == null) { // singletonConfig = new Config(); // } // return singletonConfig; // } private static String getRHNConfigDir() { String confDir = System.getProperty(RHN_CONF_DIR_PROPERTY); if (StringUtils.isBlank(confDir)) { confDir = DEFAULT_CONF_DIR; } return confDir; } private static String getSearchConfigDir() { String confDir = System.getProperty(SEARCH_CONF_DIR_PROPERTY); if (StringUtils.isBlank(confDir)) { confDir = DEFAULT_DEFAULT_CONF_DIR; } return confDir; } /** * Get the path to the rhn.conf file we use. * * @return String path. */ public static String getDefaultConfigFilePath() { return getRHNConfigDir() + "/rhn.conf"; } /** * Get the configuration entry for the given string name. If the value * is null, then return the given defValue. defValue can be null as well. * @param name name of property * @param defValue default value for property if it is null. * @return the value of the property with the given name, or defValue. */ public String getString(String name, String defValue) { String ret = getString(name); if (ret == null) { if (logger.isDebugEnabled()) { logger.debug("getString() - returning default value"); } ret = defValue; } return ret; } /** * Returns a map of the values with the given name. The value must be * in the format of key:value otherwise, an empty map is returned. * @param name name of property * @return map of the values of the property matching k:v. */ public Map<String, String> getMap(String name) { String value = getString(name); Map<String,String> retval = null; if (value != null) { retval = new HashMap<String, String>(); String[] pairs = value.split(","); for (int x = 0; x < pairs.length; x++) { String[] nv = pairs[x].split(":"); if (nv.length != 2) { continue; } retval.put(nv[0].trim(), nv[1].trim()); } } return retval; } /** * get the config entry for string s * * @param value string to get the value of * @return the value */ public String getString(String value) { if (logger.isDebugEnabled()) { logger.debug("getString() - getString() called with: " + value); } if (value == null) { return null; } int lastDot = value.lastIndexOf("."); String ns = ""; String property = value; if (lastDot > 0) { property = value.substring(lastDot + 1); ns = value.substring(0, lastDot); } if (logger.isDebugEnabled()) { logger.debug("getString() - getString() -> Getting property: " + property); } String result = configValues.getProperty(property); if (logger.isDebugEnabled()) { logger.debug("getString() - getString() -> result: " + result); } if (result == null) { if (!"".equals(ns)) { result = configValues.getProperty(ns + "." + property); } else { for (int i = 0; i < prefixOrder.length; i++) { result = configValues.getProperty(prefixOrder[i] + "." + property); if (result != null) { break; } } } } if (logger.isDebugEnabled()) { logger.debug("getString() - getString() -> returning: " + result); } if (result == null || result.equals("")) { return null; } return StringUtils.trim(result); } /** * get the config entry for string s * * @param s string to get the value of * @return the value */ public int getInt(String s) { return getInt(s, 0); } /** * get the config entry for string s, if no value is found * return the defaultValue specified. * * @param s string to get the value of * @param defaultValue Default value if entry is not found. * @return the value */ public int getInt(String s, int defaultValue) { Integer val = getInteger(s); if (val == null) { return defaultValue; } return val.intValue(); } /** * get the config entry for string s * * @param s string to get the value of * @return the value */ public double getDouble(String s) { return getDouble(s, 0.0); } /** * get the config entry for string s, if no value is found * return the defaultValue specified. * * @param s string to get the value of * @param defaultValue Default value if entry is not found. * @return the value */ public double getDouble(String s, double defaultValue) { String val = getString(s); if (val == null) { return defaultValue; } return new Double(val).doubleValue(); } /** * get the config entry for string s * * @param s string to get the value of * @return the value */ public Integer getInteger(String s) { String val = getString(s); if (val == null) { return null; } return new Integer(val); } /** * Parses a comma-delimited list of values as a java.util.List * @param name config entry name * @return instance of java.util.List populated with config values */ public List<String> getList(String name) { List<String> retval = new LinkedList<String>(); String[] vals = getStringArray(name); if (vals != null) { retval.addAll(Arrays.asList(vals)); } return retval; } /** * get the config entry for string s * * @param s string to get the value of * @return the value */ public String[] getStringArray(String s) { if (s == null) { return null; } String value = getString(s); if (value == null) { return null; } return value.split(","); } /** * get the config entry for string name * * @param name string to set the value of * @param value new value * @return the previous value of the property */ public String setString(String name, String value) { return (String) configValues.setProperty(name, value); } /** * get the config entry for string s * * @param s string to get the value of * @return the value */ public boolean getBoolean(String s) { String value = getString(s); if (logger.isDebugEnabled()) { logger.debug("getBoolean() - " + s + " is : " + value); } if (value == null) { return false; } //need to check the possible true values // tried to use BooleanUtils, but that didn't // get the job done for an integer as a String. for (int i = 0; i < TRUE_VALUES.length; i++) { if (TRUE_VALUES[i].equalsIgnoreCase(value)) { if (logger.isDebugEnabled()) { logger.debug("getBoolean() - Returning true: " + value); } return true; } } return false; } /** * set the config entry for string name * @param s string to set the value of * @param b new value */ public void setBoolean(String s, String b) { // need to check the possible true values // tried to use BooleanUtils, but that didn't // get the job done for an integer as a String. for (int i = 0; i < TRUE_VALUES.length; i++) { if (TRUE_VALUES[i].equalsIgnoreCase(b)) { configValues.setProperty(s, "1"); // get out we're done here return; } } configValues.setProperty(s, "0"); } private void addFiles(String path) { File f = new File(path); if (f.isDirectory()) { // bugzilla: 154517; only add items that end in .conf File[] files = f.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].getName().endsWith((".conf"))) { fileList.add(files[i]); } } } else { fileList.add(f); } } private String makeNamespace(File f) { String ns = f.getName(); // This is really hokey, but it works. Basically, rhn.conf doesn't // match the standard rhn_foo.conf convention. So, to create the // namespace, we first special case rhn.* if (ns.startsWith("rhn.")) { return ""; } ns = ns.replaceFirst("rhn_", ""); ns = ns.substring(0, ns.lastIndexOf('.')); ns = ns.replaceAll("_", "."); return ns; } private void parseStream(Properties props, String namespace, InputStream is) throws IOException { props.load(is); // loop through all of the config values in the properties file // making sure the prefix is there. Properties newProps = new Properties(); for (Iterator j = props.keySet().iterator(); j.hasNext();) { String key = (String) j.next(); String newKey = key; if (!key.startsWith(namespace)) { newKey = namespace + "." + key; } logger.debug("Adding: " + newKey + ": " + props.getProperty(key)); // translate the original key newKey = translateKey(key); newProps.put(newKey, props.getProperty(key)); } configValues.putAll(newProps); } /** * Parse all of the added files. */ public void parseFiles() { for (Iterator i = fileList.iterator(); i.hasNext();) { File curr = (File) i.next(); parseFile(curr); } } private void parseFile(File file) { Properties props = new Properties(); String ns = makeNamespace(file); logger.debug("Adding namespace: " + ns + " for file: " + file.getAbsolutePath()); try { parseStream(props, ns, new FileInputStream(file)); } catch (IOException e) { logger.error("Could not parse file" + file, e); } } /** * Returns a subset of the properties for the given namespace. This is * not a particularly fast method and should be used only at startup or * some other discreet time. Repeated calls to this method are guaranteed * to be slow. * @param namespace Namespace of properties to be returned. * @return subset of the properties that begin with the given namespace. */ public Properties getNamespaceProperties(String namespace) { Properties prop = new Properties(); for (Iterator i = configValues.keySet().iterator(); i.hasNext();) { String key = (String) i.next(); if (key.startsWith(namespace)) { if (logger.isDebugEnabled()) { logger.debug("Looking for key: [" + key + "]"); } prop.put(key, configValues.getProperty(key)); } } return prop; } private String translateKey(String key) { for (Iterator itr = translators.iterator(); itr.hasNext();) { KeyTranslator trans = (KeyTranslator) itr.next(); if (trans.shouldTranslate(key)) { key = trans.translateKey(key); } } return key; } private static class ReaderWrapper extends InputStream { private Reader rdr; public ReaderWrapper(Reader reader) { rdr = reader; } /** * {@inheritDoc} */ @Override public int read() throws IOException { return rdr.read(); } @Override public void close() throws IOException { super.close(); rdr.close(); } } } 0707010000003E000081B400000000000000000000000166154954000004EE000000000000000000000000000000000000005000000000spacewalk-search/src/java/com/redhat/satellite/search/config/KeyTranslator.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.config; /** * Translator * @version $Rev$ */ public interface KeyTranslator { /** * Translates the given key into something else. That something else is * determined by the specific implementation. The value for the given key * should not be affected. * @param key key to be translated. * @return The translated key. */ String translateKey(String key); /** * Returns true if the key should be translated. * @param key to be translated * @return true if the key should be translated. */ boolean shouldTranslate(String key); } 0707010000003F000041FD0000000000000000000000026615495400000000000000000000000000000000000000000000004300000000spacewalk-search/src/java/com/redhat/satellite/search/config/tests07070100000040000081B400000000000000000000000166154954000012F6000000000000000000000000000000000000005A00000000spacewalk-search/src/java/com/redhat/satellite/search/config/tests/ConfigurationTest.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.config.tests; import com.redhat.satellite.search.config.Configuration; import java.io.BufferedReader; import java.io.StringReader; import java.util.List; import java.util.Map; import junit.framework.TestCase; /** * ConfigurationTest * @version $Rev$ */ public class ConfigurationTest extends TestCase { private Configuration config; @Override protected void setUp() throws Exception { StringBuilder builder = new StringBuilder(); builder.append("search.boolean=true\n"); builder.append("search.index_work_dir=/tmp/search-server-test\n"); builder.append("search.rpc_port=2828\n"); builder.append("search.list=item1,item2, item3\n"); builder.append("db_user=rhnsat\n"); builder.append("search.rpc_handlers="); builder.append( "index:com.redhat.satellite.search.rpc.handlers.IndexHandler\n\n"); StringReader sr = new StringReader(builder.toString()); config = new Configuration(new BufferedReader(sr)); } public void testGetValue() { assertEquals("bar", config.getString("foo", "bar")); assertEquals( "index:com.redhat.satellite.search.rpc.handlers.IndexHandler", config.getString("search.rpc_handlers", "")); assertNull(config.getString(null, null)); assertEquals("", config.getString(null, "")); } public void testGetValueAsInt() { assertEquals(2828, config.getInt("search.rpc_port")); assertEquals(2828, config.getInt("search.rpc_port", 0)); assertEquals(10, config.getInt("search.nothere", 10)); assertEquals(10, config.getInt(null, 10)); try { config.getInt("search.rpc_handlers", 0); fail("getValueAsInt didn't throw exception"); } catch (Exception e) { // expected } } public void testGetValuesAsMap() { assertNull(config.getMap("search.notthere")); assertNull(config.getMap(null)); Map<String, String> map = config.getMap("search.rpc_handlers"); assertNotNull(map); assertEquals("com.redhat.satellite.search.rpc.handlers.IndexHandler", map.get("index")); map = config.getMap("search.rpc_port"); assertNotNull(map); assertTrue(map.keySet().isEmpty()); } public void testGetValues() { assertNotNull(config.getList("search.notthere")); assertTrue(config.getList("search.notthere").isEmpty()); assertNotNull(config.getList(null)); assertTrue(config.getList(null).isEmpty()); List<String> list = config.getList("search.list"); assertNotNull(list); assertEquals(3, list.size()); assertEquals("item1", list.get(0)); assertEquals("item2", list.get(1)); assertEquals(" item3", list.get(2)); } public void testTranslation() { assertNull(config.getString("db_user")); assertEquals("rhnsat", config.getString("search.connection.username")); } public void testGetBoolean() { assertTrue(config.getBoolean("search.boolean")); config.setBoolean("search.boolean", "false"); assertFalse(config.getBoolean("search.boolean")); } public void testGetDefaultConfig() { String confDir = System.getProperty("rhn.config.dir"); if (confDir == null || "".equals(confDir)) { confDir = "/etc/rhn"; } assertEquals(confDir + "/rhn.conf", Configuration.getDefaultConfigFilePath()); } public void testSetString() { config.setString("search.stringvalue", "foobar"); assertEquals("foobar", config.getString("search.stringvalue")); } public void testGetDouble() { config.setString("search.double", ".30"); assertEquals(0.0, config.getDouble("better.not.be.a.double")); assertEquals(.30, config.getDouble("search.double")); config.setString("search.double", "30"); assertEquals(30.0, config.getDouble("search.double")); config.setString("search.double", ""); assertEquals(0.0, config.getDouble("search.double")); } } 07070100000041000041FD0000000000000000000000026615495400000000000000000000000000000000000000000000004800000000spacewalk-search/src/java/com/redhat/satellite/search/config/translator07070100000042000081B40000000000000000000000016615495400000419000000000000000000000000000000000000006300000000spacewalk-search/src/java/com/redhat/satellite/search/config/translator/C3P0DataSourceFactory.java/* * Copyright (c) 2013 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.config.translator; import com.mchange.v2.c3p0.ComboPooledDataSource; import org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory; /** * DataSourceFactory using c3p0 * C3P0DataSourceFactory * @version $Rev$ */ public class C3P0DataSourceFactory extends UnpooledDataSourceFactory { public C3P0DataSourceFactory() { this.dataSource = new ComboPooledDataSource(); } } 07070100000043000081B400000000000000000000000166154954000004D7000000000000000000000000000000000000006900000000spacewalk-search/src/java/com/redhat/satellite/search/config/translator/HibernateToSearchTranslator.java/* * Copyright (c) 2008--2010 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.config.translator; import com.redhat.satellite.search.config.KeyTranslator; /** * HibernateToSearchTranslator * @version $Rev$ */ public class HibernateToSearchTranslator implements KeyTranslator { /** * {@inheritDoc} */ public String translateKey(String key) { return key.replaceAll("hibernate", "search"); } /** * {@inheritDoc} */ public boolean shouldTranslate(String key) { return (key.equals("hibernate.connection.driver_class") || key.equals("hibernate.connection.driver_proto")); } } 07070100000044000081B40000000000000000000000016615495400000751000000000000000000000000000000000000006000000000spacewalk-search/src/java/com/redhat/satellite/search/config/translator/TranslatorRegistry.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.config.translator; import com.redhat.satellite.search.config.KeyTranslator; import java.util.LinkedList; import java.util.List; /** * TranslatorRegistry * @version $Rev$ */ public class TranslatorRegistry { private TranslatorRegistry() { // hide the default constructor } private static final List<Class> TRANSLATOR_CLASSES; static { TRANSLATOR_CLASSES = new LinkedList<Class>(); TRANSLATOR_CLASSES.add(HibernateToSearchTranslator.class); } private static List<KeyTranslator> translators = new LinkedList<KeyTranslator>(); /** * Returns the list of all available translators. * @return the list of all available translators. */ public static List<KeyTranslator> getTranslators() { if (translators.isEmpty() && !TRANSLATOR_CLASSES.isEmpty()) { for (Class clazz : TRANSLATOR_CLASSES) { try { Object s = clazz.newInstance(); translators.add((KeyTranslator)s); } catch (Exception e) { e.printStackTrace(System.out); } } } return translators; } } 07070100000045000041FD0000000000000000000000046615495400000000000000000000000000000000000000000000003900000000spacewalk-search/src/java/com/redhat/satellite/search/db07070100000046000081B4000000000000000000000001661549540000120A000000000000000000000000000000000000004E00000000spacewalk-search/src/java/com/redhat/satellite/search/db/DatabaseManager.java/* * Copyright (c) 2008--2012 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.db; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.util.Properties; import com.redhat.satellite.search.config.Configuration; import com.redhat.satellite.search.config.ConfigException; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactoryBuilder; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; /** * Manages DB activity - connections, running queries, etc * @version $Rev$ */ public class DatabaseManager { private SqlSessionFactory sessionFactory = null; private static boolean isOracle; private static Logger log = LogManager.getLogger(DatabaseManager.class); /** * Constructor * @param config * @throws IOException */ public DatabaseManager(Configuration config) throws IOException { String configPath = config.getString("search.db_config_path", "classpath"); Reader reader = null; if (configPath.equals("classpath")) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); InputStream stream = cl .getResourceAsStream("com/redhat/satellite/search/db/config.xml"); if (stream == null) { throw new IllegalArgumentException( "com/redhat/satellite/search/db/" + "config.xml resource missing"); } reader = new InputStreamReader(stream); } else { reader = new FileReader(configPath); } Properties overrides = config.getNamespaceProperties("search"); String[] options = {"db_name", "db_password", "db_user"}; for (String option : options) { overrides.setProperty(option, config.getString(option)); } isOracle = config.getString("db_backend").equals("oracle"); if (isOracle) { overrides.setProperty("db_name", "@" + overrides.getProperty("db_name")); } else { String dbHost = config.getString("db_host"); if (!StringUtils.isEmpty(dbHost)) { String connectionUrl = "//" + dbHost; String dbPort = config.getString("db_port"); if (!StringUtils.isEmpty(dbPort)) { connectionUrl += ":" + dbPort; } connectionUrl += "/" + overrides.getProperty("db_name"); if (config.getBoolean("db_ssl_enabled")) { connectionUrl += "?ssl=true"; String trustStore = config.getString("java.ssl_truststore"); if (trustStore == null || ! new File(trustStore).isFile()) { throw new ConfigException("Can not find java truststore at " + trustStore + ". Path can be changed with java.ssl_truststore option."); } System.setProperty("javax.net.ssl.trustStore", trustStore); } overrides.setProperty("db_name", connectionUrl); } } sessionFactory = new SqlSessionFactoryBuilder(). build(reader, overrides); } /** * Open a named select query * @param <T> type returned by query * @param name name of query * @return query object */ public <T> Query<T> getQuery(String name) { return new Query<T>(sessionFactory.openSession(), name); } /** * Open a named write (insert, update, delete) query * @param name of query * @return query object */ public WriteQuery getWriterQuery(String name) { return new WriteQuery(sessionFactory.openSession(), name); } public static boolean isOracle() { return isOracle; } } 07070100000047000081B40000000000000000000000016615495400000993000000000000000000000000000000000000004400000000spacewalk-search/src/java/com/redhat/satellite/search/db/Query.java/* * Copyright (c) 2008--2013 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.db; import org.apache.ibatis.session.SqlSession; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; /** * Named Select query * @param <T> type returned by query * * @version $Rev$ */ public class Query<T> { private SqlSession session; private String queryName; Query(SqlSession sessionIn, String queryNameIn) { session = sessionIn; queryName = queryNameIn; } /** * Close query and associated resources * @throws SQLException something bad happened */ public void close() throws SQLException { try { session.commit(); } finally { session.close(); } } /** * Load list of objects from query * @param param query param * @return list of T * @throws SQLException something bad happened */ @SuppressWarnings("unchecked") public List<T> loadList(Object param) throws SQLException { List r = session.selectList(queryName, param); List<Object> results = r; List<T> retval = new ArrayList<T>(results.size()); for (Object item : results) { retval.add((T)item); } return retval; } /** * Load single object from query * @param param query apram * @return T * @throws SQLException something bad happened */ @SuppressWarnings("unchecked") public T load(Object param) throws SQLException { return (T)session.selectOne(queryName, param); } /** * Load single object from query * @return T * @throws SQLException something bad happened */ @SuppressWarnings("unchecked") public T load() throws SQLException { return (T)session.selectOne(queryName); } } 07070100000048000081B4000000000000000000000001661549540000040B000000000000000000000000000000000000004C00000000spacewalk-search/src/java/com/redhat/satellite/search/db/ResultHandler.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.db; import java.sql.ResultSet; import java.sql.SQLException; /** * Callback interface for Connection-based queries * * @version $Rev$ */ public interface ResultHandler { /** * Called for each row in a resultset * @param rs resultset * @throws SQLException something bad happened */ void handleRow(ResultSet rs) throws SQLException; } 07070100000049000081B4000000000000000000000001661549540000084F000000000000000000000000000000000000004900000000spacewalk-search/src/java/com/redhat/satellite/search/db/WriteQuery.java/* * Copyright (c) 2008--2013 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.db; import org.apache.ibatis.session.SqlSession; import java.sql.SQLException; /** * Query for writing (insert, update, delete) to a database * * @version $Rev$ */ public class WriteQuery { private SqlSession session; private String queryName; WriteQuery(SqlSession sessionIn, String queryNameIn) { session = sessionIn; queryName = queryNameIn; } /** * Close query and all associated resources * @throws SQLException something bad happened */ public void close() throws SQLException { try { session.commit(); } finally { session.close(); } } /** * Execute update query * @param param query param * @return number of rows updated * @throws SQLException something bad happened */ public int update(Object param) throws SQLException { return session.update(queryName, param); } /** * Execute delete query * @param param query param * @return number of rows updated * @throws SQLException something bad happened */ public int delete(Object param) throws SQLException { return session.delete(queryName, param); } /** * Execute insert query * @param param query param * @throws SQLException something bad happened */ public void insert(Object param) throws SQLException { session.insert(queryName, param); } } 0707010000004A000041FD0000000000000000000000026615495400000000000000000000000000000000000000000000004000000000spacewalk-search/src/java/com/redhat/satellite/search/db/models0707010000004B000081B40000000000000000000000016615495400001D1E000000000000000000000000000000000000004C00000000spacewalk-search/src/java/com/redhat/satellite/search/db/models/Errata.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.db.models; /** * Errata * @version $Rev$ */ public class Errata { private long id; private String advisory; private String advisoryType; private String advisoryName; private long advisoryRel; private String product; private String description; private String synopsis; private String topic; private String solution; private String issueDate; private String updateDate; private String notes; private String orgId; private String created; private String modified; private String lastModified; /** * Returns a string representation of the errata * @return string representation of the errata */ public String toString() { StringBuffer text = new StringBuffer("Errata<" + id + ", " + product + ">: "); text.append(advisoryType + ", " + advisoryName + ", " + advisory); text.append(", " + topic + ", " + synopsis); return text.toString(); } /** * Returns the erratum's id. * @return the erratum's id. */ public long getId() { return id; } /** * The erratum's id. * @param idIn erratum id. */ public void setId(long idIn) { id = idIn; } /** * Returns the advisory. * @return the advisory. */ public String getAdvisory() { return advisory; } /** * Sets the advisory. * @param advisoryIn */ public void setAdvisory(String advisoryIn) { advisory = advisoryIn; } /** * Returns advisory name * @return advisory name */ public String getAdvisoryName() { return advisoryName; } /** * Sets advisory name * @param advisoryNameIn new advisory name */ public void setAdvisoryName(String advisoryNameIn) { advisoryName = advisoryNameIn; } /** * Returns advisory release * @return advisory release */ public long getAdvisoryRel() { return advisoryRel; } /** * Sets advisory release * @param advisoryRelIn advisory release */ public void setAdvisoryRel(long advisoryRelIn) { advisoryRel = advisoryRelIn; } /** * Returns advisory type * @return advisory type */ public String getAdvisoryType() { return advisoryType; } /** * Set advisory type * @param advisoryTypeIn new advisory type */ public void setAdvisoryType(String advisoryTypeIn) { advisoryType = advisoryTypeIn; } /** * Returns created date as a string * @return created date as a string */ public String getCreated() { return created; } /** * Sets the created date (expecting string format) * @param createdIn string formatted date. */ public void setCreated(String createdIn) { created = createdIn; } /** * Returns the errata description * @return the errata description */ public String getDescription() { return description; } /** * Sets the description * @param descriptionIn description of errata */ public void setDescription(String descriptionIn) { description = descriptionIn; } /** * Returns the erratum's issue date as a string. * @return the erratum's issue date as a string. */ public String getIssueDate() { return issueDate; } /** * Sets the issue date (expecting string format). * @param issueDateIn string formatted date. */ public void setIssueDate(String issueDateIn) { issueDate = issueDateIn; } /** * Returns the last time the erratum was modified as a string. * @return the last time the erratum was modified as a string. */ public String getLastModified() { return lastModified; } /** * sets the last modified date as a string. * @param lastModifiedIn string formatted last modified date. */ public void setLastModified(String lastModifiedIn) { lastModified = lastModifiedIn; } /** * Returns the modified date as a string. * @return the modified date as a string. */ public String getModified() { return modified; } /** * Sets the modified date as a string. * @param modifiedIn string formatted date. */ public void setModified(String modifiedIn) { modified = modifiedIn; } /** * Returns notes associated with the errataum. * @return notes associated with the errataum. */ public String getNotes() { return notes; } /** * Sets the notes for the erratum. * @param notesIn notes. */ public void setNotes(String notesIn) { notes = notesIn; } /** * The org id owning the errata. * @return org id owning the errata. */ public String getOrgId() { return orgId; } /** * Sets the orgid owning the errata. * @param orgIdIn owning orgid. */ public void setOrgId(String orgIdIn) { orgId = orgIdIn; } /** * Products affected. * @return affected products. */ public String getProduct() { return product; } /** * sets the product. * @param productIn product */ public void setProduct(String productIn) { product = productIn; } /** * Returns what the errata proposed solution. * @return what the errata proposed solution. */ public String getSolution() { return solution; } /** * Proposed solution * @param solutionIn proposed solution. */ public void setSolution(String solutionIn) { solution = solutionIn; } /** * Returns erratum's synopsis. * @return erratum's synopsis. */ public String getSynopsis() { return synopsis; } /** * Sets the erratum's synopsis. * @param synopsisIn synopsis. */ public void setSynopsis(String synopsisIn) { synopsis = synopsisIn; } /** * returns erratum topic. * @return erratum topic. */ public String getTopic() { return topic; } /** * Sets the erratum's topic. * @param topicIn topic */ public void setTopic(String topicIn) { topic = topicIn; } /** * Returns the update date as a string. * @return the update date as a string. */ public String getUpdateDate() { return updateDate; } /** * Sets the update date as a string. * @param updateDateIn string formatted date. */ public void setUpdateDate(String updateDateIn) { updateDate = updateDateIn; } } 0707010000004C000081B400000000000000000000000166154954000003D6000000000000000000000000000000000000005300000000spacewalk-search/src/java/com/redhat/satellite/search/db/models/GenericRecord.java/* * Copyright (c) 2008--2010 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.db.models; /** * Server * @version $Rev$ */ public abstract class GenericRecord { protected long id = 0; /** * @return the id */ public long getId() { return id; } /** * @param idIn the id to set */ public void setId(long idIn) { this.id = idIn; } } 0707010000004D000081B40000000000000000000000016615495400001089000000000000000000000000000000000000005400000000spacewalk-search/src/java/com/redhat/satellite/search/db/models/HardwareDevice.java/* * Copyright (c) 2008--2010 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.db.models; /** * Server * @version $Rev$ */ public class HardwareDevice extends GenericRecord { private long serverId; private String classInfo; private String bus; private long detached; private String device; private String driver; private String description; private String vendorId; private String deviceId; private String subVendorId; private String subDeviceId; private long pciType; /** * @return the serverId */ public long getServerId() { return serverId; } /** * @param serverIdIn the serverId to set */ public void setServerId(long serverIdIn) { this.serverId = serverIdIn; } /** * @return the classInfo */ public String getClassInfo() { return classInfo; } /** * @param classInfoIn the classInfo to set */ public void setClassInfo(String classInfoIn) { this.classInfo = classInfoIn; } /** * @return the bus */ public String getBus() { return bus; } /** * @param busIn the bus to set */ public void setBus(String busIn) { this.bus = busIn; } /** * @return the detached */ public long getDetached() { return detached; } /** * @param detachedIn the detached to set */ public void setDetached(long detachedIn) { this.detached = detachedIn; } /** * @return the device */ public String getDevice() { return device; } /** * @param deviceIn the device to set */ public void setDevice(String deviceIn) { this.device = deviceIn; } /** * @return the driver */ public String getDriver() { return driver; } /** * @param driverIn the driver to set */ public void setDriver(String driverIn) { this.driver = driverIn; } /** * @return the description */ public String getDescription() { return description; } /** * @param descriptionIn the description to set */ public void setDescription(String descriptionIn) { this.description = descriptionIn; } /** * @return the vendorId */ public String getVendorId() { return vendorId; } /** * @param vendorIdIn the vendorId to set */ public void setVendorId(String vendorIdIn) { this.vendorId = vendorIdIn; } /** * @return the deviceId */ public String getDeviceId() { return deviceId; } /** * @param deviceIdIn the deviceId to set */ public void setDeviceId(String deviceIdIn) { this.deviceId = deviceIdIn; } /** * @return the subVendorId */ public String getSubVendorId() { return subVendorId; } /** * @param subVendorIdIn the subVendorId to set */ public void setSubVendorId(String subVendorIdIn) { this.subVendorId = subVendorIdIn; } /** * @return the subDeviceId */ public String getSubDeviceId() { return subDeviceId; } /** * @param subDeviceIdIn the subDeviceId to set */ public void setSubDeviceId(String subDeviceIdIn) { this.subDeviceId = subDeviceIdIn; } /** * @return the pciType */ public long getPciType() { return pciType; } /** * @param pciTypeIn the pciType to set */ public void setPciType(long pciTypeIn) { this.pciType = pciTypeIn; } } 0707010000004E000081B40000000000000000000000016615495400000E5F000000000000000000000000000000000000005000000000spacewalk-search/src/java/com/redhat/satellite/search/db/models/RhnPackage.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.db.models; /** * Simple Package DTO * @version $Rev$ */ public class RhnPackage { private long id; private String name; private String epoch; private String version; private String release; private String arch; private String description; private String summary; /** * Getter for pkg id * @return pkg id */ public long getId() { return id; } /** * Setter for pkg id * @param idIn pkg id */ public void setId(long idIn) { this.id = idIn; } /** * Getter for pkg name * @return pkg name */ public String getName() { return name; } /** * Setter for pkg name * @param nameIn pkg name */ public void setName(String nameIn) { this.name = nameIn; } /** * Getter for pkg epoch * @return pkg epoch */ public String getEpoch() { return epoch; } /** * Setter for pkg epoch * @param epochIn pkg epoch */ public void setEpoch(String epochIn) { this.epoch = epochIn; } /** * Getter for pkg version * @return pkg version */ public String getVersion() { return version; } /** * Setter for pkg version * @param versionIn */ public void setVersion(String versionIn) { this.version = versionIn; } /** * Getter for pkg release * @return pkg release */ public String getRelease() { return release; } /** * Setter for pkg release * @param releaseIn pkg release */ public void setRelease(String releaseIn) { this.release = releaseIn; } /** * Getter for pkg arch * @return pkg arch */ public String getArch() { return arch; } /** * Setter for pkg arch * @param archIn pkg arch */ public void setArch(String archIn) { this.arch = archIn; } /** * Setter for pkg description * @param desc pkg description */ public void setDescription(String desc) { description = desc; } /** * Getter for pkg description * @return pkg description */ public String getDescription() { return description; } /** * Setter for pkg summary * @param summaryIn pkg summary */ public void setSummary(String summaryIn) { summary = summaryIn; } /** * Getter for pkg summary * @return pkg summary */ public String getSummary() { return summary; } /** * Getter for "pretty" versino * @return <version>-<release> */ public String getPrettyVersion() { return version + "-" + release; } /** * Reconstructs filename from various parts of pkg metadata * @return <name>-<version>-<release>.<arch> */ public String getFileName() { return name + "-" + version + "-" + release + "." + arch; } } 0707010000004F000081B40000000000000000000000016615495400003ACA000000000000000000000000000000000000004C00000000spacewalk-search/src/java/com/redhat/satellite/search/db/models/Server.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.db.models; import java.util.Date; import org.apache.lucene.document.DateTools; import org.apache.lucene.document.NumberTools; /** * Server * @version $Rev$ */ public class Server extends GenericRecord { private String name; private String info; private String description; /* Location */ private String machine; private String rack; private String room; private String building; private String address1; private String address2; private String city; private String state; private String country; /* Network Info */ private String hostname; private String ipaddr; private String ip6addr; /* DMI Info */ private String dmiVendor; private String dmiSystem; private String dmiProduct; private String dmiBiosVendor; private String dmiBiosVersion; private String dmiBiosRelease; private String dmiAsset; private String dmiBoard; /* CPU Info */ private String cpuBogoMIPS; private String cpuCache; private String cpuFamily; private String cpuMHz; private String cpuStepping; private String cpuFlags; private String cpuModel; private String cpuVersion; private String cpuVendor; private String cpuNumberOfCpus; private String cpuAcpiVersion; private String cpuApic; private String cpuApmVersion; private String cpuChipset; private String checkin; private String registered; private String ram; private String swap; private String runningKernel; private String uuid; /** * @return the name */ public String getName() { return name; } /** * @param nameIn the name to set */ public void setName(String nameIn) { this.name = nameIn; } /** * @return the info */ public String getInfo() { return info; } /** * @param infoIn the info to set */ public void setInfo(String infoIn) { this.info = infoIn; } /** * @return the description */ public String getDescription() { return description; } /** * @param descriptionIn the description to set */ public void setDescription(String descriptionIn) { this.description = descriptionIn; } /** * @return the machine */ public String getMachine() { return machine; } /** * @param machineIn the machine to set */ public void setMachine(String machineIn) { this.machine = machineIn; } /** * @return the rack */ public String getRack() { return rack; } /** * @param rackIn the rack to set */ public void setRack(String rackIn) { this.rack = rackIn; } /** * @return the room */ public String getRoom() { return room; } /** * @param roomIn the room to set */ public void setRoom(String roomIn) { this.room = roomIn; } /** * @return the building */ public String getBuilding() { return building; } /** * @param buildingIn the building to set */ public void setBuilding(String buildingIn) { this.building = buildingIn; } /** * @return the address1 */ public String getAddress1() { return address1; } /** * @param address1In the address1 to set */ public void setAddress1(String address1In) { this.address1 = address1In; } /** * @return the address2 */ public String getAddress2() { return address2; } /** * @param address2In the address2 to set */ public void setAddress2(String address2In) { this.address2 = address2In; } /** * @return the city */ public String getCity() { return city; } /** * @param cityIn the city to set */ public void setCity(String cityIn) { this.city = cityIn; } /** * @return the state */ public String getState() { return state; } /** * @param stateIn the state to set */ public void setState(String stateIn) { this.state = stateIn; } /** * @return the country */ public String getCountry() { return country; } /** * @param countryIn the country to set */ public void setCountry(String countryIn) { this.country = countryIn; } /** * @return the hostname */ public String getHostname() { return hostname; } /** * @param hostnameIn the hostname to set */ public void setHostname(String hostnameIn) { this.hostname = hostnameIn; } /** * @return the ipaddr */ public String getIpaddr() { return ipaddr; } /** * @param ipaddrIn the ipaddr to set */ public void setIpaddr(String ipaddrIn) { this.ipaddr = ipaddrIn; } /** * @return the ip6addr */ public String getIp6addr() { return ip6addr; } /** * @param ip6addrIn the ip6addr to set */ public void setIp6addr(String ip6addrIn) { this.ip6addr = ip6addrIn; } /** * @return the dmiVendor */ public String getDmiVendor() { return dmiVendor; } /** * @param dmiVendorIn the dmiVendor to set */ public void setDmiVendor(String dmiVendorIn) { this.dmiVendor = dmiVendorIn; } /** * @return the dmiSystem */ public String getDmiSystem() { return dmiSystem; } /** * @param dmiSystemIn the dmiSystem to set */ public void setDmiSystem(String dmiSystemIn) { this.dmiSystem = dmiSystemIn; } /** * @return the dmiProduct */ public String getDmiProduct() { return dmiProduct; } /** * @param dmiProductIn the dmiProduct to set */ public void setDmiProduct(String dmiProductIn) { this.dmiProduct = dmiProductIn; } /** * @return the dmiBiosVendor */ public String getDmiBiosVendor() { return dmiBiosVendor; } /** * @param dmiBiosVendorIn the dmiBiosVendor to set */ public void setDmiBiosVendor(String dmiBiosVendorIn) { this.dmiBiosVendor = dmiBiosVendorIn; } /** * @return the dmiBiosVersion */ public String getDmiBiosVersion() { return dmiBiosVersion; } /** * @param dmiBiosVersionIn the dmiBiosVersion to set */ public void setDmiBiosVersion(String dmiBiosVersionIn) { this.dmiBiosVersion = dmiBiosVersionIn; } /** * @return the dmiBiosRelease */ public String getDmiBiosRelease() { return dmiBiosRelease; } /** * @param dmiBiosReleaseIn the dmiBiosRelease to set */ public void setDmiBiosRelease(String dmiBiosReleaseIn) { this.dmiBiosRelease = dmiBiosReleaseIn; } /** * @return the dmiAsset */ public String getDmiAsset() { return dmiAsset; } /** * @param dmiAssetIn the dmiAsset to set */ public void setDmiAsset(String dmiAssetIn) { this.dmiAsset = dmiAssetIn; } /** * @return the dmiBoard */ public String getDmiBoard() { return dmiBoard; } /** * @param dmiBoardIn the dmiBoard to set */ public void setDmiBoard(String dmiBoardIn) { this.dmiBoard = dmiBoardIn; } /** * @return the cpuBogoMIPS */ public String getCpuBogoMIPS() { return cpuBogoMIPS; } /** * @param cpuBogoMIPSIn the cpuBogoMIPS to set */ public void setCpuBogoMIPS(String cpuBogoMIPSIn) { if (cpuBogoMIPSIn != null) { Float f = Float.parseFloat(cpuBogoMIPSIn); this.cpuBogoMIPS = NumberTools.longToString(f.longValue()); } else { this.cpuBogoMIPS = null; } } /** * @return the cpuCache */ public String getCpuCache() { return cpuCache; } /** * @param cpuCacheIn the cpuCache to set */ public void setCpuCache(String cpuCacheIn) { this.cpuCache = cpuCacheIn; } /** * @return the cpuFamily */ public String getCpuFamily() { return cpuFamily; } /** * @param cpuFamilyIn the cpuFamily to set */ public void setCpuFamily(String cpuFamilyIn) { this.cpuFamily = cpuFamilyIn; } /** * @return the cpuMHz */ public String getCpuMHz() { return cpuMHz; } /** * @param cpuMHzIn the cpuMHz to set */ public void setCpuMHz(String cpuMHzIn) { if (cpuMHzIn != null) { this.cpuMHz = NumberTools.longToString(Math.round(Double.valueOf(cpuMHzIn))); } else { this.cpuMHz = null; } } /** * @return the cpuStepping */ public String getCpuStepping() { return cpuStepping; } /** * @param cpuSteppingIn the cpuStepping to set */ public void setCpuStepping(String cpuSteppingIn) { this.cpuStepping = cpuSteppingIn; } /** * @return the cpuFlags */ public String getCpuFlags() { return cpuFlags; } /** * @param cpuFlagsIn the cpuFlags to set */ public void setCpuFlags(String cpuFlagsIn) { this.cpuFlags = cpuFlagsIn; } /** * @return the cpuModel */ public String getCpuModel() { return cpuModel; } /** * @param cpuModelIn the cpuModel to set */ public void setCpuModel(String cpuModelIn) { this.cpuModel = cpuModelIn; } /** * @return the cpuVersion */ public String getCpuVersion() { return cpuVersion; } /** * @param cpuVersionIn the cpuVersion to set */ public void setCpuVersion(String cpuVersionIn) { this.cpuVersion = cpuVersionIn; } /** * @return the cpuVendor */ public String getCpuVendor() { return cpuVendor; } /** * @param cpuVendorIn the cpuVendor to set */ public void setCpuVendor(String cpuVendorIn) { this.cpuVendor = cpuVendorIn; } /** * @return the cpuNrCpu */ public String getCpuNumberOfCpus() { return cpuNumberOfCpus; } /** * @param cpuNumberOfCpusIn the cpuNumberOfCpus to set */ public void setCpuNumberOfCpus(String cpuNumberOfCpusIn) { if (cpuNumberOfCpusIn != null) { this.cpuNumberOfCpus = NumberTools.longToString(Long.parseLong(cpuNumberOfCpusIn)); } else { this.cpuNumberOfCpus = null; } } /** * @return the cpuAcpiVersion */ public String getCpuAcpiVersion() { return cpuAcpiVersion; } /** * @param cpuAcpiVersionIn the cpuAcpiVersion to set */ public void setCpuAcpiVersion(String cpuAcpiVersionIn) { this.cpuAcpiVersion = cpuAcpiVersionIn; } /** * @return the cpuApic */ public String getCpuApic() { return cpuApic; } /** * @param cpuApicIn the cpuApic to set */ public void setCpuApic(String cpuApicIn) { this.cpuApic = cpuApicIn; } /** * @return the cpuApmVersion */ public String getCpuApmVersion() { return cpuApmVersion; } /** * @param cpuApmVersionIn the cpuApmVersion to set */ public void setCpuApmVersion(String cpuApmVersionIn) { this.cpuApmVersion = cpuApmVersionIn; } /** * @return the cpuChipset */ public String getCpuChipset() { return cpuChipset; } /** * @param cpuChipsetIn the cpuChipset to set */ public void setCpuChipset(String cpuChipsetIn) { this.cpuChipset = cpuChipsetIn; } /** * @return the checkin */ public String getCheckin() { return checkin; } /** * @param checkinIn the checkin to set */ public void setCheckin(Date checkinIn) { if (checkinIn != null) { this.checkin = DateTools.dateToString(checkinIn, DateTools.Resolution.MINUTE); } else { this.checkin = null; } } /** * @return the registered */ public String getRegistered() { return registered; } /** * @param registeredIn the registered to set */ public void setRegistered(Date registeredIn) { if (registeredIn != null) { this.registered = DateTools.dateToString(registeredIn, DateTools.Resolution.MINUTE); } else { this.registered = null; } } /** * @return the ram */ public String getRam() { return ram; } /** * @param ramIn the ram to set */ public void setRam(String ramIn) { if (ramIn != null) { this.ram = NumberTools.longToString(Long.parseLong(ramIn)); } else { this.ram = null; } } /** * @return the swap */ public String getSwap() { return swap; } /** * @param swapIn the swap to set */ public void setSwap(String swapIn) { if (swapIn != null) { this.swap = NumberTools.longToString(Long.parseLong(swapIn)); } else { this.swap = null; } } /** * @return the running kernel */ public String getRunningKernel() { return runningKernel; } /** * @param runningKernelIn the runningKernel to set */ public void setRunningKernel(String runningKernelIn) { if (runningKernelIn != null) { this.runningKernel = runningKernelIn; } else { this.runningKernel = null; } } /** * @return the UUID */ public String getUuid() { return uuid; } /** * @param uuidIn the uuid to set */ public void setUuid(String uuidIn) { if (uuidIn != null) { this.uuid = uuidIn; } else { this.uuid = null; } } } 07070100000050000081B40000000000000000000000016615495400000E2C000000000000000000000000000000000000005600000000spacewalk-search/src/java/com/redhat/satellite/search/db/models/ServerCustomInfo.java/* * Copyright (c) 2008--2010 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.db.models; /** * ServerCustomInfo * @version $Rev$ */ public class ServerCustomInfo extends GenericRecord { private long keyId; private long serverId; private String label; private String value; private Long createdBy; private Long lastModifiedBy; private String created; private String modified; /** * * @param serverIdIn server id * @param keyIdIn key id * @return long based on server id and key id */ public static long makeUniqId(long serverIdIn, long keyIdIn) { return new Long("" + serverIdIn + keyIdIn); } /** * * @return unique id for a server/custom info key pair */ public long getId() { return makeUniqId(serverId, keyId); } /** * @return the keyId */ public long getKeyId() { return keyId; } /** * @param keyIdIn the keyId to set */ public void setKeyId(long keyIdIn) { this.keyId = keyIdIn; } /** * @return the serverId */ public long getServerId() { return serverId; } /** * @param serverIdIn the serverId to set */ public void setServerId(long serverIdIn) { this.serverId = serverIdIn; } /** * @return the created */ public String getCreated() { return created; } /** * @param createdIn the created to set */ public void setCreated(String createdIn) { this.created = createdIn; } /** * @return the modified */ public String getModified() { return modified; } /** * @param modifiedIn the modified to set */ public void setModified(String modifiedIn) { this.modified = modifiedIn; } /** * @return the label */ public String getLabel() { return label; } /** * @param labelIn the label to set */ public void setLabel(String labelIn) { this.label = labelIn; } /** * @return the value */ public String getValue() { return value; } /** * @param valueIn the value to set */ public void setValue(String valueIn) { this.value = valueIn; } /** * @return the createdBy */ public Long getCreatedBy() { return createdBy; } /** * @param createdByIn the createdBy to set */ public void setCreatedBy(Long createdByIn) { this.createdBy = createdByIn; } /** * @return the lastModifiedBy */ public Long getLastModifiedBy() { return lastModifiedBy; } /** * @param lastModifiedByIn the lastModifiedBy to set */ public void setLastModifiedBy(Long lastModifiedByIn) { this.lastModifiedBy = lastModifiedByIn; } /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { return String.valueOf(getId()); } } 07070100000051000081B40000000000000000000000016615495400000C1F000000000000000000000000000000000000005100000000spacewalk-search/src/java/com/redhat/satellite/search/db/models/SnapshotTag.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.db.models; /** * SnapshotTag * @version $Rev$ */ public class SnapshotTag extends GenericRecord { private long snapshotId; private long tagNameId; private long serverId; private long orgId; private String name; private String created; private String modified; private String makeUniqId(long serverIdIn, long snapshotdIn) { return serverIdIn + "-" + snapshotdIn; } /** * * @return uniqId */ public String getUniqId() { return makeUniqId(serverId, snapshotId); } /** * @return the snapshotId */ public long getSnapshotId() { return snapshotId; } /** * @param snapshotIdIn the snapshotId to set */ public void setSnapshotId(long snapshotIdIn) { this.snapshotId = snapshotIdIn; } /** * @return the tagNameId */ public long getTagNameId() { return tagNameId; } /** * @param tagNameIdIn the tagNameId to set */ public void setTagNameId(long tagNameIdIn) { this.tagNameId = tagNameIdIn; } /** * @return the serverId */ public long getServerId() { return serverId; } /** * @param serverIdIn the serverId to set */ public void setServerId(long serverIdIn) { this.serverId = serverIdIn; } /** * @return the orgId */ public long getOrgId() { return orgId; } /** * @param orgIdIn the orgId to set */ public void setOrgId(long orgIdIn) { this.orgId = orgIdIn; } /** * @return the name */ public String getName() { return name; } /** * @param nameIn the name to set */ public void setName(String nameIn) { this.name = nameIn; } /** * @return the created */ public String getCreated() { return created; } /** * @param createdIn the created to set */ public void setCreated(String createdIn) { this.created = createdIn; } /** * @return the modified */ public String getModified() { return modified; } /** * @param modifiedIn the modified to set */ public void setModified(String modifiedIn) { this.modified = modifiedIn; } /** * {@inheritDoc} */ @Override public String toString() { return String.valueOf(getUniqId()); } } 07070100000052000081B40000000000000000000000016615495400000437000000000000000000000000000000000000005000000000spacewalk-search/src/java/com/redhat/satellite/search/db/models/XccdfIdent.java/* * Copyright (c) 2012 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.db.models; /** * XccdfIdent * @version $Rev$ */ public class XccdfIdent extends GenericRecord { private String identifier; /** * @return the xccdf:identifier */ public String getIdentifier() { return identifier; } /** * @param identifierIn the identifier to set */ public void setIdentifier(String identifierIn) { this.identifier = identifierIn; } } 07070100000053000041FD0000000000000000000000026615495400000000000000000000000000000000000000000000003F00000000spacewalk-search/src/java/com/redhat/satellite/search/db/tests07070100000054000081B40000000000000000000000016615495400000593000000000000000000000000000000000000005800000000spacewalk-search/src/java/com/redhat/satellite/search/db/tests/DatabaseManagerTest.javapackage com.redhat.satellite.search.db.tests; import com.redhat.satellite.search.db.DatabaseManager; import com.redhat.satellite.search.db.Query; import com.redhat.satellite.search.db.models.RhnPackage; import com.redhat.satellite.search.tests.BaseTestCase; import com.redhat.satellite.search.tests.TestUtil; import java.sql.SQLException; import java.util.List; public class DatabaseManagerTest extends BaseTestCase { private DatabaseManager dm; @Override protected void setUp() throws Exception { super.setUp(); dm = (DatabaseManager) container.getComponentInstance(DatabaseManager.class); } public void testObjectQuery() throws SQLException { Query<Long> maxidquery = dm.getQuery("maxPackageId"); Long maxid = maxidquery.load(); Query<RhnPackage> query = dm.getQuery("getPackageById"); RhnPackage p = query.load(maxid); assertNotNull(p); assertEquals(p.getId(), maxid.longValue()); } public void testListQuery() throws SQLException { Query<RhnPackage> query = dm.getQuery("listPackagesFromId"); List<RhnPackage> results = query.loadList((long) 0); assertNotNull(results); assertTrue(results.size() > 0); } @SuppressWarnings("unchecked") @Override protected Class[] getComponentClasses() { return TestUtil.buildComponentsList(DatabaseManager.class); } } 07070100000055000041FD0000000000000000000000056615495400000000000000000000000000000000000000000000003C00000000spacewalk-search/src/java/com/redhat/satellite/search/index07070100000056000081B40000000000000000000000016615495400000797000000000000000000000000000000000000005600000000spacewalk-search/src/java/com/redhat/satellite/search/index/HardwareDeviceResult.java/* * Copyright (c) 2008--2010 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index; import org.apache.lucene.document.Document; /** * Result * @version $Rev$ */ public class HardwareDeviceResult extends Result { private String serverId; /** * Constructor */ public HardwareDeviceResult() { super(); serverId = "N/A"; } /** * Constructs a result object * @param rankIn order of results returned from lucene * @param scoreIn score of this hit as defined by lucene query * @param doc lucene document containing data fields */ public HardwareDeviceResult(int rankIn, float scoreIn, Document doc) { if (doc.getField("description") != null) { setName(doc.getField("description").stringValue()); } if (doc.getField("serverId") != null) { setServerId(doc.getField("serverId").stringValue()); } if (doc.getField("id") != null) { setId(doc.getField("id").stringValue()); } setRank(rankIn); setScore(scoreIn); } /** * @return the serverId */ public String getServerId() { return serverId; } /** * @param serverIdIn the serverId to set */ public void setServerId(String serverIdIn) { this.serverId = serverIdIn; } } 07070100000057000081B4000000000000000000000001661549540000710F000000000000000000000000000000000000004E00000000spacewalk-search/src/java/com/redhat/satellite/search/index/IndexManager.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index; import com.redhat.satellite.search.config.Configuration; import com.redhat.satellite.search.index.builder.BuilderFactory; import com.redhat.satellite.search.index.ngram.NGramAnalyzer; import com.redhat.satellite.search.index.ngram.NGramQueryParser; import com.redhat.satellite.search.rpc.handlers.IndexHandler; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.PerFieldAnalyzerWrapper; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.DateTools; import org.apache.lucene.document.Document; import org.apache.lucene.index.CorruptIndexException; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.queryParser.ParseException; import org.apache.lucene.queryParser.QueryParser; import org.apache.lucene.search.Explanation; import org.apache.lucene.search.Hits; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FSDirectory; import org.apache.lucene.store.LockObtainFailedException; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeMap; /** * Indexing workhorse class * * @version $Rev$ */ public class IndexManager { private static Logger log = LogManager.getLogger(IndexManager.class); private String indexWorkDir; private int maxHits; private double score_threshold; private double system_score_threshold; private double errata_score_threshold; private double errata_advisory_score_threshold; private int min_ngram; private int max_ngram; private boolean filterDocResults = false; private boolean explainResults = false; // Name conflict with our Configuration class and Hadoop's private Map<String, String> docLocaleLookUp = new TreeMap<String, String> (String.CASE_INSENSITIVE_ORDER); /** * Constructor * * @param config application config */ public IndexManager(Configuration config) { maxHits = config.getInt("search.max_hits_returned", 0); indexWorkDir = config.getString("search.index_work_dir", null); if (indexWorkDir == null) { throw new IllegalArgumentException( "search.index_work_dir config entry " + "is missing"); } if (!indexWorkDir.endsWith("/")) { indexWorkDir += "/"; } score_threshold = config.getDouble("search.score_threshold", .30); system_score_threshold = config.getDouble("search.system_score_threshold", .30); errata_score_threshold = config.getDouble("search.errata_score_threshold", .30); errata_advisory_score_threshold = config.getDouble("search.errata.advisory_score_threshold", .30); min_ngram = config.getInt("search.min_ngram", 1); max_ngram = config.getInt("search.max_ngram", 5); filterDocResults = config.getBoolean("search.doc.limit_results"); explainResults = config.getBoolean("search.log.explain.results"); } /** * @return String of the index working directory */ public String getIndexWorkDir() { return indexWorkDir; } /** * Query a index * * @param indexName name of the index * @param query search query * @param lang language * @return list of hits * @throws IndexingException if there is a problem indexing the content. * @throws QueryParseException */ public List<Result> search(String indexName, String query, String lang) throws IndexingException, QueryParseException { return search(indexName, query, lang, false); } /** * Query a index * * @param indexName name of the index * @param query search query * @param lang language * @param isFineGrained * true: will limit results, less are returned but they are closer * to the search query, useful for advanced/free form queries * * false: will allow queries to be more flexible returning words * which are spelled similarly * * @return list of hits * @throws IndexingException if there is a problem indexing the content. * @throws QueryParseException */ public List<Result> search(String indexName, String query, String lang, boolean isFineGrained) throws IndexingException, QueryParseException { IndexSearcher searcher = null; IndexReader reader = null; List<Result> retval = null; try { reader = getIndexReader(indexName, lang); searcher = getIndexSearcher(indexName, lang); QueryParser qp = getQueryParser(indexName, lang, isFineGrained); Query q = qp.parse(query); if (log.isDebugEnabled()) { log.debug("Original query was: " + query); log.debug("Parsed Query is: " + q.toString()); } Hits hits = searcher.search(q); if (log.isDebugEnabled()) { log.debug(hits.length() + " results were found."); } Set<Term> queryTerms = null; try { queryTerms = new HashSet<Term>(); Query newQ = q.rewrite(reader); newQ.extractTerms(queryTerms); } catch (Exception e) { e.printStackTrace(); throw new QueryParseException(e); } retval = processHits(indexName, hits, queryTerms, query, lang); if (explainResults) { debugExplainResults(indexName, hits, searcher, q, queryTerms); } } catch (IOException e) { // this exception is thrown, when there're no packages or errata on the system // and the user performs a search // if this is the case, just return 0 results, otherwise rethrow the exception if (!e.getMessage().contains("no segments* file found in org.apache.lucene.store.FSDirectory@/var/lib/rhn/search/indexes")) { throw new IndexingException(e); } log.error(e.getMessage()); retval = new ArrayList<Result>(); } catch (ParseException e) { throw new QueryParseException("Could not parse query: '" + query + "'"); } finally { try { if (searcher != null) { searcher.close(); } if (reader != null) { reader.close(); } } catch (IOException ex) { throw new IndexingException(ex); } } return retval; } /** * Create an empty index if it exists * * @param indexName index to use * @param lang language. * @throws IndexingException something went wrong adding the document */ public void createIndex(String indexName, String lang) throws IndexingException { try { IndexWriter writer = getIndexWriter(indexName, lang); try { writer.flush(); } finally { try { writer.close(); } finally { // unlock it if it is locked. unlockIndex(indexName); } } } catch (CorruptIndexException e) { throw new IndexingException(e); } catch (LockObtainFailedException e) { throw new IndexingException(e); } catch (IOException e) { throw new IndexingException(e); } } /** * Adds a document to an index * * @param indexName index to use * @param doc Document to be indexed. * @param lang language. * @throws IndexingException something went wrong adding the document */ public void addToIndex(String indexName, Document doc, String lang) throws IndexingException { try { IndexWriter writer = getIndexWriter(indexName, lang); try { writer.addDocument(doc); writer.flush(); } finally { try { writer.close(); } finally { // unlock it if it is locked. unlockIndex(indexName); } } } catch (CorruptIndexException e) { throw new IndexingException(e); } catch (LockObtainFailedException e) { throw new IndexingException(e); } catch (IOException e) { throw new IndexingException(e); } } /** * @param indexName * @param doc document with data to index * @param uniqueField field in doc which identifies this uniquely * @param lang language * @throws IndexingException */ public void addUniqueToIndex(String indexName, Document doc, String uniqueField, String lang) throws IndexingException { IndexReader reader = null; int numFound = 0; try { reader = getIndexReader(indexName, lang); Term term = new Term(uniqueField, doc.get(uniqueField)); numFound = reader.docFreq(term); } catch (FileNotFoundException e) { // Index doesn't exist, so this add will be unique // we don't need to do anything/ } catch (IOException e) { throw new IndexingException(e); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { // } } } if (numFound > 0) { log.info("Found " + numFound + " <" + indexName + " docs for " + uniqueField + ":" + doc.get(uniqueField) + " will remove them now."); removeFromIndex(indexName, uniqueField, doc.get(uniqueField)); } addToIndex(indexName, doc, lang); } /** * Remove a document from an index * * @param indexName index to use * @param uniqueField field name which represents this data's unique id * @param objectId unique document id * @throws IndexingException something went wrong removing the document */ public void removeFromIndex(String indexName, String uniqueField, String objectId) throws IndexingException { log.info("Removing <" + indexName + "> " + uniqueField + ":" + objectId); Term t = new Term(uniqueField, objectId); IndexReader reader; try { reader = getIndexReader(indexName, IndexHandler.DEFAULT_LANG); try { reader.deleteDocuments(t); reader.flush(); } finally { if (reader != null) { reader.close(); } } } catch (CorruptIndexException e) { throw new IndexingException(e); } catch (IOException e) { throw new IndexingException(e); } } /** * Unlocks the index at the given directory if it is currently locked. * Otherwise, does nothing. * @param indexName index name * @throws IOException thrown if there is a problem unlocking the index. */ private void unlockIndex(String indexName) throws IOException { String path = indexWorkDir + indexName; File f = new File(path); Directory dir = FSDirectory.getDirectory(f); if (IndexReader.isLocked(dir)) { IndexReader.unlock(dir); } } private IndexWriter getIndexWriter(String name, String lang) throws CorruptIndexException, LockObtainFailedException, IOException { String path = indexWorkDir + name; File f = new File(path); f.mkdirs(); Analyzer analyzer = getAnalyzer(name, lang); IndexWriter writer = new IndexWriter(path, analyzer); writer.setUseCompoundFile(true); return writer; } private IndexReader getIndexReader(String indexName, String locale) throws CorruptIndexException, IOException { String path = indexWorkDir + indexName; log.info("IndexManager::getIndexReader(" + indexName + ", " + locale + ") path = " + path); File f = new File(path); IndexReader retval = IndexReader.open(FSDirectory.getDirectory(f)); return retval; } private IndexSearcher getIndexSearcher(String indexName, String locale) throws CorruptIndexException, IOException { String path = indexWorkDir + indexName; log.info("IndexManager::getIndexSearcher(" + indexName + ", " + locale + ") path = " + path); IndexSearcher retval = new IndexSearcher(path); return retval; } private QueryParser getQueryParser(String indexName, String lang, boolean isFineGrained) { if (log.isDebugEnabled()) { log.debug("getQueryParser(" + indexName + ", " + lang + ", " + isFineGrained + ")"); } Analyzer analyzer = getAnalyzer(indexName, lang); QueryParser qp = new NGramQueryParser("name", analyzer, isFineGrained); qp.setDateResolution(DateTools.Resolution.MINUTE); return qp; } private Analyzer getAnalyzer(String indexName, String lang) { if (log.isDebugEnabled()) { log.debug("getAnalyzer(" + indexName + ", " + lang + ")"); } if (indexName.compareTo(BuilderFactory.SERVER_TYPE) == 0) { return getServerAnalyzer(); } else if (indexName.compareTo(BuilderFactory.ERRATA_TYPE) == 0) { return getErrataAnalyzer(); } else if (indexName.compareTo(BuilderFactory.SNAPSHOT_TAG_TYPE) == 0) { return getSnapshotTagAnalyzer(); } else if (indexName.compareTo(BuilderFactory.HARDWARE_DEVICE_TYPE) == 0) { return getHardwareDeviceAnalyzer(); } else if (indexName.compareTo(BuilderFactory.SERVER_CUSTOM_INFO_TYPE) == 0) { return getServerCustomInfoAnalyzer(); } else { log.debug(indexName + " using getDefaultAnalyzer()"); return getDefaultAnalyzer(); } } private List<Result> processHits(String indexName, Hits hits, Set<Term> queryTerms, String query, String lang) throws IOException { List<Result> retval = new ArrayList<Result>(); for (int x = 0; x < hits.length(); x++) { Document doc = hits.doc(x); Result pr = null; if (!isScoreAcceptable(indexName, hits, x, query)) { break; } else if (indexName.compareTo(BuilderFactory.HARDWARE_DEVICE_TYPE) == 0) { pr = new HardwareDeviceResult(x, hits.score(x), doc); } else if (indexName.compareTo(BuilderFactory.SNAPSHOT_TAG_TYPE) == 0) { pr = new SnapshotTagResult(x, hits.score(x), doc); } else if (indexName.compareTo(BuilderFactory.SERVER_CUSTOM_INFO_TYPE) == 0) { pr = new ServerCustomInfoResult(x, hits.score(x), doc); } else if (indexName.compareTo(BuilderFactory.XCCDF_IDENT_TYPE) == 0) { pr = new Result(x, doc.getField("id").stringValue(), doc.getField("identifier").stringValue(), hits.score(x)); } else if (indexName.compareTo(BuilderFactory.SERVER_TYPE) == 0) { pr = new Result(x, doc.getField("id").stringValue(), doc.getField("name").stringValue(), hits.score(x), doc.getField("uuid").stringValue()); } else { //Type Errata and Package pr = new Result(x, doc.getField("id").stringValue(), doc.getField("name").stringValue(), hits.score(x)); } if (log.isDebugEnabled()) { log.debug("Hit[" + x + "] Score = " + hits.score(x) + ", Result = " + pr); } /** * matchingField will help the webUI to understand what field was responsible * for this match. Later implementation should use "Explanation" to determine * field, for now we will simply grab one term and return it's field. */ try { MatchingField match = new MatchingField(query, doc, queryTerms); pr.setMatchingField(match.getFieldName()); pr.setMatchingFieldValue(match.getFieldValue()); log.info("hit[" + x + "] matchingField is being set to: <" + pr.getMatchingField() + "> based on passed in query field. " + "matchingFieldValue = " + pr.getMatchingFieldValue()); } catch (Exception e) { log.error("Caught exception: ", e); } if (pr != null) { retval.add(pr); } if (maxHits > 0 && x == maxHits) { break; } } return retval; } /** * * @param indexName * @param hits * @param x * @param query * @return true - score is acceptable * false - score is NOT acceptable * @throws IOException */ private boolean isScoreAcceptable(String indexName, Hits hits, int x, String queryIn) throws IOException { String guessMainQueryTerm = MatchingField.getFirstFieldName(queryIn); /** * Dropping matches which are a poor fit. * system searches are filtered based on "system_score_threshold" * other searches will return 10 best matches, then filter anything below * "score_threshold" */ if ((indexName.compareTo(BuilderFactory.SERVER_TYPE) == 0) || (indexName.compareTo(BuilderFactory.SERVER_CUSTOM_INFO_TYPE) == 0) || (indexName.compareTo(BuilderFactory.SNAPSHOT_TAG_TYPE) == 0) || (indexName.compareTo(BuilderFactory.HARDWARE_DEVICE_TYPE) == 0)) { if (hits.score(x) < system_score_threshold) { if (log.isDebugEnabled()) { log.debug("hits.score(" + x + ") is " + hits.score(x)); log.debug("Filtering out search results from " + x + " to " + hits.length() + ", due to their score being below " + "system_score_threshold = " + system_score_threshold); } return false; } } else if (indexName.compareTo(BuilderFactory.ERRATA_TYPE) == 0) { if (guessMainQueryTerm.compareTo("name") == 0) { if (hits.score(x) < errata_advisory_score_threshold) { if (log.isDebugEnabled()) { log.debug("hits.score(" + x + ") is " + hits.score(x)); log.debug("Filtering out search results from " + x + " to " + hits.length() + ", due to their score being below " + "errata_advisory_score_threshold = " + errata_advisory_score_threshold); } return false; } } else { if (hits.score(x) < errata_score_threshold) { if (log.isDebugEnabled()) { log.debug("hits.score(" + x + ") is " + hits.score(x)); log.debug("Filtering out search results from " + x + " to " + hits.length() + ", due to their score being below " + "errata_score_threshold = " + errata_score_threshold); } return false; } } } else if (((hits.score(x) < score_threshold) && (x > 10)) || (hits.score(x) < 0.001)) { /** * Dropping matches which are a poor fit. * First term is configurable, it allows matches like spelling errors or * suggestions to be possible. * Second term is intended to get rid of pure and utter crap hits */ if (log.isDebugEnabled()) { log.debug("hits.score(" + x + ") is " + hits.score(x)); log.debug("Filtering out search results from " + x + " to " + hits.length() + ", due to their score being below " + "score_threshold = " + score_threshold); } return false; } return true; } /** * Removes any documents which are not related to the passed in Set of good value * @param ids Set of ids of all known/good values * @param indexName index name to operate on * @param uniqField the name of the field in the Document to uniquely identify * this record * @return the number of documents deleted */ public int deleteRecordsNotInList(Set<String> ids, String indexName, String uniqField) { int count = 0; IndexReader reader = null; try { reader = getIndexReader(indexName, IndexHandler.DEFAULT_LANG); // Use maxDoc() to iterate over all docs, numDocs() returns the // number of currently alive docs leaving out the deleted ones. int maxDoc = reader.maxDoc(); for (int i = 0; i < maxDoc; i++) { if (!reader.isDeleted(i)) { Document doc = reader.document(i); String uniqId = doc.getField(uniqField).stringValue(); if (!ids.contains(uniqId)) { log.info(indexName + ":" + uniqField + ": <" + uniqId + "> not found in list of current/good values " + "assuming this has been deleted from Database and we " + "should remove it."); removeFromIndex(indexName, uniqField, uniqId); count++; } } } } catch (IOException e) { e.printStackTrace(); log.info("deleteRecordsNotInList() caught exception : " + e); } catch (IndexingException e) { e.printStackTrace(); log.info("deleteRecordsNotInList() caught exception : " + e); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { // } } } return count; } private void debugExplainResults(String indexName, Hits hits, IndexSearcher searcher, Query q, Set<Term> queryTerms) throws IOException { log.debug("Parsed Query is " + q.toString()); log.debug("Looking at index: " + indexName); for (int i = 0; i < hits.length(); i++) { if ((i < 10)) { Document doc = hits.doc(i); Float score = hits.score(i); Explanation ex = searcher.explain(q, hits.id(i)); log.debug("Looking at hit<" + i + ", " + hits.id(i) + ", " + score + ">: " + doc); log.debug("Explanation: " + ex); MatchingField match = new MatchingField(q.toString(), doc, queryTerms); String fieldName = match.getFieldName(); String fieldValue = match.getFieldValue(); log.debug("Guessing that matched fieldName is " + fieldName + " = " + fieldValue); } } } private Analyzer getServerAnalyzer() { PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(new NGramAnalyzer(min_ngram, max_ngram)); analyzer.addAnalyzer("checkin", new KeywordAnalyzer()); analyzer.addAnalyzer("registered", new KeywordAnalyzer()); analyzer.addAnalyzer("ram", new KeywordAnalyzer()); analyzer.addAnalyzer("swap", new KeywordAnalyzer()); analyzer.addAnalyzer("cpuMHz", new KeywordAnalyzer()); analyzer.addAnalyzer("cpuNumberOfCpus", new KeywordAnalyzer()); return analyzer; } private Analyzer getErrataAnalyzer() { PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(new NGramAnalyzer(min_ngram, max_ngram)); analyzer.addAnalyzer("advisoryName", new KeywordAnalyzer()); analyzer.addAnalyzer("synopsis", new StandardAnalyzer()); analyzer.addAnalyzer("description", new StandardAnalyzer()); analyzer.addAnalyzer("topic", new StandardAnalyzer()); analyzer.addAnalyzer("solution", new StandardAnalyzer()); return analyzer; } private Analyzer getSnapshotTagAnalyzer() { PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(new NGramAnalyzer(min_ngram, max_ngram)); analyzer.addAnalyzer("id", new KeywordAnalyzer()); analyzer.addAnalyzer("snapshotId", new KeywordAnalyzer()); analyzer.addAnalyzer("orgId", new KeywordAnalyzer()); analyzer.addAnalyzer("serverId", new KeywordAnalyzer()); analyzer.addAnalyzer("tagNameId", new KeywordAnalyzer()); analyzer.addAnalyzer("created", new KeywordAnalyzer()); analyzer.addAnalyzer("modified", new KeywordAnalyzer()); return analyzer; } private Analyzer getHardwareDeviceAnalyzer() { PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(new NGramAnalyzer(min_ngram, max_ngram)); analyzer.addAnalyzer("id", new KeywordAnalyzer()); analyzer.addAnalyzer("serverId", new KeywordAnalyzer()); analyzer.addAnalyzer("pciType", new KeywordAnalyzer()); return analyzer; } private Analyzer getServerCustomInfoAnalyzer() { PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(new NGramAnalyzer(min_ngram, max_ngram)); analyzer.addAnalyzer("id", new KeywordAnalyzer()); analyzer.addAnalyzer("serverId", new KeywordAnalyzer()); analyzer.addAnalyzer("created", new KeywordAnalyzer()); analyzer.addAnalyzer("modified", new KeywordAnalyzer()); analyzer.addAnalyzer("createdBy", new KeywordAnalyzer()); analyzer.addAnalyzer("lastModifiedBy", new KeywordAnalyzer()); return analyzer; } private Analyzer getDefaultAnalyzer() { PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(new NGramAnalyzer(min_ngram, max_ngram)); analyzer.addAnalyzer("id", new KeywordAnalyzer()); analyzer.addAnalyzer("arch", new KeywordAnalyzer()); analyzer.addAnalyzer("epoch", new KeywordAnalyzer()); analyzer.addAnalyzer("version", new KeywordAnalyzer()); analyzer.addAnalyzer("release", new KeywordAnalyzer()); analyzer.addAnalyzer("filename", new KeywordAnalyzer()); return analyzer; } } 07070100000058000081B4000000000000000000000001661549540000062E000000000000000000000000000000000000005300000000spacewalk-search/src/java/com/redhat/satellite/search/index/IndexingException.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index; /** * Something vewy vewy bad happened while indexing content * * @version $Rev$ */ public class IndexingException extends Exception { private static final long serialVersionUID = 3037442150973499615L; /** * Simple no-arg constructor */ public IndexingException() { super(); } /** * Constructor * * @param message * error message * @param cause * root cause */ public IndexingException(String message, Throwable cause) { super(message, cause); } /** * Constructor * * @param message * error message */ public IndexingException(String message) { super(message); } /** * Constructor * * @param cause * root cause */ public IndexingException(Throwable cause) { super(cause); } } 07070100000059000081B400000000000000000000000166154954000005F3000000000000000000000000000000000000005100000000spacewalk-search/src/java/com/redhat/satellite/search/index/KeywordAnalyzer.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index; import java.io.Reader; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.CharTokenizer; /** * KeywordAnalyzer * Used to retain all characters associated with a search term. Basically * use this if you don't want the search term to be tokenized. * * @version $Rev$ */ public class KeywordAnalyzer extends Analyzer { /** * Will return the exact test passed in. *@param fieldName ignored value *@param reader Reader containing data to parse *@return TokenStream which contains exact text passed in. */ @Override public TokenStream tokenStream(String fieldName, Reader reader) { return new CharTokenizer(reader) { protected boolean isTokenChar(char c) { return true; } }; } } 0707010000005A000081B40000000000000000000000016615495400000FDA000000000000000000000000000000000000004F00000000spacewalk-search/src/java/com/redhat/satellite/search/index/MatchingField.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.NumberTools; import org.apache.lucene.index.Term; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; /** * Purpose of this class is to guess what field in the Document is responsible * for this being flagged as a hit. We will use the query and terms as hints. * @version $Rev$ */ public class MatchingField { private static Logger log = LogManager.getLogger(IndexManager.class); protected Document doc; protected Object[] terms; protected String query; protected Map<String, Boolean> needNumberToolsAdjust; /** * * @param queryIn query used in search * @param docIn document results returned as a match * @param termsIn terms from a parsed query */ public MatchingField(String queryIn, Document docIn, Set<Term> termsIn) { query = queryIn; doc = docIn; if ((termsIn != null)) { terms = termsIn.toArray(); } else { terms = new Term[0]; } needNumberToolsAdjust = new HashMap<String, Boolean>(); needNumberToolsAdjust.put("cpuMHz", true); needNumberToolsAdjust.put("cpuBogoMIPS", true); needNumberToolsAdjust.put("cpuMHz", true); needNumberToolsAdjust.put("cpuNumberOfCpus", true); needNumberToolsAdjust.put("ram", true); needNumberToolsAdjust.put("swap", true); } /** * * @return field name most responsible for this document being a match */ public String getFieldName() { if (terms.length > 0) { return ((Term)terms[0]).field(); } return getFirstFieldName(query); } /** * * @return value most responsible for this document being a match */ public String getFieldValue() { String fieldName = getFieldName(); Field f = doc.getField(fieldName); if (f == null) { StringBuffer sb = new StringBuffer(); sb.append("[length=" + terms.length + "; "); for (Object o : terms) { sb.append(o + ", "); } sb.append("]"); log.info("Unable to get matchingFieldValue for field : " + fieldName + " with query: " + query + ", and terms = " + sb.toString()); log.info("Document = " + doc); return ""; } String value = f.stringValue(); if (needNumberToolsAdjust.containsKey(fieldName)) { Long temp = NumberTools.stringToLong(value); value = temp.toString(); } return value; } /** * * @param queryIn * @return first term in query, which is a good guess as to being the most * important term in the query. * * */ public static String getFirstFieldName(String queryIn) { // remove first parenthesis, this shows up when you do a // Query.toString(), package searches generally have this if (queryIn.startsWith("(")) { queryIn = queryIn.substring(1); } StringTokenizer tokens = new StringTokenizer(queryIn, ":"); return tokens.nextToken(); } } 0707010000005B000081B400000000000000000000000166154954000005A0000000000000000000000000000000000000005500000000spacewalk-search/src/java/com/redhat/satellite/search/index/QueryParseException.java/* * Copyright (c) 2008--2010 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index; /** * QueryParseException thrown if there is a problem parsing the query input. * @version $Rev$ */ public class QueryParseException extends Exception { /** * Simple no-arg constructor */ public QueryParseException() { super(); } /** * Constructor * @param message error message * @param cause root cause */ public QueryParseException(String message, Throwable cause) { super(message, cause); } /** * Constructor * @param message error message */ public QueryParseException(String message) { super(message); } /** * Constructor * @param cause root cause */ public QueryParseException(Throwable cause) { super(cause); } } 0707010000005C000081B40000000000000000000000016615495400001026000000000000000000000000000000000000004800000000spacewalk-search/src/java/com/redhat/satellite/search/index/Result.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index; /** * PackageResult * @version $Rev$ */ public class Result { private int rank = 0; private String id = ""; private String name = ""; private String uuid = ""; private float score = 0.0f; /** TODO: * matchingField could be used to possibly give more info into what made * lucene think this was a good match.. */ private String matchingField = ""; private String matchingFieldValue = ""; /** * Constructor */ public Result() { rank = -1; id = ""; name = ""; uuid = ""; score = 0; } /** * Constructs a pre populated * @param r rank * @param idIn package id * @param nameIn package name */ public Result(int r, String idIn, String nameIn, float scoreIn) { rank = r; id = idIn; name = nameIn; score = scoreIn; } /** * Constructs a pre populated * @param r rank * @param idIn package id * @param nameIn package name * @param uuidIn uuid name */ public Result(int r, String idIn, String nameIn, float scoreIn, String uuidIn) { rank = r; id = idIn; name = nameIn; score = scoreIn; uuid = uuidIn; } /** * Sets the rank * @param rankIn rank */ public void setRank(int rankIn) { rank = rankIn; } /** * Returns the rank. * @return the rank. */ public int getRank() { return rank; } /** * Sets the id * @param idIn id */ public void setId(String idIn) { id = idIn; } /** * Returns the package id. * @return the package id. */ public String getId() { return id; } /** * Sets the name * @param nameIn name */ public void setName(String nameIn) { name = nameIn; } /** * Returns the package name. * @return the package name. */ public String getName() { return name; } /** * Sets the score from lucene * @param scoreIn score */ public void setScore(float scoreIn) { score = scoreIn; } /** * Returns the score. * @return the score. */ public float getScore() { return score; } /** * @return the matchingField */ public String getMatchingField() { return matchingField; } /** * @param matchingFieldIn the matchingField to set */ public void setMatchingField(String matchingFieldIn) { this.matchingField = matchingFieldIn; } /** * @return the matchingFieldValue */ public String getMatchingFieldValue() { return matchingFieldValue; } /** * @param matchingFieldValueIn the matchingFieldValue to set */ public void setMatchingFieldValue(String matchingFieldValueIn) { this.matchingFieldValue = matchingFieldValueIn; } /** * @return the uuid */ public String getUuid() { return uuid; } /** * @param uuidIn the uuid to set */ public void setUuid(String uuidIn) { this.uuid = uuidIn; } /** * @return the string representation of this object **/ public String toString() { return "Name = " + getName() + ", Id = " + getId() + ", Score = " + getScore() + ", Rank = " + getRank() + ", UUID = " + getUuid(); } } 0707010000005D000081B400000000000000000000000166154954000008BE000000000000000000000000000000000000005800000000spacewalk-search/src/java/com/redhat/satellite/search/index/ServerCustomInfoResult.java/* * Copyright (c) 2008--2010 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index; import org.apache.lucene.document.Document; /** * ServerCustomInfoResult * @version $Rev$ */ public class ServerCustomInfoResult extends Result { private String serverId; private String value; /** * Constructor */ public ServerCustomInfoResult() { super(); serverId = "N/A"; value = "N/A"; } /** * Constructs a result object * @param rankIn order of results returned from lucene * @param scoreIn score of this hit as defined by lucene query * @param doc lucene document containing data fields */ public ServerCustomInfoResult(int rankIn, float scoreIn, Document doc) { if (doc.getField("value") != null) { setValue(doc.getField("value").stringValue()); } if (doc.getField("serverId") != null) { setServerId(doc.getField("serverId").stringValue()); } if (doc.getField("id") != null) { setId(doc.getField("id").stringValue()); } setRank(rankIn); setScore(scoreIn); } /** * @return the serverId */ public String getServerId() { return serverId; } /** * @param serverIdIn the serverId to set */ public void setServerId(String serverIdIn) { this.serverId = serverIdIn; } /** * @return the value */ public String getValue() { return value; } /** * @param valueIn the value to set */ public void setValue(String valueIn) { this.value = valueIn; } } 0707010000005E000081B40000000000000000000000016615495400000944000000000000000000000000000000000000005300000000spacewalk-search/src/java/com/redhat/satellite/search/index/SnapshotTagResult.java/* * Copyright (c) 2008--2010 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index; import org.apache.lucene.document.Document; /** * SnapshotTagResult * @version $Rev$ */ public class SnapshotTagResult extends Result { private String serverId; private String snapshotId; /** * Constructor */ public SnapshotTagResult() { super(); serverId = "N/A"; } /** * Constructs a result object * @param rankIn order of results returned from lucene * @param scoreIn score of this hit as defined by lucene query * @param doc lucene document containing data fields */ public SnapshotTagResult(int rankIn, float scoreIn, Document doc) { if (doc.getField("id") != null) { setId(doc.getField("id").stringValue()); } if (doc.getField("name") != null) { setName(doc.getField("name").stringValue()); } if (doc.getField("serverId") != null) { setServerId(doc.getField("serverId").stringValue()); } if (doc.getField("snapshotId") != null) { setSnapshotId(doc.getField("snapshotId").stringValue()); } setRank(rankIn); setScore(scoreIn); } /** * @return the serverId */ public String getServerId() { return serverId; } /** * @param serverIdIn the serverId to set */ public void setServerId(String serverIdIn) { this.serverId = serverIdIn; } /** * @return the snapshotId */ public String getSnapshotId() { return snapshotId; } /** * @param snapshotIdIn the snapshotId to set */ public void setSnapshotId(String snapshotIdIn) { this.snapshotId = snapshotIdIn; } } 0707010000005F000041FD0000000000000000000000036615495400000000000000000000000000000000000000000000004400000000spacewalk-search/src/java/com/redhat/satellite/search/index/builder07070100000060000081B400000000000000000000000166154954000009B0000000000000000000000000000000000000005800000000spacewalk-search/src/java/com/redhat/satellite/search/index/builder/BuilderFactory.java/* * Copyright (c) 2008--2012 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.builder; /** * BuilderFactory * @version $Rev$ */ public class BuilderFactory { public static final String ERRATA_TYPE = "errata"; public static final String PACKAGES_TYPE = "packages"; public static final String SERVER_TYPE = "server"; public static final String HARDWARE_DEVICE_TYPE = "hwdevice"; public static final String SNAPSHOT_TAG_TYPE = "snapshotTag"; public static final String SERVER_CUSTOM_INFO_TYPE = "serverCustomInfo"; public static final String XCCDF_IDENT_TYPE = "xccdfIdent"; /** * Private constructor. */ private BuilderFactory() { } /** * Returns a Builder suitable for building the wanted type. Invalid types * will throw an UnsupportedOperationException. * @param type Valid type of builder. * @return Suitable builder. */ public static DocumentBuilder getBuilder(String type) { if (ERRATA_TYPE.equals(type)) { return new ErrataDocumentBuilder(); } else if (PACKAGES_TYPE.equals(type)) { return new PackageDocumentBuilder(); } else if (SERVER_TYPE.equals(type)) { return new ServerDocumentBuilder(); } else if (HARDWARE_DEVICE_TYPE.equals(type)) { return new HardwareDeviceDocumentBuilder(); } else if (SNAPSHOT_TAG_TYPE.equals(type)) { return new SnapshotTagDocumentBuilder(); } else if (SERVER_CUSTOM_INFO_TYPE.equals(type)) { return new ServerCustomInfoDocumentBuilder(); } else if (XCCDF_IDENT_TYPE.equals(type)) { return new XccdfIdentDocumentBuilder(); } else { throw new UnsupportedOperationException(type + " is an unsuppported type"); } } } 07070100000061000081B40000000000000000000000016615495400000508000000000000000000000000000000000000005900000000spacewalk-search/src/java/com/redhat/satellite/search/index/builder/DocumentBuilder.java/* * Copyright (c) 2008--2010 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.builder; import org.apache.lucene.document.Document; import java.util.Map; /** * DocumentBuilder * @version $Rev$ */ public interface DocumentBuilder { /** * Builds a Lucene Document using the given object id and metadata map. * The document will contain an "id" field with the value of the object id, * and fields corresponding to the keys of the metadata and their values. * @param objId Object id * @param metadata key:value pairs describing the object. * @return Lucene Document for indexing. */ Document buildDocument(Long objId, Map<String, String> metadata); } 07070100000062000081B40000000000000000000000016615495400000851000000000000000000000000000000000000005F00000000spacewalk-search/src/java/com/redhat/satellite/search/index/builder/ErrataDocumentBuilder.java/* * Copyright (c) 2008--2011 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.builder; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import java.util.Iterator; import java.util.Map; /** * ErrataDocumentBuilder * @version $Rev$ */ public class ErrataDocumentBuilder implements DocumentBuilder { // TODO: add some information about fields and their indexing states. /** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) { Field.Store store = Field.Store.NO; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); if (name.equals("name") || name.equals("advisoryName")) { store = Field.Store.YES; } else if (name.equals("synopsis") || name.equals("description") || name.equals("topic") || name.equals("solution")) { // index, but do not store } else { // skip - do not store or index continue; } doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; } } 07070100000063000081B4000000000000000000000001661549540000077C000000000000000000000000000000000000006700000000spacewalk-search/src/java/com/redhat/satellite/search/index/builder/HardwareDeviceDocumentBuilder.java/* * Copyright (c) 2008--2010 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.builder; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import java.util.Iterator; import java.util.Map; /** * HardwareDeviceDocumentBuilder * @version $Rev$ */ public class HardwareDeviceDocumentBuilder implements DocumentBuilder { /** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) { Field.Store store = Field.Store.YES; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); if (name.equals("name") || (name.equals("description"))) { store = Field.Store.YES; } else if (name.equals("serverId")) { store = Field.Store.YES; tokenize = Field.Index.UN_TOKENIZED; } doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; } } 07070100000064000081B400000000000000000000000166154954000007BF000000000000000000000000000000000000006000000000spacewalk-search/src/java/com/redhat/satellite/search/index/builder/PackageDocumentBuilder.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.builder; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import java.util.Iterator; import java.util.Map; /** * PackageDocumentBuilder * @version $Rev$ */ public class PackageDocumentBuilder implements DocumentBuilder { /** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter .hasNext();) { Field.Store store = Field.Store.YES; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); if (name.equals("name")) { store = Field.Store.YES; } else if (name.equals("arch") || name.equals("filename") || name.equals("version") || name.equals("release") || name.equals("epoch")) { tokenize = Field.Index.UN_TOKENIZED; } doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; } } 07070100000065000081B4000000000000000000000001661549540000086A000000000000000000000000000000000000006900000000spacewalk-search/src/java/com/redhat/satellite/search/index/builder/ServerCustomInfoDocumentBuilder.java/* * Copyright (c) 2008--2010 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.builder; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import java.util.Iterator; import java.util.Map; /** * ServerCustomInfoDocumentBuilder * @version $Rev$ */ public class ServerCustomInfoDocumentBuilder implements DocumentBuilder { /** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) { Field.Store store = Field.Store.YES; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); if (name.equals("value")) { store = Field.Store.YES; } else if (name.equals("created") || (name.equals("modified"))) { store = Field.Store.YES; tokenize = Field.Index.UN_TOKENIZED; } else if (name.equals("serverId") || name.equals("createdBy") || name.equals("lastModifiedBy")) { store = Field.Store.YES; tokenize = Field.Index.UN_TOKENIZED; } doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; } } 07070100000066000081B40000000000000000000000016615495400000A68000000000000000000000000000000000000005F00000000spacewalk-search/src/java/com/redhat/satellite/search/index/builder/ServerDocumentBuilder.java/* * Copyright (c) 2008--2012 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.builder; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import java.util.Iterator; import java.util.Map; /** * ServerDocumentBuilder * @version $Rev$ */ public class ServerDocumentBuilder implements DocumentBuilder { /** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); // Keep 'id' UN_TOKENIZED, this is needed to determine 'uniqueness' // if you tokenize this it will break deleting documents, we'll // no longer have unique documents per id. doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); // This is the tokenized form of 'id' so we can do searches on it and // use ngram flexibility doc.add(new Field("system_id", objId.toString(), Field.Store.YES, Field.Index.TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) { Field.Store store = Field.Store.YES; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); if (name.equals("name") || name.equals("cpuModel") || name.equals("hostname") || name.equals("ipaddr") || name.equals("ip6addr") || (name.equals("runningKernel"))) { store = Field.Store.YES; } else if (name.equals("checkin") || name.equals("registered") || name.equals("ram") || name.equals("swap") || name.equals("cpuMHz") | name.equals("cpuNumberOfCpus")) { store = Field.Store.YES; tokenize = Field.Index.UN_TOKENIZED; } doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; } } 07070100000067000081B40000000000000000000000016615495400000873000000000000000000000000000000000000006400000000spacewalk-search/src/java/com/redhat/satellite/search/index/builder/SnapshotTagDocumentBuilder.java/* * Copyright (c) 2008--2010 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.builder; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import java.util.Iterator; import java.util.Map; /** * SnapshotTagDocumentBuilder * @version $Rev$ */ public class SnapshotTagDocumentBuilder implements DocumentBuilder { /** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) { Field.Store store = Field.Store.YES; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); if (name.equals("name")) { store = Field.Store.YES; } else if (name.equals("created") || (name.equals("modified"))) { store = Field.Store.YES; tokenize = Field.Index.UN_TOKENIZED; } else if (name.equals("snapshotId") || name.equals("tagNameId") || name.equals("serverId") || name.equals("orgId")) { store = Field.Store.YES; tokenize = Field.Index.UN_TOKENIZED; } doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; } } 07070100000068000081B40000000000000000000000016615495400000653000000000000000000000000000000000000006300000000spacewalk-search/src/java/com/redhat/satellite/search/index/builder/XccdfIdentDocumentBuilder.java/* * Copyright (c) 2012 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.builder; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import java.util.Iterator; import java.util.Map; /** * XccdfIdentDocumentBuilder * @version $Rev$ */ public class XccdfIdentDocumentBuilder implements DocumentBuilder { /** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) { Field.Store store = Field.Store.YES; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; } } 07070100000069000041FD0000000000000000000000026615495400000000000000000000000000000000000000000000004A00000000spacewalk-search/src/java/com/redhat/satellite/search/index/builder/tests0707010000006A000081B40000000000000000000000016615495400000955000000000000000000000000000000000000006200000000spacewalk-search/src/java/com/redhat/satellite/search/index/builder/tests/BuilderFactoryTest.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.builder.tests; import com.redhat.satellite.search.index.builder.BuilderFactory; import com.redhat.satellite.search.index.builder.DocumentBuilder; import com.redhat.satellite.search.index.builder.ErrataDocumentBuilder; import com.redhat.satellite.search.index.builder.PackageDocumentBuilder; import com.redhat.satellite.search.index.builder.ServerDocumentBuilder; import junit.framework.TestCase; /** * BuilderFactoryTest * @version $Rev$ */ public class BuilderFactoryTest extends TestCase { public void testGetBuilderErrataType() { DocumentBuilder db = BuilderFactory.getBuilder(BuilderFactory.ERRATA_TYPE); assertNotNull(db); assertEquals(db.getClass(), ErrataDocumentBuilder.class); } public void testGetBuilderPackageType() { DocumentBuilder db = BuilderFactory.getBuilder(BuilderFactory.PACKAGES_TYPE); assertNotNull(db); assertEquals(db.getClass(), PackageDocumentBuilder.class); } public void testGetBuilderServerType() { DocumentBuilder db = BuilderFactory.getBuilder(BuilderFactory.SERVER_TYPE); assertNotNull(db); assertEquals(db.getClass(), ServerDocumentBuilder.class); } public void testGetBuilderInvalid() { try { BuilderFactory.getBuilder(null); fail("getBuilder should have thrown exception with null type"); } catch(UnsupportedOperationException uoe) { assertTrue(true); } try { BuilderFactory.getBuilder("foobar"); fail("getBuilder should have thrown exception with null type"); } catch(UnsupportedOperationException uoe) { assertTrue(true); } } } 0707010000006B000081B40000000000000000000000016615495400000F13000000000000000000000000000000000000006900000000spacewalk-search/src/java/com/redhat/satellite/search/index/builder/tests/ErrataDocumentBuilderTest.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.builder.tests; import com.redhat.satellite.search.index.builder.BuilderFactory; import com.redhat.satellite.search.index.builder.DocumentBuilder; import com.redhat.satellite.search.index.builder.ErrataDocumentBuilder; import org.apache.lucene.document.Document; import java.util.HashMap; import java.util.Map; import junit.framework.TestCase; /** * ErrataDocumentBuilderTest * @version $Rev$ */ public class ErrataDocumentBuilderTest extends TestCase { public void testBuildDocument() { Map<String,String> metadata = new HashMap<String,String>(); metadata.put("id", new Long(10).toString()); metadata.put("advisory", "Advisory"); metadata.put("advisoryType", "AdvisoryType"); metadata.put("advisoryName", "AdvisoryName"); metadata.put("advisoryRel", new Long(100).toString()); metadata.put("product", "Product"); metadata.put("description", "Description"); metadata.put("synopsis", "Synopsis"); metadata.put("topic", "Topic"); metadata.put("solution", "Solution"); metadata.put("issueDate", "IssueDate"); metadata.put("updateDate", "UpdateDate"); metadata.put("notes", "Notes"); metadata.put("orgId", "OrgId"); metadata.put("created", "Created"); metadata.put("modified", "Modified"); metadata.put("lastModified", "LastModified"); metadata.put("severityId", new Long(1).toString()); metadata.put("name", "Advisory"); DocumentBuilder db = BuilderFactory.getBuilder(BuilderFactory.ERRATA_TYPE); assertTrue(db instanceof ErrataDocumentBuilder); Document doc = db.buildDocument(new Long(10), metadata); assertNotNull(doc); assertEquals(doc.getField("id").stringValue(), new Long(10).toString()); assertEquals(doc.getField("advisory").stringValue(), "Advisory"); assertEquals(doc.getField("advisoryType").stringValue(), "AdvisoryType"); assertEquals(doc.getField("advisoryName").stringValue(), "AdvisoryName"); assertEquals(doc.getField("advisoryRel").stringValue(), new Long(100).toString()); assertEquals(doc.getField("product").stringValue(), "Product"); assertEquals(doc.getField("description").stringValue(), "Description"); assertEquals(doc.getField("synopsis").stringValue(), "Synopsis"); assertEquals(doc.getField("topic").stringValue(), "Topic"); assertEquals(doc.getField("solution").stringValue(), "Solution"); assertEquals(doc.getField("issueDate").stringValue(), "IssueDate"); assertEquals(doc.getField("updateDate").stringValue(), "UpdateDate"); assertEquals(doc.getField("notes").stringValue(), "Notes"); assertEquals(doc.getField("orgId").stringValue(), "OrgId"); assertEquals(doc.getField("created").stringValue(), "Created"); assertEquals(doc.getField("modified").stringValue(), "Modified"); assertEquals(doc.getField("lastModified").stringValue(), "LastModified"); assertEquals(doc.getField("severityId").stringValue(), new Long(1).toString()); assertEquals(doc.getField("name").stringValue(), "Advisory"); } } 0707010000006C000081B40000000000000000000000016615495400000735000000000000000000000000000000000000007100000000spacewalk-search/src/java/com/redhat/satellite/search/index/builder/tests/HardwareDeviceDocumentBuilderTest.java/* * Copyright (c) 2008--2010 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.builder.tests; import com.redhat.satellite.search.index.builder.BuilderFactory; import com.redhat.satellite.search.index.builder.DocumentBuilder; import com.redhat.satellite.search.index.builder.HardwareDeviceDocumentBuilder; import org.apache.lucene.document.Document; import junit.framework.TestCase; import java.util.HashMap; import java.util.Map; /** * HardwareDeviceDocumentBuilderTest * @version $Rev$ */ public class HardwareDeviceDocumentBuilderTest extends TestCase { public void testBuilderDocument() { Map<String, String> metadata = new HashMap<String, String>(); metadata.put("name", "Name"); metadata.put("description", "Description"); DocumentBuilder db = BuilderFactory.getBuilder(BuilderFactory.HARDWARE_DEVICE_TYPE); assertTrue(db instanceof HardwareDeviceDocumentBuilder); Document doc = db.buildDocument(new Long(10), metadata); assertNotNull(doc); assertEquals(doc.getField("id").stringValue(), new Long(10).toString()); assertEquals(doc.getField("name").stringValue(), "Name"); assertEquals(doc.getField("description").stringValue(), "Description"); } } 0707010000006D000081B400000000000000000000000166154954000008E4000000000000000000000000000000000000006A00000000spacewalk-search/src/java/com/redhat/satellite/search/index/builder/tests/PackageDocumentBuilderTest.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.builder.tests; import com.redhat.satellite.search.index.builder.BuilderFactory; import com.redhat.satellite.search.index.builder.DocumentBuilder; import com.redhat.satellite.search.index.builder.PackageDocumentBuilder; import org.apache.lucene.document.Document; import java.util.HashMap; import java.util.Map; import junit.framework.TestCase; /** * PackageDocumentBuilderTest * @version $Rev$ */ public class PackageDocumentBuilderTest extends TestCase { public void testBuildDocument() { Map<String, String> metadata = new HashMap<String, String>(); metadata.put("name", "Name"); metadata.put("version", "PrettyVersion"); metadata.put("filename", "FileName"); metadata.put("description", "Description"); metadata.put("summary", "Summary"); metadata.put("arch", "Arch"); DocumentBuilder db = BuilderFactory.getBuilder(BuilderFactory.PACKAGES_TYPE); assertTrue(db instanceof PackageDocumentBuilder); Document doc = db.buildDocument(new Long(10), metadata); assertNotNull(doc); assertEquals(doc.getField("id").stringValue(), new Long(10).toString()); assertEquals(doc.getField("name").stringValue(), "Name"); assertEquals(doc.getField("version").stringValue(), "PrettyVersion"); assertEquals(doc.getField("filename").stringValue(), "FileName"); assertEquals(doc.getField("description").stringValue(), "Description"); assertEquals(doc.getField("summary").stringValue(), "Summary"); assertEquals(doc.getField("arch").stringValue(), "Arch"); } } 0707010000006E000081B4000000000000000000000001661549540000074B000000000000000000000000000000000000007300000000spacewalk-search/src/java/com/redhat/satellite/search/index/builder/tests/ServerCustomInfoDocumentBuilderTest.java/* * Copyright (c) 2008--2010 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.builder.tests; import com.redhat.satellite.search.index.builder.BuilderFactory; import com.redhat.satellite.search.index.builder.DocumentBuilder; import com.redhat.satellite.search.index.builder.ServerCustomInfoDocumentBuilder; import org.apache.lucene.document.Document; import junit.framework.TestCase; import java.util.HashMap; import java.util.Map; /** * ServerCustomInfoDocumentBuilderTest * @version $Rev$ */ public class ServerCustomInfoDocumentBuilderTest extends TestCase { public void testBuilderDocument() { Map<String, String> metadata = new HashMap<String, String>(); metadata.put("value", "value"); metadata.put("serverId", "server id"); DocumentBuilder db = BuilderFactory.getBuilder( BuilderFactory.SERVER_CUSTOM_INFO_TYPE); assertTrue(db instanceof ServerCustomInfoDocumentBuilder); Document doc = db.buildDocument(new Long(10), metadata); assertNotNull(doc); assertEquals(doc.getField("id").stringValue(), new Long(10).toString()); assertEquals(doc.getField("value").stringValue(), "value"); assertEquals(doc.getField("serverId").stringValue(), "server id"); } } 0707010000006F000081B40000000000000000000000016615495400000774000000000000000000000000000000000000006900000000spacewalk-search/src/java/com/redhat/satellite/search/index/builder/tests/ServerDocumentBuilderTest.java/* * Copyright (c) 2008--2010 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.builder.tests; import com.redhat.satellite.search.index.builder.BuilderFactory; import com.redhat.satellite.search.index.builder.DocumentBuilder; import com.redhat.satellite.search.index.builder.ServerDocumentBuilder; import org.apache.lucene.document.Document; import junit.framework.TestCase; import java.util.HashMap; import java.util.Map; /** * ServerDocumentBuilderTest * @version $Rev$ */ public class ServerDocumentBuilderTest extends TestCase { public void testBuilderDocument() { Map<String, String> metadata = new HashMap<String, String>(); metadata.put("name", "Name"); metadata.put("description", "Description"); metadata.put("info", "Info"); DocumentBuilder db = BuilderFactory.getBuilder(BuilderFactory.SERVER_TYPE); assertTrue(db instanceof ServerDocumentBuilder); Document doc = db.buildDocument(new Long(10), metadata); assertNotNull(doc); assertEquals(doc.getField("id").stringValue(), new Long(10).toString()); assertEquals(doc.getField("name").stringValue(), "Name"); assertEquals(doc.getField("description").stringValue(), "Description"); assertEquals(doc.getField("info").stringValue(), "Info"); } } 07070100000070000081B400000000000000000000000166154954000006AE000000000000000000000000000000000000006E00000000spacewalk-search/src/java/com/redhat/satellite/search/index/builder/tests/SnapshotTagDocumentBuilderTest.java/* * Copyright (c) 2008--2010 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.builder.tests; import com.redhat.satellite.search.index.builder.BuilderFactory; import com.redhat.satellite.search.index.builder.DocumentBuilder; import com.redhat.satellite.search.index.builder.SnapshotTagDocumentBuilder; import org.apache.lucene.document.Document; import junit.framework.TestCase; import java.util.HashMap; import java.util.Map; /** * SnapshotTagDocumentBuilderTest * @version $Rev$ */ public class SnapshotTagDocumentBuilderTest extends TestCase { public void testBuilderDocument() { Map<String, String> metadata = new HashMap<String, String>(); metadata.put("name", "Name"); DocumentBuilder db = BuilderFactory.getBuilder(BuilderFactory.SNAPSHOT_TAG_TYPE); assertTrue(db instanceof SnapshotTagDocumentBuilder); Document doc = db.buildDocument(new Long(10), metadata); assertNotNull(doc); assertEquals(doc.getField("id").stringValue(), new Long(10).toString()); assertEquals(doc.getField("name").stringValue(), "Name"); } } 07070100000071000041FD0000000000000000000000036615495400000000000000000000000000000000000000000000004200000000spacewalk-search/src/java/com/redhat/satellite/search/index/ngram07070100000072000081B400000000000000000000000166154954000008F3000000000000000000000000000000000000005500000000spacewalk-search/src/java/com/redhat/satellite/search/index/ngram/NGramAnalyzer.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.ngram; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.LowerCaseFilter; import org.apache.lucene.analysis.standard.StandardTokenizer; import org.apache.lucene.analysis.standard.StandardFilter; import org.apache.lucene.analysis.TokenStream; // From Lucene Sandbox import org.apache.lucene.analysis.ngram.NGramTokenFilter; import java.io.Reader; /** * NGramAnalyzer * A ngram will take a term and break it up into a series of smaller * permutations of different letter combinations. * @version $Rev$ */ public class NGramAnalyzer extends Analyzer { //Controls minimum size ngram to construct protected int min_ngram; //Controls maximum size ngram to construct protected int max_ngram; /** * Constructor * @param min min length of ngram to generate * @param max max length of ngram to generate */ public NGramAnalyzer(int min, int max) { super(); min_ngram = min; max_ngram = max; } /** * Constructs a pre populated * @param reader contains data to parse * @return TokenStream of ngrams */ public TokenStream tokenStream(Reader reader) { return tokenStream(null, reader); } /** * @param fieldName ignored param * @param reader contains data to parse * @return TokenStream of ngrams */ public TokenStream tokenStream(String fieldName, Reader reader) { return new NGramTokenFilter( new LowerCaseFilter( new StandardFilter( new StandardTokenizer(reader))), min_ngram, max_ngram); } } 07070100000073000081B40000000000000000000000016615495400000AD1000000000000000000000000000000000000005200000000spacewalk-search/src/java/com/redhat/satellite/search/index/ngram/NGramQuery.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.ngram; import org.apache.lucene.analysis.Token; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.search.PhraseQuery; import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.index.Term; import java.io.IOException; import java.io.StringReader; /** * NGramQuery * A custom BooleanQuery, it takes each ngram-token and adds as an OR term. * @version $Rev$ */ public class NGramQuery extends BooleanQuery { private static final long serialVersionUID = 1L; /** * Constructor * @param field name of the field * @param queryTerms String containing a term or a series of terms to search. * The string will be parsed and will be broken up into a series of NGrams. * @throws IOException something went wrong parsing queryTerms * */ public NGramQuery(String field, String queryTerms, int min, int max) throws IOException { NGramAnalyzer nga = new NGramAnalyzer(min, max); TokenStream ngrams = nga.tokenStream(new StringReader(queryTerms)); Token token; while ((token = ngrams.next()) != null) { Term t = new Term(field, new String(token.termBuffer()).trim()); add(new TermQuery(t), BooleanClause.Occur.SHOULD); } } /** * * @param pq PhraseQuery to break up and convert to NGramQuery * Forms a BooleanQuery with each term in the original PhraseQuery OR'd. * Note: Assumes that each term has already been tokenized into a ngram, * this method will not re-tokenize terms. * @param useMust controls if BooleanClause.Occur SHOULD or MUST is used. */ public NGramQuery(PhraseQuery pq, boolean useMust) { Term[] terms = pq.getTerms(); for (int i = 0; i < terms.length; i++) { BooleanClause.Occur occur = BooleanClause.Occur.SHOULD; if (useMust) { occur = BooleanClause.Occur.MUST; } add(new TermQuery(terms[i]), occur); } } } 07070100000074000081B4000000000000000000000001661549540000154B000000000000000000000000000000000000005800000000spacewalk-search/src/java/com/redhat/satellite/search/index/ngram/NGramQueryParser.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.ngram; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.lucene.search.ConstantScoreRangeQuery; import org.apache.lucene.search.Query; import org.apache.lucene.search.PhraseQuery; import org.apache.lucene.queryParser.QueryParser; import org.apache.lucene.queryParser.ParseException; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.document.DateTools; import org.apache.lucene.document.NumberTools; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; /** * NGramQueryParser * Creates a custom query parser of ngram-tokenized search terms * * @version $Rev$ */ public class NGramQueryParser extends QueryParser { private static Logger log = LogManager.getLogger(NGramQueryParser.class); private boolean useMust = false; /** * Constructor * @param f field name * @param a analyzer * @param useMustIn boolean option set to true when doing a Free Form or * advanced search, it will force each NGramQuery to be constructed using * the BooleanClause.Occur.MUST. This narrows returned search results and * is not recommended for regular searches which want spelling variances * to be tolerated. */ public NGramQueryParser(String f, Analyzer a, boolean useMustIn) { super(f, a); this.setDateResolution(DateTools.Resolution.DAY); this.useMust = useMustIn; } /** * Constructor * @param f field name * @param a analyzer */ public NGramQueryParser(String f, Analyzer a) { super(f, a); this.setDateResolution(DateTools.Resolution.DAY); } /** * * @return value for useMust */ public boolean getUseMust() { return useMust; } /** * * @param value for useMust */ public void setUseMust(boolean value) { useMust = value; } protected Query getFieldQuery(String defaultField, String queryText) throws ParseException { Query orig = super.getFieldQuery(defaultField, queryText); if (!(orig instanceof PhraseQuery)) { log.debug("Returning default query. No phrase query translation."); return orig; } /** * A ngram when parsed will become a series of smaller search terms, * these terms are grouped together into a PhraseQuery. We are taking * that PhraseQuery and breaking out each ngram term then combining all * ngrams together to form a BooleanQuery. */ PhraseQuery pq = (PhraseQuery)orig; return new NGramQuery(pq, useMust); } /** * * @param field * @return return true if this looks to be a date string * false if this is not a date string */ protected boolean isDate(String field) { if (field.length() == 12) { return true; } return false; } /** * This will look to see if "part1" or "part2" are strings of all digits, * if they are, then they will be converted to a lexicographically safe string * representation, then passed into the inherited getRangeQuery(). This is needed when * comparing something like "4" to be less than "10". * If the strings don't fit the pattern of all digits, then they get passed through * to the inherited getRangeQuery(). */ protected Query getRangeQuery(String field, String part1, String part2, boolean inclusive) throws ParseException { if (isDate(part1) && isDate(part2)) { if (log.isDebugEnabled()) { log.debug("Detected passed in terms are dates, creating " + "ConstantScoreRangeQuery(" + field + ", " + part1 + ", " + part2 + ", " + inclusive + ", " + inclusive); } return new ConstantScoreRangeQuery(field, part1, part2, inclusive, inclusive); } String newPart1 = part1; String newPart2 = part2; String regEx = "(\\d)*"; Pattern pattern = Pattern.compile(regEx); Matcher matcher1 = pattern.matcher(part1); Matcher matcher2 = pattern.matcher(part2); if (matcher1.matches() && matcher2.matches()) { newPart1 = NumberTools.longToString(Long.parseLong(part1)); newPart2 = NumberTools.longToString(Long.parseLong(part2)); if (log.isDebugEnabled()) { log.debug("NGramQueryParser.getRangeQuery() Converted " + part1 + " to " + newPart1 + ", Converted " + part2 + " to " + newPart2); } } return super.getRangeQuery(field, newPart1, newPart2, inclusive); } } 07070100000075000041FD0000000000000000000000026615495400000000000000000000000000000000000000000000004800000000spacewalk-search/src/java/com/redhat/satellite/search/index/ngram/tests07070100000076000081B4000000000000000000000001661549540000070D000000000000000000000000000000000000005F00000000spacewalk-search/src/java/com/redhat/satellite/search/index/ngram/tests/NGramAnalyzerTest.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.ngram.tests; import com.redhat.satellite.search.index.ngram.NGramAnalyzer; import org.apache.lucene.analysis.Token; import org.apache.lucene.analysis.TokenStream; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.StringReader; public class NGramAnalyzerTest extends NGramTestSetup { private static Logger log = LogManager.getLogger(NGramAnalyzerTest.class); public NGramAnalyzerTest() { super(); } public void testTokenStream() throws Exception { NGramAnalyzer nga = new NGramAnalyzer(min_ngram, max_ngram); TokenStream ngrams = nga.tokenStream(new StringReader("aspell")); Token token; String result = new String(""); while ((token = ngrams.next()) != null) { result += new String(token.termBuffer()).trim() + ","; } log.info("Created a ngram token stream, this is what it looks like: " + result); assertTrue("testTokenStream", result.compareTo("a,s,p,e,l,l,as,sp,pe," + "el,ll,asp,spe,pel,ell,aspe,spel,pell,aspel,spell,") == 0); } } 07070100000077000081B400000000000000000000000166154954000020A3000000000000000000000000000000000000006200000000spacewalk-search/src/java/com/redhat/satellite/search/index/ngram/tests/NGramQueryParserTest.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.ngram.tests; import com.redhat.satellite.search.index.ngram.NGramAnalyzer; import com.redhat.satellite.search.index.ngram.NGramQueryParser; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.queryParser.QueryParser; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.Hits; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.store.Directory; public class NGramQueryParserTest extends NGramTestSetup { private static Logger log = LogManager.getLogger(NGramQueryParserTest.class); public NGramQueryParserTest() { super(); } public void testBasicQueryParse() throws Exception { String defaultField = new String("name"); NGramQueryParser parser = new NGramQueryParser(defaultField, new NGramAnalyzer(min_ngram, max_ngram)); String txt = new String("spell"); Query q = parser.parse(txt); log.info("testBasicQueryParse() query = " + q.toString()); assertTrue(q.toString().compareTo("name:s name:p name:e name:l name:l " + "name:sp name:pe name:el name:ll name:spe name:pel name:ell " + "name:spel name:pell name:spell") == 0); } /** * We want to make sure that when searching for multiple terms, each term will become it's * own BooleanQuery. * */ public void testMultiPhraseQueryParse() throws Exception { String defaultField = new String("name"); NGramQueryParser parser = new NGramQueryParser(defaultField, new NGramAnalyzer(min_ngram, max_ngram)); String txt = new String("spell* virt manager"); Query q = parser.parse(txt); assertTrue(q instanceof BooleanQuery); BooleanQuery bq = (BooleanQuery)q; assertTrue(bq.getClauses().length == 3); } public void testWildcardQueryParse() throws Exception { NGramQueryParser parser = new NGramQueryParser("name", new NGramAnalyzer(min_ngram, max_ngram)); String txt = new String("spell*"); Query q = parser.parse(txt); log.info("Wildcard query = " + q.toString()); assertTrue(q.toString().compareTo("name:spell*") == 0); } public void testQueryParseWithSpecialChars() throws Exception { String queryString = new String("spell* virt- manager+"); log.info("testQueryParserWithSpecialChars(): query string is: " + queryString); NGramQueryParser parser = new NGramQueryParser("name", new NGramAnalyzer(min_ngram, max_ngram)); Query q = parser.parse(queryString); log.info("Using NGramQueryParser query = " + q.toString()); QueryParser origParser = new QueryParser("name", new StandardAnalyzer()); q = origParser.parse(queryString); log.info("Using QueryParser query = " + q.toString()); } public Hits performSearch(Directory dir, String query, boolean useMust) throws Exception { NGramQueryParser parser = new NGramQueryParser("name", new NGramAnalyzer(min_ngram, max_ngram), useMust); IndexSearcher searcher = new IndexSearcher(dir); Query q = parser.parse(query); Hits hits = searcher.search(q); log.info("Original Query = " + query); log.info("Parsed Query = " + q.toString()); log.info("Hits.length() = " + hits.length()); for (int i=0; i < hits.length(); i++) { log.debug("Document<"+hits.id(i)+"> = " + hits.doc(i)); //Explanation explain = searcher.explain(q, hits.id(i)); //log.debug("explain = " + explain.toString()); } return hits; } public void testFreeFormQueryParse() throws Exception { String queryString = new String("name:spell -description:another"); log.info("Original query: " + queryString); NGramQueryParser parser = new NGramQueryParser("name", new NGramAnalyzer(min_ngram, max_ngram), true); Query q = parser.parse(queryString); log.info("NGramQueryParser parsed query: " + q.toString()); QueryParser origParser = new QueryParser("name", new StandardAnalyzer()); q = origParser.parse(queryString); log.info("QueryParser parsed query = " + q.toString()); } public void testFreeFormSearch() throws Exception { Hits hits = null; String query = null; boolean useMust = true; // Grab all packages with name "spell" AND // description does NOT contain "another" query = "name:spell -description:another"; hits = performSearch(this.ngramDir, query, useMust); displayHits(hits); assertTrue(hits.length() == 2); // Grab all packages with name "virt" AND // description MUST have "factory" in it query = "name:virt +description:factory"; hits = performSearch(this.ngramDir, query, useMust); displayHits(hits); assertTrue(hits.length() == 2); // Grab all packages with name "virt" query = "name:virt description:factory"; hits = performSearch(this.ngramDir, query, useMust); displayHits(hits); assertTrue(hits.length() == 4); query = "name:virt OR description:factory"; hits = performSearch(this.ngramDir, query, useMust); displayHits(hits); assertTrue(hits.length() == 4); query = "name:virt AND description:factory"; hits = performSearch(this.ngramDir, query, useMust); displayHits(hits); assertTrue(hits.length() == 1); query = "name:virt -description:factory"; hits = performSearch(this.ngramDir, query, useMust); displayHits(hits); assertTrue(hits.length() == 2); } /** * * */ public void testBasicSearch() throws Exception { Hits hits; String query; boolean useMust = false; query = "spell"; hits = performSearch(this.ngramDir, query, useMust); displayHits(hits); assertTrue(thresholdHits(hits) == 5); assertTrue(hits.length() == 16); query = "aspelll"; hits = performSearch(this.ngramDir, query, useMust); displayHits(hits); assertTrue(thresholdHits(hits) == 4); assertTrue(hits.length() == 17); query = "aspell"; hits = performSearch(this.ngramDir, query, useMust); displayHits(hits); assertTrue(thresholdHits(hits) == 4); assertTrue(hits.length() == 17); query = "pel"; hits = performSearch(this.ngramDir, query, useMust); displayHits(hits); assertTrue(thresholdHits(hits) == 8); assertTrue(hits.length() == 16); query = "gtk"; hits = performSearch(this.ngramDir, query, useMust); displayHits(hits); assertTrue(thresholdHits(hits) == 7); assertTrue(hits.length() == 17); // We want a search for kernel-hugemem to return kernel-hugemem as top hit // but currently, kernel-hugemem-devel is matchin instead. This test // is a placeholder as we explore ways to fix this. query = "((name:kernel-hugemem)^2 (description:kernel-hugemem) " + "(filename:kernel-hugemem))"; hits = performSearch(this.ngramDir, query, useMust); displayHits(hits); assertTrue(thresholdHits(hits) == 3); assertTrue(hits.length() == 20); String firstHitName = hits.doc(0).get("name"); assertTrue(firstHitName.compareToIgnoreCase("kernel-hugemem-devel") == 0); } } 07070100000078000081B400000000000000000000000166154954000006ED000000000000000000000000000000000000005C00000000spacewalk-search/src/java/com/redhat/satellite/search/index/ngram/tests/NGramQueryTest.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.ngram.tests; import com.redhat.satellite.search.index.ngram.NGramQuery; import org.apache.lucene.search.Query; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; public class NGramQueryTest extends NGramTestSetup { private static Logger log = LogManager.getLogger(NGramQueryTest.class); public NGramQueryTest() { super(); } public void testCreateQuery() throws Exception { String term = "spell"; Query q = new NGramQuery("name", term, min_ngram, max_ngram); log.info("NGramQuery("+term+") = " + q.toString()); assertTrue(q != null); } public void testCreateQueryMinMax() throws Exception { String term = "spell"; Query q = new NGramQuery("name", term, min_ngram, max_ngram); log.info("NGramQuery("+term+") = " + q.toString()); assertTrue(q.toString().compareTo("name:s name:p name:e name:l " + "name:l name:sp name:pe name:el name:ll name:spe name:pel " + "name:ell name:spel name:pell name:spell") == 0); } } 07070100000079000081B400000000000000000000000166154954000019B4000000000000000000000000000000000000005C00000000spacewalk-search/src/java/com/redhat/satellite/search/index/ngram/tests/NGramTestSetup.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.index.ngram.tests; import java.io.IOException; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import com.redhat.satellite.search.index.ngram.NGramAnalyzer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.queryParser.QueryParser; import org.apache.lucene.search.Hits; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import junit.framework.TestCase; public class NGramTestSetup extends TestCase { private static Logger log = LogManager.getLogger(NGramTestSetup.class); protected RAMDirectory ngramDir; protected RAMDirectory stanDir; protected double score_threshold = .10; protected int min_ngram = 1; protected int max_ngram = 5; protected List<Map<String,String>> items = new LinkedList<Map<String, String>>(); public NGramTestSetup() { super(); } protected void addItem(String name, String description, String filename) { Map<String, String> item = new HashMap<String, String>(); item.put("name", name); item.put("description", description); item.put("filename", filename); items.add(item); } protected void initItems() { addItem("spellingbee", "spelling application", "spellingbee-1.0.rpm"); addItem("aspelling", "another spelling program alternate spell", "aspelling-1.0.rpm"); addItem("aspell", "another spelling program", "aspell-0.3.4.rpm"); addItem("spell", "spelling program", "spell-4943.rpm"); addItem("slelp", "application with spelling error", "slelp1-43.rpm"); addItem("libvirt", "virtualization library", "virt-pkg-1.rpm"); addItem("virt-manager", "blah blah application", "virt-pkg-1.rpm"); addItem("virtualfactory", "virtual factory something", "virtfact-04.rpm"); addItem("newFactory", "factory test application", "newFactory-1.9.rpm"); addItem("gtk+-devel", "development library for gtk", "gtk+-devel-10.rpm"); addItem("gtk+", "runtime library", "gtk+-30.rpm"); addItem("gtk-doc", "documentation for gtk", "gtk-doc-393.rpm"); addItem("authconfig-gtk", "authentication related gtk", "authconfig-gtk-039.rpm"); addItem("mtr-gtk", "blah blah mtr gtk", "mtr-gtk-039.rpm"); addItem("ghostscript-gtk", "printting support application gtk", "ghostscript-gtk-30.rpm"); addItem("gnome-bluetooth-libs", "library for bluetooth support", "gnome-bluetooth-libs-3.4.rpm"); addItem("scim-bridge-gtk", "blah blah scim gtk", "scim-bridge-gtk-494.rpm"); addItem("kernel", "linux kernel package", "kernel-094.rpm"); addItem("kernel-hugemem", "This package includes an SMP version of " + "the Linux kernel which supports systems with 16 Gigabytes " + "of memory or more.", "kernel-hugemem-2.6.9-84.EL.i686"); addItem("kernel-hugemem-devel", "This package provides kernel " + "headers +and makefiles sufficient to build modules against " + "the hugemem kernel package.", "kernel-hugemem-devel-2.6.9-84.EL.i686"); } /** * Creates an index in RAM * */ public void setUp() throws Exception { super.setUp(); initItems(); this.stanDir = new RAMDirectory(); IndexWriter stanWriter = new IndexWriter(this.stanDir, new StandardAnalyzer(), true); this.ngramDir = new RAMDirectory(); IndexWriter ngramWriter = new IndexWriter(this.ngramDir, new NGramAnalyzer(min_ngram, max_ngram), true); for (Map<String, String> item: items) { String name = item.get("name"); String descp = item.get("description"); Document doc = new Document(); doc.add(new Field("name", name, Field.Store.YES, Field.Index.TOKENIZED)); doc.add(new Field("description", descp, Field.Store.YES, Field.Index.TOKENIZED)); stanWriter.addDocument(doc); ngramWriter.addDocument(doc); } stanWriter.close(); ngramWriter.close(); } public Hits performSearch(Directory dir, Analyzer alyz, String query) throws Exception { QueryParser parser = new QueryParser("name", alyz); IndexSearcher searcher = new IndexSearcher(dir); Query q = parser.parse(query); Hits hits = searcher.search(q); return hits; } protected int thresholdHits(Hits hits) throws IOException { /** We could consider doing thresholding as a relative thing... * instead of checking against an absolute value, we grab top score * then filter based on difference from that... */ int counter = 0; for (int i=0; i < hits.length(); i++) { if (hits.score(i) >= score_threshold) { counter++; } else { break; } } return counter; } protected void displayHits(Hits hits) throws IOException { for (int i = 0; i < hits.length(); i++) { Document doc = hits.doc(i); String name = doc.get("name"); String description = doc.get("description"); log.info("Hit<" + i + "> Score< " + hits.score(i) + "> name = <" + name + "> description = <" + description + ">"); } } } 0707010000007A000041FD0000000000000000000000026615495400000000000000000000000000000000000000000000004200000000spacewalk-search/src/java/com/redhat/satellite/search/index/tests0707010000007B000081B4000000000000000000000001661549540000095B000000000000000000000000000000000000005800000000spacewalk-search/src/java/com/redhat/satellite/search/index/tests/IndexManagerTest.javapackage com.redhat.satellite.search.index.tests; import com.redhat.satellite.search.index.IndexManager; import com.redhat.satellite.search.index.IndexingException; import com.redhat.satellite.search.index.QueryParseException; import com.redhat.satellite.search.index.Result; import com.redhat.satellite.search.index.builder.DocumentBuilder; import com.redhat.satellite.search.index.builder.PackageDocumentBuilder; import com.redhat.satellite.search.tests.BaseTestCase; import com.redhat.satellite.search.tests.TestUtil; import org.apache.lucene.document.Document; import java.util.HashMap; import java.util.List; import java.util.Map; public class IndexManagerTest extends BaseTestCase { private IndexManager indexManager; public void setUp() throws Exception { super.setUp(); indexManager = (IndexManager) container.getComponentInstance(IndexManager.class); } public void testIndexing() throws IndexingException { String index = "foo"; Long objectId = new Long(123); Map<String, String> meta = new HashMap<String, String>(); meta.put("name", "foo"); meta.put("desc", "A really nice foo"); meta.put("size", "12345"); meta.put("dateCreated", "7/13/2007"); DocumentBuilder pdb = new PackageDocumentBuilder(); Document doc = pdb.buildDocument(objectId, meta); indexManager.addToIndex(index, doc, "en"); } public void testQuerying() throws IndexingException, QueryParseException { String index = "foo"; Long objectId = new Long(123); Map<String, String> meta = new HashMap<String, String>(); meta.put("name", "foo"); meta.put("desc", "A really nice foo"); meta.put("size", "12345"); meta.put("dateCreated", "7/13/2007"); DocumentBuilder pdb = new PackageDocumentBuilder(); Document doc = pdb.buildDocument(objectId, meta); indexManager.addToIndex(index, doc, "en"); List<Result> results = indexManager.search(index, "name:foo", "en"); assertTrue(results.size() >= 1); results = indexManager.search(index, "desc:really", "en"); assertTrue(results.size() >= 1); } @SuppressWarnings("unchecked") @Override protected Class[] getComponentClasses() { return TestUtil.buildComponentsList(IndexManager.class); } } 0707010000007C000081B400000000000000000000000166154954000003B6000000000000000000000000000000000000005B00000000spacewalk-search/src/java/com/redhat/satellite/search/index/tests/KeywordAnalyzerTest.javapackage com.redhat.satellite.search.index.tests; import com.redhat.satellite.search.index.KeywordAnalyzer; import org.apache.lucene.analysis.TokenStream; import junit.framework.TestCase; import java.io.StringReader; public class KeywordAnalyzerTest extends TestCase { public void processString(String originalValue) throws Exception { KeywordAnalyzer ka = new KeywordAnalyzer(); StringReader sr = new StringReader(originalValue); TokenStream ts = ka.tokenStream("ignoredField", sr); assertTrue("Text Should be Untouched", new String(ts.next().termBuffer()).trim(). compareTo(originalValue) == 0); assertTrue("Token should be null", ts.next() == null); } public void testBasicParse() throws Exception { processString("i386"); processString("bx-gh-3&^0-993$#@!%^&*()-=+_><?/.,';:[]}{)"); processString("j839,. 43 ..,.-=-=`1~!@#"); } } 0707010000007D000041FD0000000000000000000000046615495400000000000000000000000000000000000000000000003A00000000spacewalk-search/src/java/com/redhat/satellite/search/rpc0707010000007E000081B400000000000000000000000166154954000014AC000000000000000000000000000000000000004900000000spacewalk-search/src/java/com/redhat/satellite/search/rpc/RpcServer.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.rpc; import com.redhat.satellite.search.config.Configuration; import com.redhat.satellite.search.db.DatabaseManager; import com.redhat.satellite.search.index.IndexManager; import com.redhat.satellite.search.scheduler.ScheduleManager; import org.picocontainer.Startable; import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.SocketAddress; import java.net.UnknownHostException; import java.util.Iterator; import java.util.Map; import redstone.xmlrpc.XmlRpcServer; import simple.http.connect.Connection; import simple.http.connect.ConnectionFactory; /** * Manages the embedded webserver and configures the XML-RPC runtime * * @version $Rev$ */ public class RpcServer implements Startable { private int listenPort; private InetAddress listenAddress; private Map<String, String> handlers; private XmlRpcServer xmlrpcServer; private ServerSocket socket; private IndexManager indexManager; private DatabaseManager databaseManager; private ScheduleManager scheduleManager; /** * Constructor * * @param config * dependency * @param idxManager * dependency * @throws UnknownHostException * if config contains bad rpc_address */ public RpcServer(Configuration config, IndexManager idxManager, DatabaseManager dbManager, ScheduleManager schedMgr) throws UnknownHostException { listenPort = config.getInt("search.rpc_port", 2828); String addr = config.getString("search.rpc_address", "127.0.0.1"); if (addr != null) { listenAddress = InetAddress.getByName(addr); } handlers = config.getMap("search.rpc_handlers"); if (handlers == null) { throw new IllegalArgumentException( "search.rpc_handlers config entry " + "is missing"); } indexManager = idxManager; databaseManager = dbManager; scheduleManager = schedMgr; } /** * Starts the server * @throws RuntimeException something bad happened */ public void start() { xmlrpcServer = new XmlRpcServer(); for (Iterator<String> iter = handlers.keySet().iterator(); iter .hasNext();) { String name = iter.next(); String className = handlers.get(name); xmlrpcServer.addInvocationHandler(name, loadHandler(className)); } XmlRpcInvoker invoker = new XmlRpcInvoker(xmlrpcServer); Connection connection = ConnectionFactory.getConnection(invoker); try { socket = new ServerSocket(); SocketAddress sockAddr = null; if (listenAddress != null) { sockAddr = new InetSocketAddress(listenAddress, listenPort); } else { sockAddr = new InetSocketAddress(listenPort); } socket.bind(sockAddr); connection.connect(socket); } catch (IOException e) { throw new RuntimeException(e); } } /** * Stops the server * * @throws IOException */ public void stop() { try { socket.close(); } catch (IOException e) { throw new RuntimeException(e); } } @SuppressWarnings("unchecked") private Object loadHandler(String className) { try { ClassLoader cl = Thread.currentThread().getContextClassLoader(); Class klass = cl.loadClass(className); Class[] paramTypes = { IndexManager.class, DatabaseManager.class, ScheduleManager.class }; Object[] params = { indexManager, databaseManager, scheduleManager}; Constructor c = klass.getConstructor(paramTypes); return c.newInstance(params); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } } } 0707010000007F000081B40000000000000000000000016615495400000B71000000000000000000000000000000000000004D00000000spacewalk-search/src/java/com/redhat/satellite/search/rpc/XmlRpcInvoker.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.rpc; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import java.io.StringWriter; import redstone.xmlrpc.XmlRpcServer; import simple.http.ProtocolHandler; import simple.http.Request; import simple.http.Response; /** * SimpleWeb ProtocolHandler used to pass requests to the XML-RPC layer * * @version $Rev$ * */ public class XmlRpcInvoker implements ProtocolHandler { private static Logger log = LogManager.getLogger(XmlRpcInvoker.class); private XmlRpcServer server; /** * Constructor * * @param xmlrpcServer * handles actual XML-RPC calls */ public XmlRpcInvoker(XmlRpcServer xmlrpcServer) { server = xmlrpcServer; } /** * {@inheritDoc} */ public void handle(Request request, Response response) { String uri = request.getURI(); log.info(uri); try { if (!uri.startsWith("/RPC2")) { response.setCode(404); response.setText(uri); PrintStream out = response.getPrintStream(); out.println("<html><body><title>Page not found</title>"); out.println("<b>" + uri + " not found</b>"); out.println("</body></html>"); response.set("Content-Type", "text/html"); out.flush(); out.close(); } else { InputStream in = request.getInputStream(); StringWriter writer = new StringWriter(); server.execute(in, writer); OutputStream out = response.getOutputStream(); response.set("Content-Type", "text/xml"); writer.flush(); out.write(writer.getBuffer().toString().getBytes()); out.flush(); out.close(); } } catch (IOException e) { e.printStackTrace(); } finally { try { response.commit(); } catch (IOException e) { e.printStackTrace(); } } } } 07070100000080000041FD0000000000000000000000036615495400000000000000000000000000000000000000000000004300000000spacewalk-search/src/java/com/redhat/satellite/search/rpc/handlers07070100000081000081B400000000000000000000000166154954000007B5000000000000000000000000000000000000005500000000spacewalk-search/src/java/com/redhat/satellite/search/rpc/handlers/AdminHandler.java/* * Copyright (c) 2008--2010 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.rpc.handlers; import com.redhat.satellite.search.db.DatabaseManager; import com.redhat.satellite.search.index.IndexManager; import com.redhat.satellite.search.scheduler.ScheduleManager; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; /** * XML-RPC handler which handles calls for administration * Updating indexes maybe more tasks later * * @version $Rev$ */ public class AdminHandler { private static Logger log = LogManager.getLogger(AdminHandler.class); private ScheduleManager scheduleManager; /** * Constructor * * @param idxManager * Search engine interface */ public AdminHandler(IndexManager idxManager, DatabaseManager dbMgr, ScheduleManager schedMgr) { log.info("** AdminHandler constructor invoked"); scheduleManager = schedMgr; } /** * Causes the task associated with the indexName to run and index new data. * * @param indexName * @return true if index update is scheduled, false if unable to schedule. */ public boolean updateIndex(String indexName) { if (log.isDebugEnabled()) { log.debug("AdminHandler::updateIndex(" + indexName); } return scheduleManager.triggerIndexTask(indexName); } } 07070100000082000081B40000000000000000000000016615495400001AD1000000000000000000000000000000000000005800000000spacewalk-search/src/java/com/redhat/satellite/search/rpc/handlers/DatabaseHandler.java/* * Copyright (c) 2008--2013 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.rpc.handlers; import com.redhat.satellite.search.db.DatabaseManager; import com.redhat.satellite.search.db.Query; import com.redhat.satellite.search.index.IndexManager; import com.redhat.satellite.search.index.QueryParseException; import com.redhat.satellite.search.index.Result; import com.redhat.satellite.search.scheduler.ScheduleManager; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.sql.SQLException; import java.util.HashMap; import java.util.List; import java.util.Map; import redstone.xmlrpc.XmlRpcFault; /** * XML-RPC handler which handles calls for database queries * * TODO: * 1) Restrict this class to only being able to call queries * defined in specified namespaces, for now that would be: "errataHandler", * errata_handler.xml. * 2) Screenhits returned, verify these objects are allowed to be seen by the logged in * user. * * * @version $Rev$ */ public class DatabaseHandler { private static Logger log = LogManager.getLogger(DatabaseHandler.class); private DatabaseManager databaseManager; /** * Constructor * @param idxManager IndexManager - unused param, needed for interface compatibility * with RpcServer constructing us. * @param dbMgr DatabaseManager * Will perform database queries * @param schedManager ScheduleManager unused param, needed for interface compatibility * with RpcServer constructing us. */ public DatabaseHandler(IndexManager idxManager, DatabaseManager dbMgr, ScheduleManager schedManager) { databaseManager = dbMgr; } /** * Search database - using session id as String to avoid Integer overflow * * @param sessionId * user's application session id * @param namespace * namespace query is located in * @param query * search query * @return list of document ids as results * @throws XmlRpcFault something bad happened */ public List<Result> search(String sessionId, String namespace, String query) throws XmlRpcFault { return search(Long.parseLong(sessionId), namespace, query); } /** * Search database * * @param sessionId * user's application session id * @param namespace * namespace query is located in * @param query * search query * @return list of document ids as results * @throws XmlRpcFault something bad happened */ public List<Result> search(long sessionId, String namespace, String query) throws XmlRpcFault { if (log.isDebugEnabled()) { log.debug("DatabaseHandler:: searching for <" + namespace + ">: " + query); } try { String queryName = getQueryName(query); Map<String, Object> params = getQueryParams(query); if (log.isDebugEnabled()) { log.debug("Calling runQuery(" + sessionId + ", " + namespace + ", " + queryName + ", " + params + ")"); } List<Result> hits = runQuery(sessionId, namespace, queryName, params); log.info("Returned " + hits.size() + " records"); return hits; } catch (SQLException e) { log.warn("Caught SQLException: " + e.getMessage()); e.printStackTrace(); throw new XmlRpcFault(IndexHandler.DB_ERROR, e.getMessage()); } catch (QueryParseException e) { log.warn("Caught QueryParseException: " + e.getMessage()); e.printStackTrace(); throw new XmlRpcFault(IndexHandler.QUERY_ERROR, e.getMessage()); } } /** * * @param queryIn format "name(param1, param2, ....)" * @return query name from query * @throws QueryParseException thrown when queryIn is malformed */ private String getQueryName(String queryIn) throws QueryParseException { queryIn = queryIn.trim(); int index = queryIn.indexOf(":("); if (index < 0) { throw new QueryParseException("Could not parse query: '" + queryIn + "'"); } String queryName = queryIn.substring(0, index); return queryName; } /** * * @param queryIn String format of "name(param1, param2, ....)" * @return List of params from query * @throws QueryParseException thrown when queryIn is malformed */ private Map<String, Object> getQueryParams(String queryIn) throws QueryParseException { queryIn = queryIn.trim(); String delim = ":("; int index = queryIn.indexOf(delim); if (index < 0) { throw new QueryParseException("Could not parse query: '" + queryIn + "'"); } int indexB = queryIn.indexOf(")", index); if (indexB < 0) { throw new QueryParseException("Could not parse query: '" + queryIn + "'"); } index = index + delim.length() - 1; // We want to be pointed to end of location of // delim String[] temps = queryIn.substring(index + delim.length() - 1, indexB).split(","); Map<String, Object> params = new HashMap<String, Object>(); for (int i = 0; i < temps.length; i++) { params.put(String.format("param%d", i), temps[i].trim()); } return params; } /** Will need to generalize this... right now it's specific to Errata only * * @param namespace namespace query lives in * @param queryName query to run * @param args parameters to the query * @return List of results */ private List<Result> runQuery(Long sessionId, String namespace, String queryName, Map<String, Object> args) throws SQLException { // Look up Query in DB args.put("sessionId", sessionId); Query<Result> query = databaseManager.getQuery(queryName); List<Result> retval; try { retval = query.loadList(args); } finally { query.close(); } return retval; } } 07070100000083000081B40000000000000000000000016615495400002676000000000000000000000000000000000000005500000000spacewalk-search/src/java/com/redhat/satellite/search/rpc/handlers/IndexHandler.java/* * Copyright (c) 2008--2014 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.rpc.handlers; import com.redhat.satellite.search.db.DatabaseManager; import com.redhat.satellite.search.db.Query; import com.redhat.satellite.search.index.IndexManager; import com.redhat.satellite.search.index.IndexingException; import com.redhat.satellite.search.index.Result; import com.redhat.satellite.search.index.QueryParseException; import com.redhat.satellite.search.scheduler.ScheduleManager; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.search.BooleanQuery; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; import redstone.xmlrpc.XmlRpcFault; /** * XML-RPC handler which handles calls for indexing * * @version $Rev$ */ public class IndexHandler { private static Logger log = LogManager.getLogger(IndexHandler.class); private IndexManager indexManager; private DatabaseManager databaseManager; public static final int QUERY_ERROR = 100; public static final int INDEX_ERROR = 200; public static final int DB_ERROR = 300; public static final String DEFAULT_LANG = new Locale("EN", "US").toString(); /** * Constructor * * @param idxManager * Search engine interface */ public IndexHandler(IndexManager idxManager, DatabaseManager dbMgr, ScheduleManager schedMgr) { indexManager = idxManager; databaseManager = dbMgr; } /** * Search index - using session id as String to avoid Integer overflow * * @param sessionId * user's application session id * @param indexName * index to use * @param query * search query * @return list of document ids as results * @throws XmlRpcFault something bad happened */ public List<Result> search(String sessionId, String indexName, String query, boolean isFineGrained) throws XmlRpcFault { return search(Long.parseLong(sessionId), indexName, query, DEFAULT_LANG, isFineGrained); } /** * Search index - * assumes English language as default language * * @param sessionId * user's application session id * @param indexName * index to use * @param query * search query * @return list of document ids as results * @throws XmlRpcFault something bad happened */ public List<Result> search(long sessionId, String indexName, String query) throws XmlRpcFault { return search(sessionId, indexName, query, DEFAULT_LANG); } /** * Search index - * assumes English language as default language * * @param sessionId * user's application session id * @param indexName * index to use * @param query * search query * @param isFineGrained * if set will restrict matches to be stricter and less forgiving * @return list of document ids as results * @throws XmlRpcFault something bad happened */ public List<Result> search(long sessionId, String indexName, String query, boolean isFineGrained) throws XmlRpcFault { return search(sessionId, indexName, query, DEFAULT_LANG, isFineGrained); } /** * Search index * * @param sessionId * user's application session id * @param indexName * index to use * @param query * search query * @param lang * language * @return list of document ids as results * @throws XmlRpcFault something bad happened */ public List<Result> search(long sessionId, String indexName, String query, String lang) throws XmlRpcFault { return search(sessionId, indexName, query, lang, false); } /** * Search index * * @param sessionId * user's application session id * @param indexName * index to use * @param query * search query * @param lang * language * @param isFineGrained * if set will restrict matches to be stricter and less forgiving * @return list of document ids as results * @throws XmlRpcFault something bad happened */ public List<Result> search(long sessionId, String indexName, String query, String lang, boolean isFineGrained) throws XmlRpcFault { if (log.isDebugEnabled()) { log.debug("IndexHandler:: searching for: " + query + ", indexName = " + indexName + ", lang = " + lang); } boolean retry = true; while (retry) { try { retry = false; List<Result> hits = indexManager.search(indexName, query, lang, isFineGrained); if (indexName.equals("package") || indexName.equals("errata") || indexName.equals("server")) { return screenHits(sessionId, indexName, hits); } return hits; } catch (IndexingException e) { log.error("Caught exception: ", e); throw new XmlRpcFault(INDEX_ERROR, e.getMessage()); } catch (QueryParseException e) { log.error("Caught exception: ", e); throw new XmlRpcFault(QUERY_ERROR, e.getMessage()); } catch (SQLException e) { log.error("Caught exception: ", e); throw new XmlRpcFault(DB_ERROR, e.getMessage()); } catch (BooleanQuery.TooManyClauses e) { int oldQueries = BooleanQuery.getMaxClauseCount(); if (Integer.MAX_VALUE / 2 > oldQueries) { // increase number of max clause count // if there's no overflow danger int newQueries = oldQueries * 2; log.error("Too many hits for query: " + oldQueries + ". Increasing max clause count to " + newQueries + "\nexception message: " + e.getMessage()); BooleanQuery.setMaxClauseCount(newQueries); retry = true; } else { // there's no more help throw e; } } } // return just because of compiler return null; } private List<Result> screenHits(long sessionId, String indexName, List<Result> hits) throws SQLException { if (hits == null || hits.size() == 0) { if (log.isDebugEnabled()) { log.debug("NO HITS FOUND"); } return Collections.<Result>emptyList(); } List<Long> ids = new ArrayList<Long>(); for (Result pr : hits) { ids.add(new Long(pr.getId())); } Query<String> query = null; if ("package".equals(indexName)) { query = databaseManager.getQuery("verifyPackageVisibility"); } else if ("errata".equals(indexName)) { query = databaseManager.getQuery("verifyErrataVisibility"); } else if ("server".equals(indexName)) { query = databaseManager.getQuery("verifyServerVisibility"); } else { if (log.isDebugEnabled()) { log.debug("screenHits(" + indexName + ") no 'screening of results' performed"); log.debug("results: " + hits); } return hits; } try { Set<String> visible = new HashSet<String>(); // we have to batch the visibility query in clause to no more // than 1000 for oracle final int batch_size = 1000; for (int i = 0; i < ids.size(); i += batch_size) { Map<String, Object> params = new HashMap<String, Object>(); params.put("session_id", sessionId); // sub list includes the first index and excludes the last. // so the proper last index of ids to pass to subList is ids.size() params.put("id_list", ids.subList(i, (i + batch_size) <= ids.size() ? i + batch_size : ids.size())); visible.addAll(query.loadList(params)); } if (log.isDebugEnabled()) { log.debug("results: " + visible); } // add the PackageResults that match the visible list List<Result> realResults = new ArrayList<Result>(); for (Result pr : hits) { if (visible.contains(pr.getId())) { realResults.add(pr); } } return realResults; } finally { query.close(); } } } 07070100000084000081B4000000000000000000000001661549540000064E000000000000000000000000000000000000006100000000spacewalk-search/src/java/com/redhat/satellite/search/rpc/handlers/VisibilityResultsHandler.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.rpc.handlers; import com.redhat.satellite.search.db.ResultHandler; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; /** * Cheesy class for screening hit results based * on user's security context * * @version $Rev $ */ class VisibilityResultsHandler implements ResultHandler { private static Logger log = LogManager .getLogger(VisibilityResultsHandler.class); private List<String> results = new ArrayList<String>(); /** * {@inheritDoc} */ public void handleRow(ResultSet rs) throws SQLException { long id = rs.getLong(1); results.add(String.valueOf(id)); } /** * Getter for accumulated results * @return results */ List<String> getResults() { log.warn("returning results"); return results; } } 07070100000085000041FD0000000000000000000000026615495400000000000000000000000000000000000000000000004900000000spacewalk-search/src/java/com/redhat/satellite/search/rpc/handlers/tests07070100000086000081B400000000000000000000000166154954000009AC000000000000000000000000000000000000006200000000spacewalk-search/src/java/com/redhat/satellite/search/rpc/handlers/tests/DatabaseHandlerTest.java/* * Copyright (c) 2008--2011 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.rpc.handlers.tests; import com.redhat.satellite.search.db.DatabaseManager; import com.redhat.satellite.search.index.IndexManager; import com.redhat.satellite.search.rpc.handlers.DatabaseHandler; import com.redhat.satellite.search.scheduler.ScheduleManager; import com.redhat.satellite.search.tests.BaseTestCase; import com.redhat.satellite.search.tests.TestUtil; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.util.List; import redstone.xmlrpc.XmlRpcFault; public class DatabaseHandlerTest extends BaseTestCase { private static Logger log = LogManager.getLogger(DatabaseHandlerTest.class); @Override @SuppressWarnings("unchecked") protected Class[] getComponentClasses() { Class[] components = {IndexManager.class, DatabaseManager.class, ScheduleManager.class}; return TestUtil.buildComponentsList(components); } public void testQuery() throws XmlRpcFault { DatabaseManager db = (DatabaseManager) container.getComponentInstance(DatabaseManager.class); IndexManager idx = (IndexManager) container.getComponentInstance(IndexManager.class); ScheduleManager schedMgr = (ScheduleManager) container.getComponentInstance(ScheduleManager.class); DatabaseHandler handler = new DatabaseHandler(idx, db, schedMgr); String searchNamespace = "errata"; String searchString = "listErrataByIssueDateRange:(2004-10-20, 2010-10-30)"; log.info("Calling hander.search(1, " + searchNamespace + ", " + searchString + ")"); List results = handler.search(1, searchNamespace, searchString); log.info("results = " + results); assertTrue(results.size() > 0); } } 07070100000087000081B400000000000000000000000166154954000009C7000000000000000000000000000000000000005F00000000spacewalk-search/src/java/com/redhat/satellite/search/rpc/handlers/tests/IndexHandlerTest.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.rpc.handlers.tests; import com.redhat.satellite.search.db.DatabaseManager; import com.redhat.satellite.search.index.IndexManager; import com.redhat.satellite.search.rpc.handlers.IndexHandler; import com.redhat.satellite.search.scheduler.ScheduleManager; import com.redhat.satellite.search.tests.BaseTestCase; import com.redhat.satellite.search.tests.TestUtil; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.util.List; import redstone.xmlrpc.XmlRpcFault; public class IndexHandlerTest extends BaseTestCase { private static Logger log = LogManager.getLogger(IndexHandlerTest.class); @Override @SuppressWarnings("unchecked") protected Class[] getComponentClasses() { Class[] components = {IndexManager.class, DatabaseManager.class, ScheduleManager.class}; return TestUtil.buildComponentsList(components); } public void testQuery() throws XmlRpcFault, InterruptedException { // Let the indexing task do some stuff Thread.sleep(15000); DatabaseManager db = (DatabaseManager) container.getComponentInstance(DatabaseManager.class); IndexManager idx = (IndexManager) container.getComponentInstance(IndexManager.class); ScheduleManager schedMgr = (ScheduleManager) container.getComponentInstance(ScheduleManager.class); IndexHandler handler = new IndexHandler(idx, db, schedMgr); handler.search(252437, "package", "description:package", "en"); List results = handler.search(252437, "package", "kernel*", "en"); log.info("kernel results 1: " + results); results = handler.search(252437, "package", "kernel", "en"); log.info("kernel results 2: " + results); } } 07070100000088000041FD0000000000000000000000026615495400000000000000000000000000000000000000000000004000000000spacewalk-search/src/java/com/redhat/satellite/search/rpc/tests07070100000089000081B4000000000000000000000001661549540000024F000000000000000000000000000000000000005300000000spacewalk-search/src/java/com/redhat/satellite/search/rpc/tests/RpcServerTest.javapackage com.redhat.satellite.search.rpc.tests; import com.redhat.satellite.search.rpc.RpcServer; import com.redhat.satellite.search.tests.BaseTestCase; import com.redhat.satellite.search.tests.TestUtil; public class RpcServerTest extends BaseTestCase { @SuppressWarnings("unchecked") @Override protected Class[] getComponentClasses() { return TestUtil.buildComponentsList(RpcServer.class); } public void testStopServer() { RpcServer server = (RpcServer) container.getComponentInstanceOfType(RpcServer.class); server.stop(); } } 0707010000008A000041FD0000000000000000000000046615495400000000000000000000000000000000000000000000004000000000spacewalk-search/src/java/com/redhat/satellite/search/scheduler0707010000008B000081B400000000000000000000000166154954000020C4000000000000000000000000000000000000005500000000spacewalk-search/src/java/com/redhat/satellite/search/scheduler/ScheduleManager.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.scheduler; import static org.quartz.JobBuilder.newJob; import static org.quartz.SimpleScheduleBuilder.simpleSchedule; import static org.quartz.TriggerBuilder.newTrigger; import com.redhat.satellite.search.config.Configuration; import com.redhat.satellite.search.db.DatabaseManager; import com.redhat.satellite.search.index.IndexManager; import com.redhat.satellite.search.index.builder.BuilderFactory; import com.redhat.satellite.search.scheduler.tasks.IndexErrataTask; import com.redhat.satellite.search.scheduler.tasks.IndexHardwareDevicesTask; import com.redhat.satellite.search.scheduler.tasks.IndexPackagesTask; import com.redhat.satellite.search.scheduler.tasks.IndexServerCustomInfoTask; import com.redhat.satellite.search.scheduler.tasks.IndexSnapshotTagsTask; import com.redhat.satellite.search.scheduler.tasks.IndexSystemsTask; import com.redhat.satellite.search.scheduler.tasks.IndexXccdfIdentTask; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.picocontainer.Startable; import org.quartz.JobBuilder; import org.quartz.JobDataMap; import org.quartz.Scheduler; import org.quartz.SchedulerException; import org.quartz.SimpleTrigger; import org.quartz.Trigger; import org.quartz.impl.StdSchedulerFactory; import org.quartz.spi.MutableTrigger; import java.util.Date; /** * Manages all scheduled tasks for the search server * Right now all tasks are hardcoded -- this should be * changed to be more config file driven * * @version $Rev $ */ public class ScheduleManager implements Startable { private static Logger log = LogManager.getLogger(ScheduleManager.class); private Scheduler scheduler; private DatabaseManager databaseManager; private IndexManager indexManager; private final String updateIndexGroupName = "updateIndex"; /** * Constructor * @param dbmgr allows ScheduleManager to access the database. * @param idxmgr allows the ScheduleManager to access the indexer. */ public ScheduleManager(DatabaseManager dbmgr, IndexManager idxmgr) { databaseManager = dbmgr; indexManager = idxmgr; try { scheduler = StdSchedulerFactory.getDefaultScheduler(); } catch (SchedulerException e) { throw new RuntimeException(e); } } private void scheduleJob(Scheduler sched, String name, int mode, long interval, Class task, JobDataMap data) throws SchedulerException { Trigger t = createTrigger(name, updateIndexGroupName, mode, interval); JobBuilder d = newJob(task).withIdentity(name, updateIndexGroupName); d.usingJobData(data); sched.scheduleJob(d.build(), t); } private Trigger createTrigger(String name, String group, int mode, long interval) { SimpleTrigger trigger = newTrigger() .withIdentity(name, "default") .forJob(name, group) .startAt(new Date()) .endAt(null) .withSchedule(simpleSchedule() .withRepeatCount(mode) .withIntervalInMilliseconds(interval)) .build(); if (trigger instanceof MutableTrigger) { MutableTrigger mtrigger = (MutableTrigger) trigger; mtrigger.setMisfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT); return mtrigger; } else { log.error("Cannot set MisfireInstruction since trigger is not instance of MutableTrigger: " + trigger); } return trigger; } /** * {@inheritDoc} */ @Override public void start() { try { Configuration config = new Configuration(); long interval = config.getInt("search.schedule.interval", 300000); log.info("ScheduleManager task interval is set to " + interval); int mode = SimpleTrigger.REPEAT_INDEFINITELY; if (System.getProperties().get("isTesting") != null) { interval = 100; mode = 0; } JobDataMap jobData = new JobDataMap(); jobData.put("indexManager", indexManager); jobData.put("databaseManager", databaseManager); jobData.put("configuration", new Configuration()); scheduleJob(scheduler, BuilderFactory.PACKAGES_TYPE, mode, interval, IndexPackagesTask.class, jobData); scheduleJob(scheduler, BuilderFactory.ERRATA_TYPE, mode, interval, IndexErrataTask.class, jobData); scheduleJob(scheduler, BuilderFactory.SERVER_TYPE, mode, interval, IndexSystemsTask.class, jobData); scheduleJob(scheduler, BuilderFactory.HARDWARE_DEVICE_TYPE, mode, interval, IndexHardwareDevicesTask.class, jobData); scheduleJob(scheduler, BuilderFactory.SNAPSHOT_TAG_TYPE, mode, interval, IndexSnapshotTagsTask.class, jobData); scheduleJob(scheduler, BuilderFactory.SERVER_CUSTOM_INFO_TYPE, mode, interval, IndexServerCustomInfoTask.class, jobData); scheduleJob(scheduler, BuilderFactory.XCCDF_IDENT_TYPE, mode, interval, IndexXccdfIdentTask.class, jobData); scheduler.start(); } catch (SchedulerException e) { throw new RuntimeException(e); } } /** * {@inheritDoc} */ @Override public void stop() { try { scheduler.shutdown(); } catch (SchedulerException e) { throw new RuntimeException(e); } } private boolean isSupported(String indexName) { if (BuilderFactory.ERRATA_TYPE.equals(indexName) || BuilderFactory.HARDWARE_DEVICE_TYPE.equals(indexName) || BuilderFactory.PACKAGES_TYPE.equals(indexName) || BuilderFactory.SERVER_CUSTOM_INFO_TYPE.equals(indexName) || BuilderFactory.SERVER_TYPE.equals(indexName) || BuilderFactory.SNAPSHOT_TAG_TYPE.equals(indexName) || BuilderFactory.XCCDF_IDENT_TYPE.equals(indexName)) { return true; } log.info("Unknown index: " + indexName); return false; } /** * Will create/schedule a trigger for the passed in indexName. * Note: Only one trigger per indexName is allowed, if subsequent calls * are made before the current trigger finishes completion, this request * will be dropped. * @param indexName * @return */ public boolean triggerIndexTask(String indexName) { if (!isSupported(indexName)) { log.info(indexName + " is not a supported for scheduler modifications."); return false; } // Define a Trigger that will fire "now" and associate it with the existing job Trigger trigger = newTrigger() .withIdentity("immediateTrigger-" + indexName, "group1") .startAt(new Date()) .forJob(indexName, updateIndexGroupName) .build(); try { // Schedule the trigger log.info("Scheduling trigger: " + trigger); scheduler.scheduleJob(trigger); } catch (SchedulerException e) { log.warn("Scheduling trigger: " + trigger + " failed."); log.warn("Exception was caught: ", e); return false; } return true; } } 0707010000008C000041FD0000000000000000000000036615495400000000000000000000000000000000000000000000004600000000spacewalk-search/src/java/com/redhat/satellite/search/scheduler/tasks0707010000008D000081B40000000000000000000000016615495400002690000000000000000000000000000000000000005C00000000spacewalk-search/src/java/com/redhat/satellite/search/scheduler/tasks/GenericIndexTask.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.scheduler.tasks; import com.redhat.satellite.search.db.DatabaseManager; import com.redhat.satellite.search.db.Query; import com.redhat.satellite.search.db.WriteQuery; import com.redhat.satellite.search.db.models.GenericRecord; import com.redhat.satellite.search.index.IndexManager; import com.redhat.satellite.search.index.IndexingException; import com.redhat.satellite.search.index.builder.BuilderFactory; import com.redhat.satellite.search.index.builder.DocumentBuilder; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.document.Document; import org.quartz.JobDataMap; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import org.quartz.StatefulJob; import java.sql.SQLException; import java.util.Calendar; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; /** * GenericIndexTask * @version $Rev$ */ public abstract class GenericIndexTask implements StatefulJob { private static Logger log = LogManager.getLogger(GenericIndexTask.class); private String lang = "en"; /** * {@inheritDoc} */ public void execute(JobExecutionContext ctx) throws JobExecutionException { JobDataMap jobData = ctx.getJobDetail().getJobDataMap(); DatabaseManager databaseManager = (DatabaseManager)jobData.get("databaseManager"); IndexManager indexManager = (IndexManager)jobData.get("indexManager"); try { //try to create the index first incase we never actually // have any records (BZ 537502) indexManager.createIndex(getIndexName(), lang); List<GenericRecord> data = getRecords(databaseManager); int count = 0; log.info(super.getClass().toString() + "found [" + data.size() + "] items to index"); for (Iterator<GenericRecord> iter = data.iterator(); iter.hasNext();) { GenericRecord current = iter.next(); indexRecord(indexManager, current); count++; if (count == 10 || !iter.hasNext()) { if (System.getProperties().get("isTesting") == null) { updateLastRecord(databaseManager, current.getId()); } count = 0; } } // // Check to see if any records have been deleted from database, so // we should delete from our indexes. // int numDel = handleDeletedRecords(databaseManager, indexManager); log.info("Deleted " + numDel + " records from index <" + getIndexName() + ">"); } catch (SQLException e) { e.printStackTrace(); throw new JobExecutionException(e); } catch (IndexingException e) { log.debug(e); if (e.getMessage().contains("LockObtainFailedException: Lock obtain timed out")) { log.info("Indexer already running. Skipping"); return; } throw new JobExecutionException(e); } } /** * @param databaseManager * @param sid */ private void updateLastRecord(DatabaseManager databaseManager, long sid) throws SQLException { WriteQuery updateQuery = databaseManager.getWriterQuery(getQueryUpdateLastRecord()); WriteQuery insertQuery = null; try { Map<String, Object> params = new HashMap<String, Object>(); params.put("id", sid); params.put("last_modified", Calendar.getInstance().getTime()); if (updateQuery.update(params) == 0) { insertQuery = databaseManager.getWriterQuery(getQueryCreateLastRecord()); insertQuery.insert(params); } } finally { try { if (updateQuery != null) { updateQuery.close(); } } finally { if (insertQuery != null) { insertQuery.close(); } } } } /** * @param indexManager * @param current */ private void indexRecord(IndexManager indexManager, GenericRecord data) throws IndexingException { Map<String, String> attrs = getFieldMap(data); log.info(super.getClass().toString() + " Indexing object: " + data.getId() + ": " + attrs.toString()); DocumentBuilder pdb = BuilderFactory.getBuilder(getIndexName()); Document doc = pdb.buildDocument(new Long(data.getId()), attrs); indexManager.addUniqueToIndex(getIndexName(), doc, getUniqueFieldId(), lang); } /** * @param databaseManager * @return */ private List<GenericRecord> getRecords(DatabaseManager databaseManager) throws SQLException { // What was the last object id we indexed? List<GenericRecord> retval = null; Query<Long> query = databaseManager.getQuery(getQueryLastRecord()); Long sid = null; try { sid = query.load(); } finally { query.close(); } if (sid == null) { sid = new Long(0); } // When was the last time we ran the indexing of servers? Query<Date> queryLast = databaseManager.getQuery(getQueryLastIndexDate()); Date lastRun = null; try { lastRun = queryLast.load(); } finally { queryLast.close(); } if (lastRun == null) { lastRun = new Date(0); } // Lookup what objects have not been indexed, or need to be reindexed. Query<GenericRecord> srvrQuery = databaseManager.getQuery( getQueryRecordsToIndex()); try { Map<String, Object> params = new HashMap<String, Object>(); params.put("id", sid); params.put("last_modified", lastRun); log.info("GenericIndexTask<" + super.getClass().toString() + " last processed id = " + sid + ", lastRun was " + lastRun); retval = srvrQuery.loadList(params); log.info("GenericIndexTask<" + super.getClass().toString() + " number of results returned = " + retval.size()); } finally { srvrQuery.close(); } return retval; } /** * Will determine if any records have been deleted from the DB, then will * delete those records from the lucene index. * @return number of deleted records */ protected int handleDeletedRecords(DatabaseManager databaseManager, IndexManager indexManager) throws SQLException { List<Object> records = null; Query<Object> query = null; String uniqField = null; String indexName = null; HashSet<String> idSet = null; try { query = databaseManager.getQuery(getQueryAllIds()); records = query.loadList(Collections.EMPTY_MAP); idSet = new HashSet<String>(); for (Object record : records) { idSet.add(record.toString()); } uniqField = getUniqueFieldId(); indexName = getIndexName(); } finally { if (query != null) { query.close(); } } return indexManager.deleteRecordsNotInList(idSet, indexName, uniqField); } /** * * @param data fully populated DTO object * @return map which represents the fields to index along with their values * @throws ClassCastException when data isn't castable to the intended DTO */ protected abstract Map<String, String> getFieldMap(GenericRecord data) throws ClassCastException; /** * * @return the index name */ public abstract String getIndexName(); /** * @return the Document field name which represents the unique id for this data */ public abstract String getUniqueFieldId(); /** * * @return name of query which shows the last record indexed */ protected abstract String getQueryLastRecord(); /** * * @return name of query which will update the last record indexed */ protected abstract String getQueryUpdateLastRecord(); /** * * @return name of query which will create the last record indexed */ protected abstract String getQueryCreateLastRecord(); /** * * @return name of query which will give back records to be indexed */ protected abstract String getQueryRecordsToIndex(); /** * * @return name of query which will show the date this task last ran */ protected abstract String getQueryLastIndexDate(); /** * @return name of the query which will return all current ids. */ protected abstract String getQueryAllIds(); } 0707010000008E000081B4000000000000000000000001661549540000193D000000000000000000000000000000000000005B00000000spacewalk-search/src/java/com/redhat/satellite/search/scheduler/tasks/IndexErrataTask.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.scheduler.tasks; import com.redhat.satellite.search.db.DatabaseManager; import com.redhat.satellite.search.db.Query; import com.redhat.satellite.search.db.WriteQuery; import com.redhat.satellite.search.db.models.Errata; import com.redhat.satellite.search.index.IndexManager; import com.redhat.satellite.search.index.IndexingException; import com.redhat.satellite.search.index.builder.BuilderFactory; import com.redhat.satellite.search.index.builder.DocumentBuilder; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.document.Document; import org.quartz.Job; import org.quartz.JobDataMap; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import java.sql.SQLException; import java.util.Calendar; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; /** * IndexErrataTask * @version $Rev$ */ public class IndexErrataTask implements Job { private static Logger log = LogManager.getLogger(IndexErrataTask.class); private String lang = "en"; /** * {@inheritDoc} */ public void execute(JobExecutionContext ctx) throws JobExecutionException { JobDataMap jobData = ctx.getJobDetail().getJobDataMap(); DatabaseManager databaseManager = (DatabaseManager)jobData.get("databaseManager"); IndexManager indexManager = (IndexManager)jobData.get("indexManager"); try { List<Errata> errata = getErrata(databaseManager); int count = 0; log.info("found [" + errata.size() + "] errata to index"); for (Iterator<Errata> iter = errata.iterator(); iter.hasNext();) { Errata current = iter.next(); indexErrata(indexManager, current); count++; if (count == 10 || !iter.hasNext()) { if (System.getProperties().get("isTesting") == null) { updateLastErrataId(databaseManager, current.getId()); } count = 0; } } } catch (SQLException e) { throw new JobExecutionException(e); } catch (IndexingException e) { log.debug(e); if (e.getMessage().contains("LockObtainFailedException: Lock obtain timed out")) { log.info("Indexer already running. Skipping"); return; } throw new JobExecutionException(e); } } /** * @param databaseManager * @param sid */ private void updateLastErrataId(DatabaseManager databaseManager, long eid) throws SQLException { WriteQuery updateQuery = databaseManager.getWriterQuery("updateLastErrata"); WriteQuery insertQuery = databaseManager.getWriterQuery("createLastErrata"); try { Map<String, Object> params = new HashMap<String, Object>(); params.put("id", eid); params.put("last_modified", Calendar.getInstance().getTime()); if (updateQuery.update(params) == 0) { insertQuery.insert(params); } } finally { try { if (updateQuery != null) { updateQuery.close(); } } finally { if (insertQuery != null) { insertQuery.close(); } } } } /** * @param indexManager * @param current */ private void indexErrata(IndexManager indexManager, Errata errata) throws IndexingException { Map<String, String> attrs = new HashMap<String, String>(); attrs.put("id", new Long(errata.getId()).toString()); attrs.put("advisory", errata.getAdvisory()); attrs.put("advisoryType", errata.getAdvisoryType()); attrs.put("advisoryName", errata.getAdvisoryName()); attrs.put("advisoryRel", new Long(errata.getAdvisoryRel()).toString()); attrs.put("product", errata.getProduct()); attrs.put("description", errata.getDescription()); attrs.put("synopsis", errata.getSynopsis()); attrs.put("topic", errata.getTopic()); attrs.put("solution", errata.getSolution()); attrs.put("issueDate", errata.getIssueDate()); attrs.put("updateDate", errata.getUpdateDate()); attrs.put("notes", errata.getNotes()); attrs.put("orgId", errata.getOrgId()); attrs.put("created", errata.getCreated()); attrs.put("modified", errata.getModified()); attrs.put("lastModified", errata.getLastModified()); attrs.put("name", errata.getAdvisory()); log.info("Indexing errata: " + errata.getId() + ": " + attrs.toString()); DocumentBuilder edb = BuilderFactory.getBuilder(BuilderFactory.ERRATA_TYPE); Document doc = edb.buildDocument(new Long(errata.getId()), attrs); indexManager.addToIndex("errata", doc, lang); } /** * @param databaseManager * @return */ private List<Errata> getErrata(DatabaseManager databaseManager) throws SQLException { List<Errata> retval = null; Query<Long> query = databaseManager.getQuery("getLastErrataId"); Long eid = null; try { eid = query.load(); } finally { query.close(); } if (eid == null) { eid = new Long(0); } Query<Errata> errataQuery = databaseManager.getQuery("listErrataFromId"); try { retval = errataQuery.loadList(eid); } finally { errataQuery.close(); } return retval; } } 0707010000008F000081B40000000000000000000000016615495400000C2F000000000000000000000000000000000000006400000000spacewalk-search/src/java/com/redhat/satellite/search/scheduler/tasks/IndexHardwareDevicesTask.java/* * Copyright (c) 2008--2013 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.scheduler.tasks; import com.redhat.satellite.search.db.models.GenericRecord; import com.redhat.satellite.search.db.models.HardwareDevice; import com.redhat.satellite.search.index.builder.BuilderFactory; import java.util.HashMap; import java.util.Map; /** * IndexHardwareDevicesTask * @version $Rev$ */ public class IndexHardwareDevicesTask extends GenericIndexTask { /** * {@inheritDoc} */ @Override protected Map<String, String> getFieldMap(GenericRecord data) throws ClassCastException { HardwareDevice dev = (HardwareDevice)data; Map<String, String> attrs = new HashMap<String, String>(); attrs.put("serverId", new Long(dev.getServerId()).toString()); attrs.put("classInfo", dev.getClassInfo()); attrs.put("bus", dev.getBus()); attrs.put("detached", new Long(dev.getDetached()).toString()); attrs.put("device", dev.getDevice()); attrs.put("driver", dev.getDriver()); attrs.put("description", dev.getDescription()); attrs.put("vendorId", dev.getVendorId()); attrs.put("deviceId", dev.getDeviceId()); attrs.put("subVendorId", dev.getSubVendorId()); attrs.put("subDeviceId", dev.getSubDeviceId()); attrs.put("pciType", new Long(dev.getPciType()).toString()); return attrs; } /** * {@inheritDoc} */ @Override public String getIndexName() { return BuilderFactory.HARDWARE_DEVICE_TYPE; } /** * {@inheritDoc} */ @Override protected String getQueryCreateLastRecord() { return "createLastHardwareDevice"; } /** * {@inheritDoc} */ @Override protected String getQueryLastRecord() { return "getLastHardwareDeviceId"; } /** * {@inheritDoc} */ @Override protected String getQueryLastIndexDate() { return "getLastHardwareDeviceIndexRun"; } /** * {@inheritDoc} */ @Override protected String getQueryRecordsToIndex() { return "getHardwareDeviceById"; } /** * {@inheritDoc} */ @Override protected String getQueryUpdateLastRecord() { return "updateLastHardwareDevice"; } /** * {@inheritDoc} */ public String getUniqueFieldId() { return "id"; } /** * {@inheritDoc} */ public String getQueryAllIds() { return "queryAllHwDeviceIds"; } } 07070100000090000081B4000000000000000000000001661549540000180A000000000000000000000000000000000000005D00000000spacewalk-search/src/java/com/redhat/satellite/search/scheduler/tasks/IndexPackagesTask.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.scheduler.tasks; import com.redhat.satellite.search.db.DatabaseManager; import com.redhat.satellite.search.db.Query; import com.redhat.satellite.search.db.WriteQuery; import com.redhat.satellite.search.db.models.RhnPackage; import com.redhat.satellite.search.index.IndexManager; import com.redhat.satellite.search.index.IndexingException; import com.redhat.satellite.search.index.builder.BuilderFactory; import com.redhat.satellite.search.index.builder.DocumentBuilder; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.document.Document; import org.quartz.Job; import org.quartz.JobDataMap; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import java.sql.SQLException; import java.util.Calendar; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; /** * Task to index package information * * @version $Rev$ */ public class IndexPackagesTask implements Job { private static Logger log = LogManager.getLogger(IndexPackagesTask.class); private String lang = "en"; /** * {@inheritDoc} */ public void execute(JobExecutionContext ctx) throws JobExecutionException { JobDataMap jobData = ctx.getJobDetail().getJobDataMap(); DatabaseManager databaseManager = (DatabaseManager)jobData.get("databaseManager"); IndexManager indexManager = (IndexManager)jobData.get("indexManager"); try { if (System.getProperties().get("isTesting") != null) { cleanLastPackage(databaseManager); } List<RhnPackage> packages = getPackages(databaseManager); int count = 0; log.info("found [" + packages.size() + "] packages to index"); for (Iterator<RhnPackage> iter = packages.iterator(); iter.hasNext();) { RhnPackage current = iter.next(); indexPackage(indexManager, current); count++; if (count == 10 || !iter.hasNext()) { if (System.getProperties().get("isTesting") == null) { updateLastPackageId(databaseManager, current.getId()); } count = 0; } } } catch (SQLException e) { throw new JobExecutionException(e); } catch (IndexingException e) { log.debug(e); if (e.getMessage().contains("LockObtainFailedException: Lock obtain timed out")) { log.info("Indexer already running. Skipping"); return; } throw new JobExecutionException(e); } } private void cleanLastPackage(DatabaseManager databaseManager) throws SQLException { WriteQuery query = null; try { query = databaseManager.getWriterQuery("deleteLastPackage"); query.delete(null); } finally { query.close(); } } private void indexPackage(IndexManager indexManager, RhnPackage pkg) throws IndexingException { Map<String, String> attrs = new HashMap<String, String>(); attrs.put("name", pkg.getName()); attrs.put("version", pkg.getVersion()); attrs.put("release", pkg.getRelease()); attrs.put("filename", pkg.getFileName()); attrs.put("description", pkg.getDescription()); attrs.put("summary", pkg.getSummary()); attrs.put("arch", pkg.getArch()); log.info("Indexing package: " + pkg.getId() + ": " + attrs.toString()); DocumentBuilder pdb = BuilderFactory.getBuilder(BuilderFactory.PACKAGES_TYPE); Document doc = pdb.buildDocument(new Long(pkg.getId()), attrs); indexManager.addToIndex("package", doc, lang); } private void updateLastPackageId(DatabaseManager databaseManager, Long packageId) throws SQLException { WriteQuery updateQuery = databaseManager.getWriterQuery("updateLastPackage"); WriteQuery insertQuery = databaseManager.getWriterQuery("createLastPackage"); try { Map<String, Object> params = new HashMap<String, Object>(); params.put("id", packageId); params.put("last_modified", Calendar.getInstance().getTime()); if (updateQuery.update(params) == 0) { insertQuery.insert(params); } } finally { try { if (updateQuery != null) { updateQuery.close(); } } finally { if (insertQuery != null) { insertQuery.close(); } } } } private List<RhnPackage> getPackages(DatabaseManager databaseManager) throws SQLException { List<RhnPackage> retval = null; Query<Long> query = databaseManager.getQuery("getLastPackageId"); Long packageId = null; try { packageId = query.load(); } finally { query.close(); } if (packageId == null) { packageId = new Long(0); } Query<RhnPackage> pkgQuery = databaseManager.getQuery("listPackagesFromId"); try { retval = pkgQuery.loadList(packageId); } finally { pkgQuery.close(); } return retval; } } 07070100000091000081B40000000000000000000000016615495400000C18000000000000000000000000000000000000006500000000spacewalk-search/src/java/com/redhat/satellite/search/scheduler/tasks/IndexServerCustomInfoTask.java/* * Copyright (c) 2008--2013 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.scheduler.tasks; import com.redhat.satellite.search.db.models.GenericRecord; import com.redhat.satellite.search.db.models.ServerCustomInfo; import com.redhat.satellite.search.index.builder.BuilderFactory; import java.util.HashMap; import java.util.Map; /** * IndexServerCustomInfoTask * @version $Rev$ * */ public class IndexServerCustomInfoTask extends GenericIndexTask { /** * {@inheritDoc} */ @Override protected Map<String, String> getFieldMap(GenericRecord data) throws ClassCastException { ServerCustomInfo scInfo = (ServerCustomInfo)data; Map<String, String> attrs = new HashMap<String, String>(); attrs.put("id", new Long(scInfo.getId()).toString()); attrs.put("serverId", new Long(scInfo.getServerId()).toString()); attrs.put("value", scInfo.getValue()); attrs.put("label", scInfo.getLabel()); if (scInfo.getCreatedBy() != null) { attrs.put("createdBy", scInfo.getCreatedBy().toString()); } if (scInfo.getLastModifiedBy() != null) { attrs.put("lastModifiedBy", scInfo.getLastModifiedBy().toString()); } attrs.put("created", scInfo.getCreated()); attrs.put("modified", scInfo.getModified()); return attrs; } /** * {@inheritDoc} */ @Override public String getIndexName() { return BuilderFactory.SERVER_CUSTOM_INFO_TYPE; } /** * {@inheritDoc} */ @Override protected String getQueryCreateLastRecord() { return "createLastServerCustomInfo"; } /** * {@inheritDoc} */ @Override protected String getQueryLastRecord() { return "getLastServerCustomInfoId"; } /** * {@inheritDoc} */ @Override protected String getQueryLastIndexDate() { return "getLastServerCustomInfoIndexRun"; } /** * {@inheritDoc} */ @Override protected String getQueryRecordsToIndex() { return "getServerCustomInfoByIdOrDate"; } /** * {@inheritDoc} */ @Override protected String getQueryUpdateLastRecord() { return "updateLastServerCustomInfo"; } /** * {@inheritDoc} */ public String getUniqueFieldId() { return "id"; } /** * {@inheritDoc} */ public String getQueryAllIds() { return "queryAllServerCustomInfoIds"; } } 07070100000092000081B40000000000000000000000016615495400000B67000000000000000000000000000000000000006100000000spacewalk-search/src/java/com/redhat/satellite/search/scheduler/tasks/IndexSnapshotTagsTask.java/* * Copyright (c) 2008--2013 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.scheduler.tasks; import com.redhat.satellite.search.db.models.GenericRecord; import com.redhat.satellite.search.db.models.SnapshotTag; import com.redhat.satellite.search.index.builder.BuilderFactory; import java.util.HashMap; import java.util.Map; /** * IndexSnapshotTagsTask * @version $Rev$ * */ public class IndexSnapshotTagsTask extends GenericIndexTask { /** * {@inheritDoc} */ @Override protected Map<String, String> getFieldMap(GenericRecord data) throws ClassCastException { SnapshotTag sTag = (SnapshotTag)data; Map<String, String> attrs = new HashMap<String, String>(); attrs.put("uniqId", sTag.getUniqId()); attrs.put("snapshotId", new Long(sTag.getSnapshotId()).toString()); attrs.put("tagNameId", new Long(sTag.getTagNameId()).toString()); attrs.put("serverId", new Long(sTag.getServerId()).toString()); attrs.put("orgId", new Long(sTag.getOrgId()).toString()); attrs.put("name", sTag.getName()); attrs.put("created", sTag.getCreated()); attrs.put("modified", sTag.getModified()); return attrs; } /** * {@inheritDoc} */ @Override public String getIndexName() { return BuilderFactory.SNAPSHOT_TAG_TYPE; } /** * {@inheritDoc} */ @Override protected String getQueryCreateLastRecord() { return "createLastSnapshotTag"; } /** * {@inheritDoc} */ @Override protected String getQueryLastRecord() { return "getLastSnapshotTagId"; } /** * {@inheritDoc} */ @Override protected String getQueryLastIndexDate() { return "getLastSnapshotTagIndexRun"; } /** * {@inheritDoc} */ @Override protected String getQueryRecordsToIndex() { return "getSnapshotTagByIdOrDate"; } /** * {@inheritDoc} */ @Override protected String getQueryUpdateLastRecord() { return "updateLastSnapshotTag"; } /** * {@inheritDoc} */ public String getUniqueFieldId() { return "uniqId"; } /** * {@inheritDoc} */ public String getQueryAllIds() { return "queryAllSnapshotTagIds"; } } 07070100000093000081B400000000000000000000000166154954000013AD000000000000000000000000000000000000005C00000000spacewalk-search/src/java/com/redhat/satellite/search/scheduler/tasks/IndexSystemsTask.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.scheduler.tasks; import com.redhat.satellite.search.db.models.GenericRecord; import com.redhat.satellite.search.db.models.Server; import com.redhat.satellite.search.index.builder.BuilderFactory; import java.util.HashMap; import java.util.Map; // Main tasks: // 1) Index new systems, i.e. system id is greater than last recorded system id indexed. // 2) Update the existing index of systems which have been modified // 3) Remove systems which have been deleted from the system. /** * IndexSystemsTask * @version $Rev$ */ public class IndexSystemsTask extends GenericIndexTask { /** * {@inheritDoc} */ @Override protected Map<String, String> getFieldMap(GenericRecord data) throws ClassCastException { Server srvr = (Server)data; Map<String, String> attrs = new HashMap<String, String>(); attrs.put("id", new Long(srvr.getId()).toString()); attrs.put("system_id", new Long(srvr.getId()).toString()); attrs.put("name", srvr.getName()); attrs.put("description", srvr.getDescription()); attrs.put("info", srvr.getInfo()); attrs.put("runningKernel", srvr.getRunningKernel()); attrs.put("machine", srvr.getMachine()); attrs.put("rack", srvr.getRack()); attrs.put("room", srvr.getRoom()); attrs.put("building", srvr.getBuilding()); attrs.put("address1", srvr.getAddress1()); attrs.put("address2", srvr.getAddress2()); attrs.put("city", srvr.getCity()); attrs.put("state", srvr.getState()); attrs.put("country", srvr.getCountry()); attrs.put("hostname", srvr.getHostname()); attrs.put("ipaddr", srvr.getIpaddr()); attrs.put("ip6addr", srvr.getIp6addr()); attrs.put("dmiVendor", srvr.getDmiVendor()); attrs.put("dmiSystem", srvr.getDmiSystem()); attrs.put("dmiProduct", srvr.getDmiProduct()); attrs.put("dmiBiosVendor", srvr.getDmiBiosVendor()); attrs.put("dmiBiosVersion", srvr.getDmiBiosVersion()); attrs.put("dmiBiosRelease", srvr.getDmiBiosRelease()); attrs.put("dmiAsset", srvr.getDmiAsset()); attrs.put("dmiBoard", srvr.getDmiBoard()); attrs.put("cpuBogoMIPs", srvr.getCpuBogoMIPS()); attrs.put("cpuCache", srvr.getCpuCache()); attrs.put("cpuFamily", srvr.getCpuFamily()); attrs.put("cpuMHz", srvr.getCpuMHz()); attrs.put("cpuStepping", srvr.getCpuStepping()); attrs.put("cpuFlags", srvr.getCpuFlags()); attrs.put("cpuModel", srvr.getCpuModel()); attrs.put("cpuVersion", srvr.getCpuVersion()); attrs.put("cpuVendor", srvr.getCpuVendor()); if (srvr.getCpuNumberOfCpus() != null) { attrs.put("cpuNumberOfCpus", srvr.getCpuNumberOfCpus().toString()); } attrs.put("cpuAcpiVersion", srvr.getCpuAcpiVersion()); attrs.put("cpuApic", srvr.getCpuApic()); attrs.put("cpuApmVersion", srvr.getCpuApmVersion()); attrs.put("cpuChipset", srvr.getCpuChipset()); attrs.put("checkin", srvr.getCheckin()); attrs.put("registered", srvr.getRegistered()); attrs.put("ram", srvr.getRam()); attrs.put("swap", srvr.getSwap()); attrs.put("uuid", srvr.getUuid()); return attrs; } /** * {@inheritDoc} */ @Override public String getIndexName() { return BuilderFactory.SERVER_TYPE; } /** * {@inheritDoc} */ @Override protected String getQueryCreateLastRecord() { return "createLastServer"; } /** * {@inheritDoc} */ @Override protected String getQueryLastRecord() { return "getLastServerId"; } /** * {@inheritDoc} */ @Override protected String getQueryLastIndexDate() { return "getLastServerIndexRun"; } /** * {@inheritDoc} */ @Override protected String getQueryRecordsToIndex() { return "getServerByIdOrDate"; } /** * {@inheritDoc} */ @Override protected String getQueryUpdateLastRecord() { return "updateLastServer"; } /** * {@inheritDoc} */ public String getUniqueFieldId() { return "id"; } /** * {@inheritDoc} */ public String getQueryAllIds() { return "queryAllServerIds"; } } 07070100000094000081B40000000000000000000000016615495400000A7E000000000000000000000000000000000000005F00000000spacewalk-search/src/java/com/redhat/satellite/search/scheduler/tasks/IndexXccdfIdentTask.java/* * Copyright (c) 2012 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.scheduler.tasks; import com.redhat.satellite.search.db.models.GenericRecord; import com.redhat.satellite.search.db.models.XccdfIdent; import com.redhat.satellite.search.index.builder.BuilderFactory; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.util.HashMap; import java.util.Map; /** * IndexXccdfIdentTask * @version $Rev$ */ public class IndexXccdfIdentTask extends GenericIndexTask { private static Logger log = LogManager.getLogger(IndexXccdfIdentTask.class); /** * {@inheritDoc} */ @Override protected Map<String, String> getFieldMap(GenericRecord data) throws ClassCastException { XccdfIdent dev = (XccdfIdent)data; Map<String, String> attrs = new HashMap<String, String>(); attrs.put("id", new Long(dev.getId()).toString()); attrs.put("identifier", dev.getIdentifier()); return attrs; } /** * {@inheritDoc} */ @Override public String getIndexName() { return BuilderFactory.XCCDF_IDENT_TYPE; } /** * {@inheritDoc} */ @Override protected String getQueryCreateLastRecord() { return "createLastXccdfIdent"; } /** * {@inheritDoc} */ @Override protected String getQueryLastRecord() { return "getLastXccdfIdentId"; } /** * {@inheritDoc} */ @Override protected String getQueryLastIndexDate() { return "getLastXccdfIdentIndexRun"; } /** * {@inheritDoc} */ @Override protected String getQueryRecordsToIndex() { return "getXccdfIdentById"; } /** * {@inheritDoc} */ @Override protected String getQueryUpdateLastRecord() { return "updateLastXccdfIdent"; } /** * {@inheritDoc} */ public String getUniqueFieldId() { return "id"; } /** * {@inheritDoc} */ public String getQueryAllIds() { return "queryAllXccdfIdentIds"; } } 07070100000095000041FD0000000000000000000000026615495400000000000000000000000000000000000000000000004C00000000spacewalk-search/src/java/com/redhat/satellite/search/scheduler/tasks/tests07070100000096000081B40000000000000000000000016615495400001CB2000000000000000000000000000000000000006500000000spacewalk-search/src/java/com/redhat/satellite/search/scheduler/tasks/tests/IndexErrataTaskTest.java/* * Copyright (c) 2008--2015 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.scheduler.tasks.tests; import static org.quartz.JobBuilder.newJob; import static org.quartz.SimpleScheduleBuilder.simpleSchedule; import static org.quartz.TriggerBuilder.newTrigger; import com.redhat.satellite.search.config.Configuration; import com.redhat.satellite.search.db.DatabaseManager; import com.redhat.satellite.search.db.WriteQuery; import com.redhat.satellite.search.index.IndexManager; import com.redhat.satellite.search.index.IndexingException; import com.redhat.satellite.search.scheduler.tasks.IndexErrataTask; import com.redhat.satellite.search.tests.BaseTestCase; import com.redhat.satellite.search.tests.TestUtil; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.document.Document; import org.quartz.JobBuilder; import org.quartz.JobDataMap; import org.quartz.JobExecutionContext; import org.quartz.Scheduler; import org.quartz.SchedulerException; import org.quartz.SimpleTrigger; import org.quartz.Trigger; import org.quartz.Trigger.CompletedExecutionInstruction; import org.quartz.TriggerListener; import org.quartz.impl.StdSchedulerFactory; import org.quartz.impl.triggers.AbstractTrigger; import org.quartz.impl.triggers.SimpleTriggerImpl; import org.quartz.spi.MutableTrigger; import java.util.Date; import java.util.HashMap; import java.util.Map; /** * IndexErrataTaskTest * @version $Rev$ */ public class IndexErrataTaskTest extends BaseTestCase { private static Logger log = LogManager.getLogger(IndexErrataTaskTest.class); private Scheduler scheduler; @Override public void tearDown() throws Exception { DatabaseManager databaseManager = (DatabaseManager) container.getComponentInstanceOfType(DatabaseManager.class); WriteQuery updateQuery = databaseManager.getWriterQuery("updateLastErrata"); Map<String, Object> params = new HashMap<String, Object>(); params.put("id", 0L); params.put("last_modified", new Date(0)); updateQuery.update(params); updateQuery.close(); if (scheduler != null) { scheduler.shutdown(false); } super.tearDown(); } public void testExecute() throws InterruptedException, SchedulerException { DatabaseManager databaseManager = (DatabaseManager) container.getComponentInstanceOfType(DatabaseManager.class); IndexManager indexManager = (IndexManager) container.getComponentInstanceOfType(IndexManager.class); try { scheduler = StdSchedulerFactory.getDefaultScheduler(); } catch (SchedulerException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } SimpleTrigger trigger = newTrigger().withIdentity("index", "default") .forJob("index", "default") .startAt(new Date()) .endAt(null) .withSchedule(simpleSchedule() .withRepeatCount(0) .withIntervalInMilliseconds(100)) .build(); MutableTrigger mtrigger = null; if (trigger instanceof MutableTrigger) { mtrigger = (MutableTrigger) trigger; mtrigger.setMisfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT); } else { log.error("Cannot set MisfireInstruction since trigger is not instance of MutableTrigger: " + trigger); } JobBuilder detail = newJob(IndexErrataTask.class) .withIdentity("index", "default"); JobDataMap jobData = new JobDataMap(); jobData.put("indexManager", indexManager); jobData.put("databaseManager", databaseManager); detail.usingJobData(jobData); try { scheduler.getListenerManager().addTriggerListener(new TestTrigger()); if (trigger instanceof MutableTrigger) { scheduler.scheduleJob(detail.build(), mtrigger); } else { scheduler.scheduleJob(detail.build(), trigger); } } catch (SchedulerException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { scheduler.start(); } catch (SchedulerException e) { System.out.println("woo hoo"); } Thread.sleep(1000); if(!scheduler.isShutdown()) { scheduler.shutdown(true); } System.out.println("running"); } /** * {@inheritDoc} */ @Override protected Class[] getComponentClasses() { Class[] comps = {DatabaseManager.class, TestIndexManager.class}; return TestUtil.buildComponentsList(comps); } public static class TestIndexManager extends IndexManager { @Override public void addToIndex(String indexName, Document doc, String lang) throws IndexingException { assertNotNull(doc); assertNotNull(doc.getField("advisory")); assertNotNull(doc.getField("advisory").stringValue()); log.info("idx[" + indexName + "] doc [" + doc + "]"); } /** * @param config */ public TestIndexManager(Configuration config) { super(config); } } public static class TestTrigger implements TriggerListener { /** * {@inheritDoc} */ @Override public String getName() { return "test trigger"; } /** * {@inheritDoc} */ public void triggerComplete(Trigger trigger, JobExecutionContext context, int triggerInstructionCode) { System.out.println("**************************** completed"); } /** * {@inheritDoc} */ @Override public void triggerFired(Trigger trigger, JobExecutionContext context) { System.out.println("**************************** fired"); } /** * {@inheritDoc} */ @Override public void triggerMisfired(Trigger trigger) { System.out.println("**************************** misfire"); } /** * {@inheritDoc} */ @Override public boolean vetoJobExecution(Trigger trigger, JobExecutionContext context) { return false; } @Override public void triggerComplete(Trigger arg0, JobExecutionContext arg1, CompletedExecutionInstruction arg2) { } } } 07070100000097000081B40000000000000000000000016615495400001CA0000000000000000000000000000000000000006600000000spacewalk-search/src/java/com/redhat/satellite/search/scheduler/tasks/tests/IndexSystemsTaskTest.java/* * Copyright (c) 2008--2013 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ package com.redhat.satellite.search.scheduler.tasks.tests; import static org.quartz.JobBuilder.newJob; import static org.quartz.SimpleScheduleBuilder.simpleSchedule; import static org.quartz.TriggerBuilder.newTrigger; import com.redhat.satellite.search.config.Configuration; import com.redhat.satellite.search.db.DatabaseManager; import com.redhat.satellite.search.db.WriteQuery; import com.redhat.satellite.search.index.IndexManager; import com.redhat.satellite.search.index.IndexingException; import com.redhat.satellite.search.scheduler.tasks.IndexSystemsTask; import com.redhat.satellite.search.tests.BaseTestCase; import com.redhat.satellite.search.tests.TestUtil; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.document.Document; import org.quartz.JobBuilder; import org.quartz.JobDataMap; import org.quartz.JobExecutionContext; import org.quartz.Scheduler; import org.quartz.SchedulerException; import org.quartz.SimpleTrigger; import org.quartz.Trigger; import org.quartz.Trigger.CompletedExecutionInstruction; import org.quartz.TriggerListener; import org.quartz.impl.StdSchedulerFactory; import org.quartz.impl.triggers.AbstractTrigger; import org.quartz.spi.MutableTrigger; import java.util.Date; import java.util.HashMap; import java.util.Map; /** * IndexSystemsTaskTest * @version $Rev$ */ public class IndexSystemsTaskTest extends BaseTestCase { private static Logger log = LogManager.getLogger(IndexSystemsTaskTest.class); private Scheduler scheduler; @Override public void tearDown() throws Exception { DatabaseManager databaseManager = (DatabaseManager) container.getComponentInstanceOfType(DatabaseManager.class); WriteQuery updateQuery = databaseManager.getWriterQuery("updateLastServer"); Map<String, Object> params = new HashMap<String, Object>(); params.put("id", 0L); params.put("last_modified", new Date(0)); updateQuery.update(params); updateQuery.close(); scheduler.shutdown(false); super.tearDown(); } public void testExecute() throws InterruptedException, SchedulerException { DatabaseManager databaseManager = (DatabaseManager) container.getComponentInstanceOfType(DatabaseManager.class); IndexManager indexManager = (IndexManager) container.getComponentInstanceOfType(IndexManager.class); try { scheduler = StdSchedulerFactory.getDefaultScheduler(); } catch (SchedulerException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } SimpleTrigger trigger = newTrigger() .withIdentity("index", "default") .forJob("index", "default") .startAt(new Date()) .endAt(null) .withSchedule(simpleSchedule() .withRepeatCount(0) .withIntervalInMilliseconds(100)) .build(); MutableTrigger mtrigger = null; if (trigger instanceof MutableTrigger) { mtrigger = (MutableTrigger) trigger; mtrigger.setMisfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT); } else { log.error("Cannot set MisfireInstruction since trigger is not instance of MutableTrigger: " + trigger); } JobBuilder detail = newJob(IndexSystemsTask.class) .withIdentity("index", "default"); JobDataMap jobData = new JobDataMap(); jobData.put("indexManager", indexManager); jobData.put("databaseManager", databaseManager); detail.usingJobData(jobData); try { scheduler.getListenerManager().addTriggerListener(new TestTrigger()); if (trigger instanceof MutableTrigger) { scheduler.scheduleJob(detail.build(), mtrigger); } else { scheduler.scheduleJob(detail.build(), trigger); } } catch (SchedulerException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { scheduler.start(); } catch (SchedulerException e) { System.out.println("woo hoo"); } Thread.sleep(1000); if(!scheduler.isShutdown()) { scheduler.shutdown(true); } System.out.println("running"); } /** * {@inheritDoc} */ @Override protected Class[] getComponentClasses() { Class[] comps = {DatabaseManager.class, TestIndexManager.class}; return TestUtil.buildComponentsList(comps); } public static class TestIndexManager extends IndexManager { @Override public void addToIndex(String indexName, Document doc, String lang) throws IndexingException { assertNotNull(doc); assertNotNull(doc.getField("id")); assertNotNull(doc.getField("name").stringValue()); assertNotNull(doc.getField("description").stringValue()); assertNotNull(doc.getField("info").stringValue()); log.info("idx[" + indexName + "] doc [" + doc + "]"); } /** * @param config */ public TestIndexManager(Configuration config) { super(config); } } public static class TestTrigger implements TriggerListener { /** * {@inheritDoc} */ @Override public String getName() { return "test trigger"; } /** * {@inheritDoc} */ public void triggerComplete(Trigger trigger, JobExecutionContext context, int triggerInstructionCode) { System.out.println("**************************** completed"); } /** * {@inheritDoc} */ @Override public void triggerFired(Trigger trigger, JobExecutionContext context) { System.out.println("**************************** fired"); } /** * {@inheritDoc} */ @Override public void triggerMisfired(Trigger trigger) { System.out.println("**************************** misfire"); } /** * {@inheritDoc} */ @Override public boolean vetoJobExecution(Trigger trigger, JobExecutionContext context) { return false; } @Override public void triggerComplete(Trigger arg0, JobExecutionContext arg1, CompletedExecutionInstruction arg2) { } } } 07070100000098000041FD0000000000000000000000026615495400000000000000000000000000000000000000000000004600000000spacewalk-search/src/java/com/redhat/satellite/search/scheduler/tests07070100000099000081B400000000000000000000000166154954000007DA000000000000000000000000000000000000005F00000000spacewalk-search/src/java/com/redhat/satellite/search/scheduler/tests/ScheduleManagerTest.javapackage com.redhat.satellite.search.scheduler.tests; import com.redhat.satellite.search.index.IndexManager; import com.redhat.satellite.search.index.IndexingException; import com.redhat.satellite.search.index.QueryParseException; import com.redhat.satellite.search.index.Result; import com.redhat.satellite.search.index.builder.BuilderFactory; import com.redhat.satellite.search.scheduler.ScheduleManager; import com.redhat.satellite.search.tests.BaseTestCase; import com.redhat.satellite.search.tests.TestUtil; import java.util.List; public class ScheduleManagerTest extends BaseTestCase { @SuppressWarnings("unchecked") @Override protected Class[] getComponentClasses() { return TestUtil.buildComponentsList(ScheduleManager.class); } public void testIndexing() throws IndexingException, QueryParseException { try { Thread.sleep(30000); IndexManager mgr = (IndexManager) container.getComponentInstance(IndexManager.class); List<Result>hits = mgr.search("package", "description:package", "en"); assertTrue(hits.size() > 0); } catch (InterruptedException e) { return; } } public void testTriggerIndexTask() { ScheduleManager sm = new ScheduleManager(null, null); assertTrue(sm.triggerIndexTask(BuilderFactory.ERRATA_TYPE)); assertTrue(sm.triggerIndexTask(BuilderFactory.HARDWARE_DEVICE_TYPE)); assertTrue(sm.triggerIndexTask(BuilderFactory.PACKAGES_TYPE)); assertTrue(sm.triggerIndexTask(BuilderFactory.SERVER_CUSTOM_INFO_TYPE)); assertTrue(sm.triggerIndexTask(BuilderFactory.SERVER_TYPE)); assertTrue(sm.triggerIndexTask(BuilderFactory.SNAPSHOT_TAG_TYPE)); assertTrue(sm.triggerIndexTask(BuilderFactory.XCCDF_IDENT_TYPE)); assertFalse(sm.triggerIndexTask(null)); assertFalse(sm.triggerIndexTask("biteme")); assertFalse(sm.triggerIndexTask("")); } } 0707010000009A000041FD0000000000000000000000026615495400000000000000000000000000000000000000000000003C00000000spacewalk-search/src/java/com/redhat/satellite/search/tests0707010000009B000081B40000000000000000000000016615495400000392000000000000000000000000000000000000004E00000000spacewalk-search/src/java/com/redhat/satellite/search/tests/BaseTestCase.javapackage com.redhat.satellite.search.tests; import com.redhat.satellite.search.config.Configuration; import org.picocontainer.defaults.DefaultPicoContainer; import junit.framework.TestCase; public abstract class BaseTestCase extends TestCase { protected DefaultPicoContainer container; @Override protected void setUp() throws Exception { System.getProperties().put("isTesting", "true"); super.setUp(); container = TestUtil.buildContainer(getComponentClasses()); container.start(); } @Override protected void tearDown() throws Exception { super.tearDown(); Configuration config = (Configuration) container.getComponentInstanceOfType(Configuration.class); TestUtil.cleanupDirectories(config); container.stop(); } @SuppressWarnings("unchecked") protected abstract Class[] getComponentClasses(); } 0707010000009C000081B4000000000000000000000001661549540000120E000000000000000000000000000000000000004A00000000spacewalk-search/src/java/com/redhat/satellite/search/tests/TestUtil.javapackage com.redhat.satellite.search.tests; import com.redhat.satellite.search.config.Configuration; import org.picocontainer.defaults.DefaultPicoContainer; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.StringReader; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.List; import java.util.Random; public class TestUtil { private TestUtil() { } @SuppressWarnings("unchecked") public static DefaultPicoContainer buildContainer(Class[] components) throws IOException { Configuration config = makeConfiguration(); DefaultPicoContainer container = new DefaultPicoContainer(); container.registerComponentInstance("appConfig", config); for (int x = 0; x < components.length; x++) { container.registerComponentImplementation(components[x]); } return container; } @SuppressWarnings("unchecked") public static Class[] buildComponentsList(Class component) { Class[] arg = {component}; return buildComponentsList(arg); } @SuppressWarnings("unchecked") public static Class[] buildComponentsList(Class[] components) { List<Class>accum = new ArrayList<Class>(); for (int x = 0; x < components.length; x++) { processComponent(components[x], accum); } Class[] retval = new Class[accum.size()]; accum.toArray(retval); return retval; } public static Configuration makeConfiguration() throws IOException { String prefix = "search-server-test"; String indexWorkDir = generateTempDir(prefix); StringBuilder builder = new StringBuilder(); builder.append("search.index_work_dir=").append(indexWorkDir).append("\n"); builder.append("search.rpc_port=").append(generatePortNumber()).append("\n"); builder.append("search.rpc_handlers="); builder.append("index:com.redhat.satellite.search.rpc.handlers.IndexHandler\n\n"); // see if we overrode any properties in test.properties File f = new File("src/config/test.properties"); if (f.exists()) { FileReader fr = new FileReader(f); BufferedReader br = new BufferedReader(fr); String line = null; while ((line = br.readLine()) != null) { builder.append(line); builder.append("\n"); } } StringReader sr = new StringReader(builder.toString()); return new Configuration(new BufferedReader(sr)); } public static void cleanupDirectories(Configuration config) throws IOException { String workDir = config.getString("search.index_work_dir", null); if (workDir != null) { File f = new File(workDir); if (f.exists() && f.isDirectory()) { Runtime.getRuntime().exec("rm -rf " + workDir); } } } @SuppressWarnings("unchecked") private static List<Class> processComponent(Class component, List<Class>accum) { if (component == Configuration.class) { return accum; } if (accum.indexOf(component) == -1) { accum.add(component); } Constructor[] constructors = component.getConstructors(); if (constructors != null) { for (int x = 0;x < constructors.length; x++) { Class[] paramTypes = constructors[x].getParameterTypes(); if (paramTypes.length > 0) { for (int y = 0;y < paramTypes.length; y++) { if (isCandidate(paramTypes[y].getName())) { processComponent(paramTypes[y], accum); } } } } } return accum; } private static boolean isCandidate(String className) { boolean retval = true; if (className.startsWith("java.") || className.startsWith("javax.") || className.startsWith("com.sun.")) { retval = false; } return retval; } private static String generateTempDir(String prefix) throws IOException { File f = File.createTempFile(prefix, null); f.delete(); return f.getAbsolutePath(); } private static String generatePortNumber() { Random r = new Random(System.nanoTime()); int port = 0; while (port < 1024) { port = r.nextInt(20001); } return String.valueOf(port); } } 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor