/** * Creates the Channel based on the parameters that were set. * * @return the newly created Channel * @throws InvalidChannelLabelException thrown if label is in use or invalid. * @throws InvalidChannelNameException throw if name is in use or invalid. * @throws IllegalArgumentException thrown if label, name or user are null. * @throws InvalidParentChannelException thrown if parent label is not a valid base channel. */ public Channel create() throws InvalidChannelLabelException, InvalidChannelNameException, InvalidParentChannelException { verifyRequiredParameters(); verifyChannelName(name); verifyChannelLabel(label); verifyGpgInformation(); if (ChannelFactory.doesChannelNameExist(name)) { throw new InvalidChannelNameException( name, InvalidChannelNameException.Reason.NAME_IN_USE, "edit.channel.invalidchannelname.nameinuse", name); } if (ChannelFactory.doesChannelLabelExist(label)) { throw new InvalidChannelLabelException( label, InvalidChannelLabelException.Reason.LABEL_IN_USE, "edit.channel.invalidchannellabel.labelinuse", label); } ChannelArch ca = ChannelFactory.findArchByLabel(archLabel); if (ca == null) { throw new IllegalArgumentException("Invalid architecture label"); } ChecksumType ct = ChannelFactory.findChecksumTypeByLabel(checksum); Channel c = ChannelFactory.createChannel(); c.setLabel(label); c.setName(name); c.setSummary(summary); c.setDescription(description); c.setOrg(user.getOrg()); c.setBaseDir("/dev/null"); c.setChannelArch(ca); c.setChecksumType(ct); c.setGPGKeyId(gpgKeyId); c.setGPGKeyUrl(gpgKeyUrl); c.setGPGKeyFp(gpgKeyFp); c.setAccess(access); c.setMaintainerName(maintainerName); c.setMaintainerEmail(maintainerEmail); c.setMaintainerPhone(maintainerPhone); c.setSupportPolicy(supportPolicy); // handles either parent id or label setParentChannel(c, user, parentLabel, parentId); c.addChannelFamily(user.getOrg().getPrivateChannelFamily()); // need to save before calling stored proc below ChannelFactory.save(c); ChannelManager.queueChannelChange(c.getLabel(), "createchannel", "createchannel"); ChannelFactory.refreshNewestPackageCache(c, WEB_CHANNEL_CREATED); return c; }