Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Samarth_1710991710_6G-02/dispatcher-servlet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:c="http://www.springframework.org/schema/c"
xmlns:cache="http://www.springframework.org/schema/cache" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:p="http://www.springframework.org/schema/p" xmlns:security="http://www.springframework.org/schema/security"
xmlns:task="http://www.springframework.org/schema/task" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.3.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-4.3.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.3.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">


<context:component-scan base-package="com.newshunt"></context:component-scan>
<mvc:annotation-driven />
<bean id="tt" class=" org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>

<mvc:resources mapping="/resources/**" location="/resources/"
cache-period="31556926"/>

<mvc:annotation-driven />
</beans>
38 changes: 38 additions & 0 deletions Samarth_1710991710_6G-02/hibernate.cfg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">


<hibernate-configuration>
<session-factory>

<property name = "hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</property>

<property name = "hibernate.connection.driver_class">
com.mysql.jdbc.Driver
</property>

<!-- Assume test is the database name -->

<property name = "hibernate.connection.url">
jdbc:mysql://localhost:3306/news_hunt
</property>

<property name = "hibernate.connection.username">
root
</property>

<property name = "hibernate.connection.password">
rootroot
</property>
<property name="hibrenate.hbm2ddl.auto">update</property>
<!-- List of XML mapping files -->
<mapping class = "com.newshunt.daomodel.signup"/>
<mapping class = "com.newshunt.daomodel.MenuDao"/>
<mapping class = "com.newshunt.daomodel.ChannelListDao"/>
<mapping class = "com.newshunt.daomodel.FeedbackDao"/>
<mapping class = "com.newshunt.daomodel.AdminMenuDao"/>
</session-factory>
</hibernate-configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.newshunt.accountmanagement.controller;

import javax.servlet.http.HttpSession;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.newshunt.daomodel.signup;
@Controller

