Hi all

First up, I know this isn't the Java Newbies mailing list but...

I've been working on the 'createCve' call for a while now without
success.  Below is a 'git diff' and also a new file 'CveFactory.java'.
 The problem simply is that when I call 'createCve("cve-1234-5678")',
nothing happens.  It looks like it works but when I do a 'select *
from rhnCve;' in sqlplus, no rows are returned.

Could someone please point me in the right direction with this?

Thanks

CC

diff --git 
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/errata/ErrataHandler.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/errata/ErrataHandler.java
index 98fc044..cfad7b3 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/errata/ErrataHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/errata/ErrataHandler.java
@@ -22,6 +22,7 @@ import com.redhat.rhn.domain.channel.Channel;
 import com.redhat.rhn.domain.channel.ChannelFactory;
 import com.redhat.rhn.domain.channel.InvalidChannelRoleException;
 import com.redhat.rhn.domain.errata.Bug;
+import com.redhat.rhn.domain.errata.Cve;
 import com.redhat.rhn.domain.errata.Errata;
 import com.redhat.rhn.domain.errata.ErrataFactory;
 import com.redhat.rhn.domain.errata.Keyword;
@@ -30,6 +31,7 @@ import com.redhat.rhn.domain.rhnpackage.Package;
 import com.redhat.rhn.domain.rhnpackage.PackageFactory;
 import com.redhat.rhn.domain.user.User;
 import com.redhat.rhn.frontend.dto.CVE;
+import com.redhat.rhn.frontend.dto.ErrataOverview;
 import com.redhat.rhn.frontend.xmlrpc.BaseHandler;
 import com.redhat.rhn.frontend.xmlrpc.DuplicateErrataException;
 import com.redhat.rhn.frontend.xmlrpc.InvalidAdvisoryReleaseException;
@@ -1218,4 +1220,29 @@ public class ErrataHandler extends BaseHandler {
        return erratas;
    }

+    public Integer createCve(String sessionKey, List<String> cveNames) {
+        // Get the logged in user. We don't care what roles this user has, we
+        // just want to make sure the caller is logged in.
+        User loggedInUser = getLoggedInUser(sessionKey);
+
+        for (String name : cveNames) {
+            ErrataManager.createCve(name);
+        }
+
+        return cveNames.size();
+    }
+
 }
diff --git a/java/code/src/com/redhat/rhn/manager/errata/ErrataManager.java
b/java/code/src/com/redhat/rhn/manager/errata/ErrataManager.java
index a7ebfde..a3d6afd 100644
--- a/java/code/src/com/redhat/rhn/manager/errata/ErrataManager.java
+++ b/java/code/src/com/redhat/rhn/manager/errata/ErrataManager.java
@@ -28,6 +28,8 @@ import com.redhat.rhn.common.security.PermissionException;
 import com.redhat.rhn.domain.channel.Channel;
 import com.redhat.rhn.domain.channel.ChannelFactory;
 import com.redhat.rhn.domain.errata.Bug;
+import com.redhat.rhn.domain.errata.Cve;
+import com.redhat.rhn.domain.errata.CveFactory;
 import com.redhat.rhn.domain.errata.Errata;
 import com.redhat.rhn.domain.errata.ErrataFactory;
 import com.redhat.rhn.domain.errata.ErrataFile;
@@ -214,6 +216,14 @@ public class ErrataManager extends BaseManager {
    }

    /**
+     * Creates a new CVE object.
+     * @return Returns a fresh CVE
+     */
+    public static Cve createCve(String name) {
+        return CveFactory.createCve(name);
+    }
+
+    /**
     * Creates a new Unpublished Bug with the id and summary given.
     * @param id The id for the new bug.
     * @param summary The summary for the new bug.



code/src/com/redhat/rhn/domain/errata/CveFactory.java

/**
 * Copyright (c) 2009--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.rhn.domain.errata;

import com.redhat.rhn.common.hibernate.HibernateFactory;

import org.apache.log4j.Logger;


/**
 * CveFactory - the singleton class used to fetch and store
 * com.redhat.rhn.domain.errata.Cve objects from the
 * database.
 * @version $Rev$
 */
public class CveFactory extends HibernateFactory {

    private static CveFactory singleton = new CveFactory();
    private static Logger log = Logger.getLogger(CveFactory.class);

    private CveFactory() {
        super();
    }

    /**
     * Get the Logger for the derived class so log messages
     * show up on the correct class
     */
    protected Logger getLogger() {
        return log;
    }

    /**
     * Create a new Cve from scratch
     * @return the Cve created
     */
    public static Cve createCve(String name) {
        Cve cve = new Cve();

        cve.setName(name);
        return cve;
    }

}

-- 
RHCE#805007969328369

_______________________________________________
Spacewalk-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to