SALEM – A Lynn man who was involved in the June 2007 Middleton Jail melee in which a group of seven inmates attacked guards with shackles, broomsticks and mop handles received up to eight years in state prison Monday.Juan Rivera, 25, who last lived at 58 Memorial Drive in Lynn, pleaded guilty in Salem Superior Court to four out of the seven charges against him: two counts of assault and battery with a dangerous weapon, assault with a dangerous weapon and malicious destruction of property.Judge Howard J. Whitehead sentenced Rivera to serve six-to-eight years in state prison on the two counts of assault and battery with a dangerous weapon charges and the destruction of property.Rivera also was given another four-to-five-year prison term on the charge for assault with a dangerous weapon, but that will be served simultaneously with the first term of incarceration instead of one after the other.Rivera will not be eligible for parole until 2013, said defense lawyer John V. Apruzzese.The sentence was the result of a plea bargain reached by Assistant District Attorney Michael A. Patten and Apruzzese.Patten said the incident took place shortly after midnight on June 7, after prison guards had taken the seven inmates, including Rivera, confined to the high-security segregation unit, to the showers.The inmates were told to sit on a bench outside the shower stalls, where they were unshackled and told to undress. They then were locked into individual shower stalls, but surveillance video showed the men crawling out beneath the two-foot gap beneath the shower stalls and attacking the desk guards, said Patten.Rivera admitted he grabbed a set of steel waist chains on the bench outside the shower stalls and began beating one of the guards with it and then threw a computer monitor at two guards, which missed them and crashed to the floor.The inmates took brooms and mop handles from the utility closet and began to attack the guards, destroyed equipment on the control desk, including a computer screen, keyboard and other parts, before the riot was subdued by other correctional officers who quickly responded to the back up call.Three other remaining charges against Rivera, for assault and battery with a dangerous weapon causing serious bodily injury, assault with a dangerous weapon and destruction of property were dropped by the commonwealth as part of the plea concession reached.In addition, as part of negotiations the prison term will also run simultaneously with the three-to-five-year prison term Rivera is currently serving for armed robbery out of Bristol County.Four other participants: Angel Andrades, 28, of Lynn, Eddy Lopez, also known as Miguel Torres, 30, of Lawrence, Jurrell Laronal, 22, of Dorchester and Alexis Marquez Maldonado, 29, of Haverhill, previously pleaded guilty to their role in the riot and are currently serving sentences.Two others, Raul Carraquillo 35, and Miguel Diaz, 21, both of Lawrence, remain in custody awaiting trial on the case.