public class AccountInfo
{
@RequestMapping("/accountInfo")
public String accountInfo()
{
return "accountPage";
}

@RequestMapping(value="/updateAccountInfo", method=RequestMethod.POST)
@ResponseBody
public byte updateAccountInfo(@RequestBody signup rec, HttpSession hs)
{
byte flag = 0;
try
{
String un = hs.getAttribute("un").toString();
Configuration cfg= new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory sf = cfg.buildSessionFactory();
Session ss = sf.openSession();
Criteria cr = ss.createCriteria(signup.class);
cr.add(Restrictions.eq("email", un));
signup r = (signup)cr.uniqueResult();
r.setName(rec.getName());
r.setPassword(rec.getPassword());
r.setPhone(rec.getPhone());
ss.beginTransaction().commit();
flag = 1;
}
catch(Exception e)
{
e.printStackTrace();
}
return flag;
}

@RequestMapping(value="/fetchAccountInfo", method=RequestMethod.POST)
@ResponseBody
public signup fetchinfo(HttpSession hs)
{
String un = hs.getAttribute("un").toString();
Configuration cfg= new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory sf = cfg.buildSessionFactory();
Session ss = sf.openSession();
Criteria cr = ss.createCriteria(signup.class);
cr.add(Restrictions.eq("email", un));
signup r = (signup)cr.uniqueResult();
return r;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
package com.newshunt.admin.controller;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.newshunt.daomodel.ChannelListDao;
import com.newshunt.daomodel.MenuDao;
import com.newshunt.daomodel.signup;

@Controller
public class AdminChannelManagement
{
@RequestMapping("/AddUserChannel")
public String AddUserChannel()
{
return "admin/addUserChannel";
}

@RequestMapping(value="/ChannelAddOn", method = RequestMethod.POST)
@ResponseBody
public byte ChannelAddOn(@RequestBody ChannelListDao r)
{
byte a=0;
try
{
ChannelListDao p = new ChannelListDao();
p.setId(r.getId());
p.setTitle(r.getTitle());
p.setDescription(r.getDescription());
p.setImage(r.getImage());
p.setUrl(r.getUrl());
Configuration cfg= new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory sf = cfg.buildSessionFactory();
Session ss = sf.openSession();
ss.save(p);
ss.beginTransaction().commit();
a=1;
}
catch(Exception e)
{
e.printStackTrace();
}
return a;
}

@RequestMapping("/ChannelList")
public String ChannelList()
{
return "admin/channelList";
}

@RequestMapping(value = "/ShowChannelList" , method = RequestMethod.POST)
@ResponseBody
public List<ChannelListDao>ShowChannelList()
{
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory sf = cfg.buildSessionFactory();
Session ss = sf.openSession();
Criteria cr = ss.createCriteria(ChannelListDao.class);
List<ChannelListDao>p=cr.list();
if(p.isEmpty()!=true)
return p;

return null;
}

@RequestMapping(value="/updateChannelInfo", method=RequestMethod.POST)
@ResponseBody
public byte updateChannelInfo(@RequestBody ChannelListDao rec, HttpSession hs)
{
byte flag = 0;
try
{
Configuration cfg= new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory sf = cfg.buildSessionFactory();
Session ss = sf.openSession();
ss.update(rec);
ss.beginTransaction().commit();
flag = 1;
}
catch(Exception e)
{
e.printStackTrace();
}
return flag;
}

@RequestMapping(value="/deleteChannelInfo", method=RequestMethod.POST)
@ResponseBody
public int del1(@RequestBody ChannelListDao rec)
{
int flag=0;
Configuration cfg= new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory sf = cfg.buildSessionFactory();
Session ss = sf.openSession();
Criteria criteria = ss.createCriteria(signup.class);
List<signup>info =criteria.list();
for(signup w : info) {
String updateChannel="";
if(w.getMychannel().contains(rec.getId()+""));
{
String m[] = w.getMychannel().split(",");
for(String v: m) {
if(v.equals(rec.getId()+"")){
continue;
}
else {
updateChannel = updateChannel + v +",";
}
}
w.setMychannel(updateChannel);
ss.update(w);
flag=1;
}
}
ss.delete(rec);
ss.beginTransaction().commit();
return flag;
}

}
105 changes: 105 additions & 0 deletions Samarth_1710991710_6G-02/newshunt/admin/controller/AdminHome.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package com.newshunt.admin.controller;

import java.util.HashSet;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.newshunt.daomodel.AdminMenuDao;
import com.newshunt.daomodel.ChannelListDao;
import com.newshunt.daomodel.signup;

@Controller
public class AdminHome
{
@RequestMapping("/AdminHome")
public String adminhome()
{
return "admin/adminHome";
}

@RequestMapping(value = "/AdminMenuList" , method = RequestMethod.POST)
@ResponseBody
public List<AdminMenuDao>adminMenuList()
{
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory sf = cfg.buildSessionFactory();
Session ss = sf.openSession();
Criteria cr = ss.createCriteria(AdminMenuDao.class);
List<AdminMenuDao>p=cr.list();
if(p.isEmpty()!=true)
return p;

return null;
}

@RequestMapping(value = "/userListCount" , method = RequestMethod.POST)
@ResponseBody
public int userListCount()
{
int count=0;
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory sf = cfg.buildSessionFactory();
Session ss = sf.openSession();
Criteria cr = ss.createCriteria(signup.class);
List<signup>p=cr.list();
for(signup x:p)
{
count++;
}
return count;
}

@RequestMapping(value = "/ChannelListCount" , method = RequestMethod.POST)
@ResponseBody
public int ChannelListCount()
{
int count=0;
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory sf = cfg.buildSessionFactory();
Session ss = sf.openSession();
Criteria cr = ss.createCriteria(ChannelListDao.class);
List<ChannelListDao>p=cr.list();
for(ChannelListDao x:p)
{
count++;
}

return count;
}

@RequestMapping(value="/SuscribedListCount", method=RequestMethod.POST)
@ResponseBody
public int SuscribedListCount()
{
int flag=0;
HashSet<String> hs=new HashSet();
Configuration cfg= new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory sf = cfg.buildSessionFactory();
Session ss = sf.openSession();
Criteria criteria = ss.createCriteria(signup.class);
List<signup>info =criteria.list();
for(signup w : info)
{
String m[] = w.getMychannel().split(",");
for(String v: m)
{
hs.add(v);
}
}
flag=hs.size();
return flag;
}
}
Loading