Subversion Repositories bacoAlunos

Compare Revisions

Ignore whitespace Rev 1775 → Rev 1776

/branches/v3/impl/src/java/pt/estgp/estgweb/services/courses/CoursesService.java
1,7 → 1,7
package pt.estgp.estgweb.services.courses;
 
import com.owlike.genson.Genson;
import com.owlike.genson.TransformationException;
 
import com.owlike.genson.reflect.VisibilityFilter;
import jomm.dao.impl.AbstractDao;
import jomm.utils.BytesUtils;
171,7 → 171,7
String name,
int size,
String contentType,
UserSession userSession) throws ServiceException, JAXBException, TransformationException, IOException {
UserSession userSession) throws ServiceException, JAXBException, IOException {
Course c;
if(courseView.getId() > 0)
{
202,7 → 202,7
return cv;
}
 
private String uploadStudiesPlan(InputStream stream, String name, int size, String contentType, UserSession userSession, Course c,boolean forceUrlFichas, String systemUrl) throws JAXBException, TransformationException {
private String uploadStudiesPlan(InputStream stream, String name, int size, String contentType, UserSession userSession, Course c,boolean forceUrlFichas, String systemUrl) throws JAXBException {
String htmlTrasformationResult = null;
//APENAS NO CASO DO AMDIN FAZER UPLOAD DE UM XML
if(stream != null && size > 0)
227,7 → 227,7
 
 
 
private void generateCourseJson(Course cAux) throws IOException, TransformationException {
private void generateCourseJson(Course cAux) throws IOException {
CourseImpl c = (CourseImpl) DaoFactory.getCourseDaoImpl().narrow(cAux);
 
if(c.getValidationRole() != null && c.getValidationRole().trim().length() > 0)
293,7 → 293,7
* @return
* @throws JAXBException if XML is not weel formed
*/
private void generateXmlJaxbStudiesPlanVersionFromRepositoryOldPlanStream(UserSession userSession, Course c, boolean forceFichaCurricularUrlSet, String systemUrlForUnitPrograms) throws JAXBException, TransformationException
private void generateXmlJaxbStudiesPlanVersionFromRepositoryOldPlanStream(UserSession userSession, Course c, boolean forceFichaCurricularUrlSet, String systemUrlForUnitPrograms) throws JAXBException
{
CourseStudiesPlan courseStudiesPlan;
if(c.getStudiesPlan() == null || c.getStudiesPlan().trim().length() == 0)
364,11 → 364,6
logger.error(e,e);
System.out.print("check XML for possible errors for repositoryStream:" + c.getStudiesPlan() + " file version: " + lastVersion);
throw e;
} catch (TransformationException e) {
logger.error(e, e);
throw e;
} catch (IOException e) {
e.printStackTrace();
}
try
{
443,8 → 438,8
private static Genson getGensonCourse(){
Genson genson = new Genson.Builder()
.exclude(Object.class)
.setUseFields(false)
.setUseGettersAndSetters(true)
.useFields(false)
.useMethods(true)
.setMethodFilter(VisibilityFilter.PACKAGE_PUBLIC)
.exclude("admin")
.exclude("autoBlock")
633,10 → 628,9
* @return
* @throws JSONException
* @throws IOException
* @throws TransformationException
* @throws JAXBException
*/
public JSONObject getCourseDetailForJsonApi(String code) throws JSONException, IOException, TransformationException, JAXBException {
public JSONObject getCourseDetailForJsonApi(String code) throws JSONException, IOException, JAXBException {
 
Course course = DaoFactory.getCourseDaoImpl().findCourseByCode(code);
 
718,9 → 712,6
} catch (JAXBException e) {
logger.error(e,e);
return "<error>" + e.toString() + ". see log for details</error>";
} catch (TransformationException e) {
logger.error(e, e);
return "<error>" + e.toString() + ". see log for details</error>";
}
}
741,11 → 732,10
* @return
* @throws IOException
* @throws JSONException
* @throws TransformationException
* @throws JAXBException
*/
 
public String sincronizeCoursesStudiesPlans(String systemUrl,boolean setActive,UserSession sess) throws IOException, JSONException, TransformationException, JAXBException {
public String sincronizeCoursesStudiesPlans(String systemUrl,boolean setActive,UserSession sess) throws IOException, JSONException, JAXBException {
 
StringBuilder log = new StringBuilder();
URL url = new URL(systemUrl + "/wsjson/api?service=listCourses");
791,7 → 781,7
 
}
 
private void updateStudiesPlanFromRemoteSystem(String systemUrl, boolean setActive, StringBuilder log, JSONObject course, String code, Course c) throws IOException, JSONException, TransformationException, JAXBException {
private void updateStudiesPlanFromRemoteSystem(String systemUrl, boolean setActive, StringBuilder log, JSONObject course, String code, Course c) throws IOException, JSONException, JAXBException {
String msg;
InputStream stream = new URL(systemUrl + "/wsjson/api?service=getStudiesPlanXml&code=" + code + "&renew=true").openStream();
String studiesPlan = StreamsUtils.readString(stream);
1057,12 → 1047,6
} catch (JAXBException e) {
logger.error(e,e);
return null;
} catch (TransformationException e) {
logger.error(e,e);
return null;
} catch (IOException e) {
logger.error(e,e);
return null;
}
}
 
1108,8 → 1092,6
generateCourseJson(course);
} catch (IOException e) {
logger.error(e,e);
} catch (TransformationException e) {
logger.error(e, e);
}
}
}
1222,7 → 1204,7
return t;
}
 
public CourseDepartmentImpl updateDepartmentFromJson(String json,UserSession session) throws IOException, TransformationException
public CourseDepartmentImpl updateDepartmentFromJson(String json,UserSession session) throws IOException
{
CourseDepartmentImpl courseDepartment = CourseDepartmentImpl.loadFromJson(json);
CourseDepartmentImpl courseDepartmentPersistent = (CourseDepartmentImpl) DaoFactory.getCourseDepartmentDaoImpl().load(courseDepartment.getSigla());
1246,7 → 1228,7
 
}
 
public CourseDepartmentImpl removeDepartmentFromJson(String json,UserSession session) throws IOException, TransformationException
public CourseDepartmentImpl removeDepartmentFromJson(String json,UserSession session) throws IOException
{
CourseDepartmentImpl courseDepartment = CourseDepartmentImpl.loadFromJson(json);
CourseDepartmentImpl courseDepartmentPersistent = (CourseDepartmentImpl) DaoFactory.getCourseDepartmentDaoImpl().load(courseDepartment.getSigla());
1255,7 → 1237,7
 
}
 
public CourseDepartmentImpl newDepartmentFromJson(UserSession session) throws IOException, TransformationException
public CourseDepartmentImpl newDepartmentFromJson(UserSession session) throws IOException
{
CourseDepartmentImpl courseDepartmentPersistent = DomainObjectFactory.createCourseDepartmentImpl();
 
1267,7 → 1249,7
}
 
 
public CourseSchoolImpl updateSchoolFromJson(String json,UserSession session) throws IOException, TransformationException
public CourseSchoolImpl updateSchoolFromJson(String json,UserSession session) throws IOException
{
CourseSchoolImpl courseSchool = CourseSchoolImpl.loadFromJson(json);
CourseSchoolImpl courseSchoolPersistent = (CourseSchoolImpl) DaoFactory.getCourseSchoolDaoImpl().load(courseSchool.getId());
1300,7 → 1282,7
 
}
 
public CourseSchoolImpl newSchoolFromJson(UserSession session) throws IOException, TransformationException
public CourseSchoolImpl newSchoolFromJson(UserSession session) throws IOException
{
CourseSchoolImpl courseSchoolPersistent = DomainObjectFactory.createCourseSchoolImpl();
 
1310,7 → 1292,7
 
}
 
public CourseSchoolImpl removeSchoolFromJson(String json,UserSession session) throws IOException, TransformationException
public CourseSchoolImpl removeSchoolFromJson(String json,UserSession session) throws IOException
{
CourseSchoolImpl courseSchool = CourseSchoolImpl.loadFromJson(json);
CourseSchoolImpl courseSchoolPersistent = (CourseSchoolImpl) DaoFactory.getCourseSchoolDaoImpl().load(courseSchool.getId());
/branches/v3/impl/src/java/pt/estgp/estgweb/services/courses/xsd/CursoImpl.java
1,7 → 1,7
package pt.estgp.estgweb.services.courses.xsd;
 
import com.owlike.genson.Genson;
import com.owlike.genson.TransformationException;
import com.owlike.genson.GensonBuilder;
import org.json.JSONException;
import org.json.JSONObject;
import pt.estgp.estgweb.utils.DynamicArrayList;
28,7 → 28,7
static Genson genson;
 
static {
Genson.Builder gensonBuilder = new Genson.Builder()
GensonBuilder gensonBuilder = new Genson.Builder()
.exclude(Object.class)
.include(Curso.class)
.include(UnidadeType.class)
44,21 → 44,21
 
}
 
public static String toJson(Curso c) throws IOException, TransformationException
public static String toJson(Curso c) throws IOException
{
return genson.serialize(c);
}
 
public String toJson() throws IOException, TransformationException
public String toJson() throws IOException
{
return genson.serialize(this);
}
 
public static CursoImpl loadFromJson(String json) throws IOException, TransformationException {
public static CursoImpl loadFromJson(String json) throws IOException {
return genson.deserialize(json, CursoImpl.class);
}
 
public JSONObject toJsonObject() throws IOException, TransformationException, JSONException {
public JSONObject toJsonObject() throws IOException, JSONException {
return new JSONObject(toJson());
}
 
/branches/v3/impl/src/java/pt/estgp/estgweb/services/questionarios/pedagogico/AnswersAlunosProcessor.java
1,6 → 1,5
package pt.estgp.estgweb.services.questionarios.pedagogico;
 
import com.owlike.genson.TransformationException;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.*;
267,7 → 266,7
return logMessages;
}
 
public static boolean canUse(QuestionarioPedagogicoTipologiaRequisitada tipologiaRequisitada,CourseUnitImpl cuImpl) throws IOException, TransformationException
public static boolean canUse(QuestionarioPedagogicoTipologiaRequisitada tipologiaRequisitada,CourseUnitImpl cuImpl) throws IOException
{
ArrayList<CourseUnitImpl.Tipologia> tipologiasMerged = cuImpl.getTipologiasClass().obtainMergeTipologias();
for(CourseUnitImpl.Tipologia tipologia: tipologiasMerged)
/branches/v3/impl/src/java/pt/estgp/estgweb/services/questionarios/pedagogico/UpdateCoursesAndUnitsJobService.java
1,6 → 1,5
package pt.estgp.estgweb.services.questionarios.pedagogico;
 
import com.owlike.genson.TransformationException;
import org.apache.log4j.Logger;
import org.json.JSONArray;
import org.json.JSONException;
452,9 → 451,8
* @param q
* @param c
* @throws IOException
* @throws TransformationException
*/
private void createCursoAfeto(QuestionarioImpl q, Course c, DefaultLogMessages logMessages) throws IOException, TransformationException
private void createCursoAfeto(QuestionarioImpl q, Course c, DefaultLogMessages logMessages) throws IOException
{
String msg;
QuestionarioPedagogicoCursoAfetoImpl cursoAfeto = null;
539,9 → 537,8
* @param cursoAfeto
* @param cur
* @throws IOException
* @throws TransformationException
*/
private void createUnidadeAfeta(QuestionarioPedagogicoCursoAfetoImpl cursoAfeto, CourseUnitDaoImpl.CourseUnitResult cur, CourseUnit cu, DefaultLogMessages logMessages) throws IOException, TransformationException {
private void createUnidadeAfeta(QuestionarioPedagogicoCursoAfetoImpl cursoAfeto, CourseUnitDaoImpl.CourseUnitResult cur, CourseUnit cu, DefaultLogMessages logMessages) throws IOException {
 
String msg;
QuestionarioPedagogicoUnidadeCurricularAfetaImpl unidadeAfeta = null;
787,10 → 784,9
* @param unidadeAfeta
* @return
* @throws IOException
* @throws TransformationException
*/
/*
private ArrayList<CourseUnitImpl.Tipologia> copiarTipologias(CourseUnit cu, QuestionarioPedagogicoUnidadeCurricularAfetaImpl unidadeAfeta) throws IOException, TransformationException {
private ArrayList<CourseUnitImpl.Tipologia> copiarTipologias(CourseUnit cu, QuestionarioPedagogicoUnidadeCurricularAfetaImpl unidadeAfeta) throws IOException {
try
{
CourseUnitImpl.Tipologias tipologias = ((CourseUnitImpl)cu).getTipologiasClass();
825,10 → 821,9
* @param session
* @param questionarioCleared
* @throws IOException
* @throws TransformationException
* @throws NotAuthorizedException
*/
public void updateTipologiasPedagogico(long questionarioId, List<QuestionarioPedagogicoCursoAfeto> cursosAfetos, UserSession session,QuestionarioImpl questionarioCleared) throws IOException, TransformationException, NotAuthorizedException {
public void updateTipologiasPedagogico(long questionarioId, List<QuestionarioPedagogicoCursoAfeto> cursosAfetos, UserSession session,QuestionarioImpl questionarioCleared) throws IOException, NotAuthorizedException {
 
if(!questionarioCleared.isClear((UserSessionImpl) session,QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_CHANGE_TIPOLOGIES.name()))
{
/branches/v3/impl/src/java/pt/estgp/estgweb/services/pageContent/PageContentTest.java
1,6 → 1,5
package pt.estgp.estgweb.services.pageContent;
 
import com.owlike.genson.TransformationException;
import junit.framework.Assert;
import junit.framework.TestCase;
import org.json.JSONArray;
201,10 → 200,9
/**
*
* @throws JSONException
* @throws TransformationException
* @throws IOException
*/
public void testAcl() throws JSONException, TransformationException, IOException {
public void testAcl() throws JSONException, IOException {
 
UserSessionImpl sessAnonymous = new UserSessionImpl();
sessAnonymous.setCookie("1");
412,7 → 410,7
 
}
 
public void testJson() throws JSONException, TransformationException, IOException {
public void testJson() throws JSONException, IOException {
PageContentImpl.Acl a = new PageContentImpl.Acl();
a.setAccess(PageContentImpl.Acl.Access.PERMIT.name());
a.setOperation(PageContentImpl.Acl.Operation.ADD_FILES.name());
/branches/v3/impl/src/java/pt/estgp/estgweb/services/configuration/ConfigurationSeparatorsService.java
1,6 → 1,5
package pt.estgp.estgweb.services.configuration;
 
import com.owlike.genson.TransformationException;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
16,7 → 15,7
 
 
 
public ConfigurationSeparatorImpl newConfigurationSeparator(UserSession session) throws IOException, TransformationException
public ConfigurationSeparatorImpl newConfigurationSeparator(UserSession session) throws IOException
{
ConfigurationSeparatorImpl separator = DomainObjectFactory.createConfigurationSeparatorImpl();
 
25,7 → 24,7
return separator;
 
}
public ConfigurationSeparatorImpl removeConfigurationSeparator(String json,UserSession session) throws IOException, TransformationException
public ConfigurationSeparatorImpl removeConfigurationSeparator(String json,UserSession session) throws IOException
{
ConfigurationSeparatorImpl config = ConfigurationSeparatorImpl.loadFromJson(json);
ConfigurationSeparatorImpl configPersistent = (ConfigurationSeparatorImpl) DaoFactory.getConfigurationSeparatorDaoImpl().load(config.getId());
34,7 → 33,7
 
 
}
public ConfigurationSeparatorImpl updateConfigurationSeparator(String json, UserSession session) throws IOException, TransformationException
public ConfigurationSeparatorImpl updateConfigurationSeparator(String json, UserSession session) throws IOException
{
 
ConfigurationSeparatorImpl config = ConfigurationSeparatorImpl.loadFromJson(json);
/branches/v3/impl/src/java/pt/estgp/estgweb/services/data/repositorydocuments/RepositoryDocumentService.java
1,6 → 1,5
package pt.estgp.estgweb.services.data.repositorydocuments;
 
import com.owlike.genson.TransformationException;
import jomm.dao.impl.AbstractDao;
import org.json.JSONArray;
import org.json.JSONException;
42,11 → 41,10
* @param documentIds documentIds: [LONG,LONG, ...]
* @param userSession
* @throws IOException
* @throws TransformationException
* @throws JSONException
* @throws AccessDeniedException
*/
public void changeDocumentCollection(Long newCollectionId , JSONArray documentIds, UserSession userSession) throws IOException, TransformationException, JSONException, AccessDeniedException
public void changeDocumentCollection(Long newCollectionId , JSONArray documentIds, UserSession userSession) throws IOException, JSONException, AccessDeniedException
{
RepositoryDocumentCollection newCollection = DaoFactory.getRepositoryDocumentCollectionDaoImpl().get(newCollectionId);
for(int i = 0; i < documentIds.length();i++)
68,11 → 66,10
* @param userSession
* @return
* @throws IOException
* @throws TransformationException
* @throws JSONException
* @throws AccessDeniedException
*/
public JSONArray openRepositoryCollection(Long collectionId, UserSession userSession) throws IOException, TransformationException, JSONException, AccessDeniedException {
public JSONArray openRepositoryCollection(Long collectionId, UserSession userSession) throws IOException, JSONException, AccessDeniedException {
 
boolean onlyVisible = !(userSession.getUser() != null &&
(userSession.getUser().hasRole(REPOSITORY_DOCS_ROLE)
92,7 → 89,7
}
 
 
public JSONArray openRepositoryCollectionDocuments(Long collectionId, UserSession userSession) throws IOException, TransformationException, JSONException, AccessDeniedException {
public JSONArray openRepositoryCollectionDocuments(Long collectionId, UserSession userSession) throws IOException, JSONException, AccessDeniedException {
 
boolean onlyVisible = !(userSession.getUser() != null &&
(userSession.getUser().hasRole(REPOSITORY_DOCS_ROLE)
103,7 → 100,7
return RepositoryDocumentImpl.toJsonArray(docs);
}
 
public JSONObject addRepositoryCollection(Long collectionParentId, UserSession userSession) throws IOException, TransformationException, JSONException, AccessDeniedException {
public JSONObject addRepositoryCollection(Long collectionParentId, UserSession userSession) throws IOException, JSONException, AccessDeniedException {
RepositoryDocumentCollectionImpl collectionParent = null;
if(collectionParentId != null)
{
120,7 → 117,7
return collectionChild.toJsonObject();
}
 
public JSONObject changeParentRepositoryDocumentCollection(Long collectionId,Long newParentId, UserSession userSession) throws IOException, TransformationException, JSONException, AccessDeniedException {
public JSONObject changeParentRepositoryDocumentCollection(Long collectionId,Long newParentId, UserSession userSession) throws IOException, JSONException, AccessDeniedException {
RepositoryDocumentCollectionImpl collectionChild = (RepositoryDocumentCollectionImpl) DaoFactory.getRepositoryDocumentCollectionDaoImpl().get(collectionId);
RepositoryDocumentCollectionImpl collectionNewParent = newParentId == null ? null : (RepositoryDocumentCollectionImpl) DaoFactory.getRepositoryDocumentCollectionDaoImpl().get(newParentId);
 
140,7 → 137,7
 
 
 
public JSONObject updateRepositoryCollection(String collection, UserSession userSession) throws IOException, TransformationException, JSONException, AccessDeniedException {
public JSONObject updateRepositoryCollection(String collection, UserSession userSession) throws IOException, JSONException, AccessDeniedException {
 
RepositoryDocumentCollectionImpl collectionChild = RepositoryDocumentCollectionImpl.loadFromJson(collection);
 
155,7 → 152,7
return persistent.toJsonObject();
}
 
public void deleteCollection(long collectionId, UserSession userSession) throws IOException, TransformationException, JSONException, AccessDeniedException, NotAuthorizedException
public void deleteCollection(long collectionId, UserSession userSession) throws IOException, JSONException, AccessDeniedException, NotAuthorizedException
{
RepositoryDocumentCollection collection = DaoFactory.getRepositoryDocumentCollectionDaoImpl().get(collectionId);
if(collection.getChilds().size() > 0)
171,7 → 168,7
}
 
 
public JSONArray checkRepositoryDocumentExistence(String docJson, UserSession userSession) throws IOException, TransformationException, JSONException, AccessDeniedException, NotAuthorizedException
public JSONArray checkRepositoryDocumentExistence(String docJson, UserSession userSession) throws IOException, JSONException, AccessDeniedException, NotAuthorizedException
{
JSONArray found = new JSONArray();
RepositoryDocumentImpl view = RepositoryDocumentImpl.loadFromJson(docJson);
186,7 → 183,7
return found;
}
 
public JSONObject saveRepositoryDocument(String docJson, FilesUploadResult uploadedFiles, UserSession userSession) throws IOException, TransformationException, JSONException, AccessDeniedException, NotAuthorizedException, ServiceException {
public JSONObject saveRepositoryDocument(String docJson, FilesUploadResult uploadedFiles, UserSession userSession) throws IOException, JSONException, AccessDeniedException, NotAuthorizedException, ServiceException {
 
RepositoryDocumentImpl view = RepositoryDocumentImpl.loadFromJson(docJson);
 
368,7 → 365,7
}
 
 
public JSONArray loadCollectionsOrderedAsTree() throws JSONException, TransformationException, IOException {
public JSONArray loadCollectionsOrderedAsTree() throws JSONException, IOException {
ArrayList<RepositoryDocumentCollectionImpl> collections = new ArrayList<RepositoryDocumentCollectionImpl>();
List<RepositoryDocumentCollection> collectionsRoots = DaoFactory.getRepositoryDocumentCollectionDaoImpl().findRoots();
for(RepositoryDocumentCollection col : collectionsRoots)
395,13 → 392,13
 
 
 
public JSONObject addRepositoryInterface(UserSession userSession) throws IOException, TransformationException, JSONException, AccessDeniedException {
public JSONObject addRepositoryInterface(UserSession userSession) throws IOException, JSONException, AccessDeniedException {
RepositoryDocumentInterfaceImpl repositoryDocumentInterface = DomainObjectFactory.createRepositoryDocumentInterfaceImpl();
repositoryDocumentInterface.setVisible(false);
DaoFactory.getRepositoryDocumentInterfaceDaoImpl().save(repositoryDocumentInterface);
return repositoryDocumentInterface.toJsonObject();
}
public JSONObject updateRepositoryInterface(String jsonObject,UserSession userSession) throws IOException, TransformationException, JSONException, AccessDeniedException {
public JSONObject updateRepositoryInterface(String jsonObject,UserSession userSession) throws IOException, JSONException, AccessDeniedException {
 
RepositoryDocumentInterfaceImpl repositoryDocumentInterface =
RepositoryDocumentInterfaceImpl.loadFromJson(jsonObject);
414,13 → 411,13
return persistent.toJsonObject();
}
 
public void removeRepositoryInterface(Long id,UserSession userSession) throws IOException, TransformationException, JSONException, AccessDeniedException {
public void removeRepositoryInterface(Long id,UserSession userSession) throws IOException, JSONException, AccessDeniedException {
 
RepositoryDocumentInterfaceImpl persistent = (RepositoryDocumentInterfaceImpl) DaoFactory.getRepositoryDocumentInterfaceDaoImpl().get(id);
DaoFactory.getRepositoryDocumentInterfaceDaoImpl().delete(persistent);
}
 
public void saveRepositoryInterfaceData(Long id,String dataJson, UserSession userSession) throws IOException, TransformationException, JSONException, AccessDeniedException, ServiceException {
public void saveRepositoryInterfaceData(Long id,String dataJson, UserSession userSession) throws IOException, JSONException, AccessDeniedException, ServiceException {
 
RepositoryInterface repositoryInterface = RepositoryInterface.loadFromJson(dataJson);
for(InterfaceRow row: repositoryInterface.getRows())
460,7 → 457,7
}
}
 
public static void main(String[] args) throws TransformationException, JSONException, IOException
public static void main(String[] args) throws JSONException, IOException
{
AbstractDao.getCurrentSession().beginTransaction();
JSONArray array = new RepositoryDocumentService().loadCollectionsOrderedAsTree();
/branches/v3/impl/src/java/pt/estgp/estgweb/services/data/repositorydocuments/interfaces/RepositoryInterface.java
1,7 → 1,7
package pt.estgp.estgweb.services.data.repositorydocuments.interfaces;
 
import com.owlike.genson.Genson;
import com.owlike.genson.TransformationException;
import com.owlike.genson.GensonBuilder;
import org.json.JSONException;
import org.json.JSONObject;
import pt.estgp.estgweb.services.bpmnprocess.types.BacoDataAbstractType;
76,7 → 76,7
static Genson genson;
 
static {
Genson.Builder gensonBuilder = new Genson.Builder()
GensonBuilder gensonBuilder = new Genson.Builder()
.exclude(Object.class)
.include(RepositoryInterface.class)
.include(InterfaceRow.class)
91,20 → 91,20
genson = gensonBuilder.create();
 
}
public String toJson() throws IOException, TransformationException
public String toJson() throws IOException
{
return genson.serialize(this);
}
 
public static RepositoryInterface loadFromJson(String json) throws IOException, TransformationException {
public static RepositoryInterface loadFromJson(String json) throws IOException {
return genson.deserialize(json, RepositoryInterface.class);
}
 
public JSONObject toJsonObject() throws IOException, TransformationException, JSONException {
public JSONObject toJsonObject() throws IOException, JSONException {
return new JSONObject(toJson());
}
 
public static void main(String[] args) throws IOException, TransformationException {
public static void main(String[] args) throws IOException {
RepositoryInterface repositoryInterface = new RepositoryInterface();
repositoryInterface.setTitle("Teste");
repositoryInterface.setDescription("RepoDesc");
162,9 → 162,6
} catch (IOException e) {
e.printStackTrace();
return "";
} catch (TransformationException e) {
e.printStackTrace();
return "";
}
}
 
/branches/v3/impl/src/java/pt/estgp/estgweb/services/data/repositorydocuments/EnhancedRepositoryInterface.java
1,6 → 1,5
package pt.estgp.estgweb.services.data.repositorydocuments;
 
import com.owlike.genson.TransformationException;
import pt.estgp.estgweb.services.bpmnprocess.types.AbstractStringEnhancedType;
import pt.estgp.estgweb.services.bpmnprocess.types.BacoDataAbstractType;
import pt.estgp.estgweb.services.data.repositorydocuments.interfaces.RepositoryInterface;
22,9 → 21,6
} catch (IOException e) {
e.printStackTrace();
return null;
} catch (TransformationException e) {
e.printStackTrace();
return null;
}
}
 
43,9 → 39,7
} catch (IOException e) {
e.printStackTrace();
return null;
} catch (TransformationException e) {
e.printStackTrace();
return null;
}
 
}
}
/branches/v3/impl/src/java/pt/estgp/estgweb/services/bpmnprocess/types/test/TestEnhancedType.java
2,19 → 2,9
 
import jomm.dao.impl.AbstractDao;
import junit.framework.TestCase;
import org.hibernate.Query;
import pt.estgp.estgweb.domain.BpmnActorPoolInstance;
import pt.estgp.estgweb.domain.BpmnActorPoolInstanceImpl;
import pt.estgp.estgweb.domain.BpmnFlowComponentEventEndMessagesImpl;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.services.bpmnprocess.types.DomainRoleProxy;
import pt.estgp.estgweb.services.bpmnprocess.types.DomainRolesProxy;
import pt.estgp.estgweb.services.bpmnprocess.types.TargetActorType;
import pt.estgp.estgweb.services.bpmnprocess.types.UserProxy;
 
import java.util.ArrayList;
import java.util.List;
 
/**
* Created by jorgemachado on 09/02/17.
*/
55,6 → 45,7
 
public void testUserProxy()
{
/*
AbstractDao.getCurrentSession().beginTransaction();
 
UserProxy userProxy = new UserProxy();
106,6 → 97,7
actorPoolInstance1.setUserProxy(userProxy);
AbstractDao.getCurrentSession().delete(actorPoolInstance1);
AbstractDao.getCurrentSession().getTransaction().commit();
*/
 
}
 
193,6 → 185,7
 
public void testDomainRolesProxySerializationActorPoolInstance()
{
/*
AbstractDao.getCurrentSession().beginTransaction();
 
BpmnActorPoolInstanceImpl actorPool = new BpmnActorPoolInstanceImpl();
261,6 → 254,7
assertTrue(((BpmnActorPoolInstanceImpl)actorPoolLoaded2).hasRole("test"));
AbstractDao.getCurrentSession().delete(actorPoolLoaded2);
AbstractDao.getCurrentSession().getTransaction().commit();
*/
 
 
}
/branches/v3/impl/src/java/pt/estgp/estgweb/services/entity/EntityServiceJson.java
1,7 → 1,6
package pt.estgp.estgweb.services.entity;
 
import com.owlike.genson.Genson;
import com.owlike.genson.TransformationException;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.utl.ist.berserk.logic.serviceManager.IService;
40,23 → 39,23
 
.create();
 
public String courseUnit(CourseUnit cu) throws IOException, TransformationException {
public String courseUnit(CourseUnit cu) throws IOException {
return courseUnitGenson.serialize(cu);
}
public String courseUnit(Serializable s) throws IOException, TransformationException {
public String courseUnit(Serializable s) throws IOException {
CourseUnit cu = DaoFactory.getCourseUnitDaoImpl().get(s);
return courseUnitGenson.serialize(cu);
}
 
public String user(Serializable s) throws IOException, TransformationException {
public String user(Serializable s) throws IOException {
User u = DaoFactory.getUserDaoImpl().get(s);
return userGenson.serialize(u);
}
public String user(User u) throws IOException, TransformationException {
public String user(User u) throws IOException {
return userGenson.serialize(u);
}
 
public String user(ArrayList<User> users) throws IOException, TransformationException {
public String user(ArrayList<User> users) throws IOException {
return userGenson.serialize(users);
}
}
/branches/v3/impl/src/java/pt/estgp/estgweb/domain/ConfigurationSeparatorImpl.java
1,7 → 1,6
package pt.estgp.estgweb.domain;
 
import com.owlike.genson.Genson;
import com.owlike.genson.TransformationException;
import org.json.JSONException;
import org.json.JSONObject;
 
79,21 → 78,21
.include("slug", PageSectionImpl.class)
.create();
 
public String getJson() throws IOException, TransformationException
public String getJson() throws IOException
{
return confGenson.serialize(this);
}
 
public static String getJson(ArrayList<ConfigurationSeparator> seps) throws IOException, TransformationException
public static String getJson(ArrayList<ConfigurationSeparator> seps) throws IOException
{
return confGenson.serialize(seps);
}
 
public static ConfigurationSeparatorImpl loadFromJson(String json) throws IOException, TransformationException {
public static ConfigurationSeparatorImpl loadFromJson(String json) throws IOException {
return confGenson.deserialize(json, ConfigurationSeparatorImpl.class);
}
 
public JSONObject getJsonObject() throws IOException, TransformationException, JSONException {
public JSONObject getJsonObject() throws IOException, JSONException {
return new JSONObject(getJson());
}
}
/branches/v3/impl/src/java/pt/estgp/estgweb/domain/BpmnActorPoolInstanceImpl.java
1,6 → 1,6
package pt.estgp.estgweb.domain;
 
import pt.estgp.estgweb.services.bpmnprocess.types.DomainRoleProxy;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
 
/**
* Created by jorgemachado on 09/02/17.
9,18 → 9,20
{
public boolean hasRole(String r)
{
if (r == null || getDomainRolesProxy() == null || getDomainRolesProxy().getRoles() == null || getDomainRolesProxy().getRoles().size() == 0)
/*if (r == null )
return false;
for (DomainRoleProxy role : getDomainRolesProxy().getRoles())
{
if (role.getRole().equals(r))
return true;
}
return false;
return false;*/
throw new NotImplementedException();
}
 
public void replaceRole(String oldRole,String newRole)
{
/*
if (oldRole == null || newRole == null || getDomainRolesProxy() == null || getDomainRolesProxy().getRoles() == null || getDomainRolesProxy().getRoles().size() == 0)
return;
for (DomainRoleProxy role : getDomainRolesProxy().getRoles())
30,6 → 32,6
role.setRole(newRole);
break;
}
}
}*/
}
}
/branches/v3/impl/src/java/pt/estgp/estgweb/domain/BpmnFlowComponentImpl.java
1,7 → 1,6
package pt.estgp.estgweb.domain;
 
import com.owlike.genson.Genson;
import com.owlike.genson.TransformationException;
import org.json.JSONException;
import org.json.JSONObject;
 
17,12 → 16,12
//exclude connector
.create();
 
public JSONObject getJsonObject() throws IOException, TransformationException, JSONException
public JSONObject getJsonObject() throws IOException, JSONException
{
return new JSONObject(genson.serialize(this));
}
 
public String getJson() throws IOException, TransformationException
public String getJson() throws IOException
{
return genson.serialize(this);
}
/branches/v3/impl/src/java/pt/estgp/estgweb/domain/RepositoryDocumentCollectionImpl.java
1,7 → 1,7
package pt.estgp.estgweb.domain;
 
import com.owlike.genson.Genson;
import com.owlike.genson.TransformationException;
import com.owlike.genson.GensonBuilder;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
28,7 → 28,7
static Genson gensonSimpleFields;
 
static {
Genson.Builder gensonBuilder = new Genson.Builder()
GensonBuilder gensonBuilder = new Genson.Builder()
.exclude(Object.class)
.include(RepositoryDocumentCollectionImpl.class)
.include("name", RepositoryDocumentCollection.class)
46,7 → 46,7
 
genson = gensonBuilder.create();
 
Genson.Builder gensonBuilderSimpleFields = new Genson.Builder()
GensonBuilder gensonBuilderSimpleFields = new Genson.Builder()
.exclude(Object.class)
.include(RepositoryDocumentCollectionImpl.class)
.include("name", RepositoryDocumentCollection.class)
61,33 → 61,33
gensonSimpleFields = gensonBuilderSimpleFields.create();
 
}
public String toJson() throws IOException, TransformationException
public String toJson() throws IOException
{
return genson.serialize(this);
}
 
public static String toJson(List<RepositoryDocumentCollection> collections) throws IOException, TransformationException
public static String toJson(List<RepositoryDocumentCollection> collections) throws IOException
{
return genson.serialize(collections);
}
public static JSONArray toJsonArray(Set<RepositoryDocumentCollectionImpl> collections) throws IOException, TransformationException, JSONException {
public static JSONArray toJsonArray(Set<RepositoryDocumentCollectionImpl> collections) throws IOException, JSONException {
ArrayList<RepositoryDocumentCollectionImpl> collectionsList = new ArrayList<RepositoryDocumentCollectionImpl>(collections);
return toJsonArray(collectionsList);
}
 
public static JSONArray toJsonArray(List<RepositoryDocumentCollectionImpl> collections) throws IOException, TransformationException, JSONException {
public static JSONArray toJsonArray(List<RepositoryDocumentCollectionImpl> collections) throws IOException, JSONException {
return new JSONArray(genson.serialize(collections));
}
 
public static JSONArray toJsonArraySimpleFields(List<RepositoryDocumentCollectionImpl> collections) throws IOException, TransformationException, JSONException {
public static JSONArray toJsonArraySimpleFields(List<RepositoryDocumentCollectionImpl> collections) throws IOException , JSONException {
return new JSONArray(gensonSimpleFields.serialize(collections));
}
 
public static RepositoryDocumentCollectionImpl loadFromJson(String json) throws IOException, TransformationException {
public static RepositoryDocumentCollectionImpl loadFromJson(String json) throws IOException {
return genson.deserialize(json, RepositoryDocumentCollectionImpl.class);
}
 
public JSONObject toJsonObject() throws IOException, TransformationException, JSONException {
public JSONObject toJsonObject() throws IOException, JSONException {
return new JSONObject(toJson());
}
 
/branches/v3/impl/src/java/pt/estgp/estgweb/domain/BpmnProcessImpl.java
1,7 → 1,7
package pt.estgp.estgweb.domain;
 
import com.owlike.genson.Genson;
import com.owlike.genson.TransformationException;
 
import org.json.JSONException;
import org.json.JSONObject;
 
14,7 → 14,7
public class BpmnProcessImpl extends BpmnProcess
{
static Genson genson = new Genson.Builder()
.useMetadata(true)
.useClassMetadata(true)
.exclude(Object.class)
.include(ArrayList.class)
.include(BpmnProcess.class)
28,22 → 28,22
//.include(BpmnProcessStep.class)
.create();
 
public JSONObject toJsonObject() throws IOException, TransformationException ,JSONException
public JSONObject toJsonObject() throws IOException ,JSONException
{
return new JSONObject(genson.serialize(this));
}
 
public String toJson() throws IOException,TransformationException
public String toJson() throws IOException
{
return genson.serialize(this);
}
 
public static String toJsonArray(ArrayList<BpmnProcess> processes) throws TransformationException, IOException
public static String toJsonArray(ArrayList<BpmnProcess> processes)
{
return genson.serialize(processes);
}
 
public static BpmnProcessImpl fromJson(String processJson) throws IOException, TransformationException {
public static BpmnProcessImpl fromJson(String processJson) throws IOException {
return genson.deserialize(processJson,BpmnProcessImpl.class);
}
}
/branches/v3/impl/src/java/pt/estgp/estgweb/domain/CourseUnitImpl.java
1,7 → 1,6
package pt.estgp.estgweb.domain;
 
import com.owlike.genson.Genson;
import com.owlike.genson.TransformationException;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.dao.DaoFactory;
510,12 → 509,12
}
 
 
public Tipologias getTipologiasClass() throws IOException, TransformationException
public Tipologias getTipologiasClass() throws IOException
{
return Tipologias.deserialize(getTipologias());
}
 
public void setTipologiasClass(Tipologias tipologias) throws IOException, TransformationException
public void setTipologiasClass(Tipologias tipologias) throws IOException
{
if(tipologias != null)
setTipologias(tipologias.serialize());
1014,28 → 1013,20
return genson;
}
 
public String serialize() throws IOException, TransformationException
public String serialize() throws IOException
{
Genson genson = getGenson();
try {
 
return genson.serialize(this);
} catch (TransformationException e) {
throw e;
} catch (IOException e) {
throw e;
}
 
}
public static Tipologias deserialize(String serial) throws IOException, TransformationException
public static Tipologias deserialize(String serial) throws IOException
{
if(serial == null)
return new Tipologias();
try {
 
return getGenson().deserialize(serial, Tipologias.class);
} catch (TransformationException e) {
throw e;
} catch (IOException e) {
throw e;
}
 
}
 
public static void main(String [] args)
1043,7 → 1034,7
new TestCourseUnit().testTipologias();
}
 
public static String serializeMergedList(ArrayList<Tipologia> tipologias) throws IOException, TransformationException
public static String serializeMergedList(ArrayList<Tipologia> tipologias) throws IOException
{
MergedTipologias mergedTipologias = new MergedTipologias();
if(tipologias != null)
1051,30 → 1042,23
mergedTipologias.setTipologiasWithMarkedAndUsed(tipologias);
}
Genson genson = getGensonMergedTipologiasComplete();
try {
 
return genson.serialize(mergedTipologias);
} catch (TransformationException e) {
throw e;
} catch (IOException e) {
throw e;
}
 
}
public static ArrayList<Tipologia> deserializeMergedTipologias(String serial) throws IOException, TransformationException
public static ArrayList<Tipologia> deserializeMergedTipologias(String serial) throws IOException
{
if(serial == null)
return new ArrayList<Tipologia>();
try {
 
MergedTipologias mergedTipologias = getGensonMergedTipologiasComplete().deserialize(serial, MergedTipologias.class);
if(mergedTipologias.getTipologiasWithMarkedAndUsed() == null)
return new ArrayList<Tipologia>();
return mergedTipologias.getTipologiasWithMarkedAndUsed();
} catch (TransformationException e) {
throw e;
} catch (IOException e) {
throw e;
}
 
 
}
public String obtainMergeTipologiasSerialized() throws IOException, TransformationException
public String obtainMergeTipologiasSerialized() throws IOException
{
return serializeMergedList(obtainMergeTipologias());
}
/branches/v3/impl/src/java/pt/estgp/estgweb/domain/RepositoryDocumentInterfaceImpl.java
1,7 → 1,7
package pt.estgp.estgweb.domain;
 
import com.owlike.genson.Genson;
import com.owlike.genson.TransformationException;
import com.owlike.genson.GensonBuilder;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
22,26 → 22,26
static Genson genson;
 
static {
Genson.Builder gensonBuilder = new Genson.Builder()
GensonBuilder gensonBuilder = new Genson.Builder()
.exclude(Object.class)
.include(String.class);
genson = gensonBuilder.create();
 
}
public String toJson() throws IOException, TransformationException
public String toJson() throws IOException
{
return genson.serialize(this);
}
 
public static RepositoryDocumentInterfaceImpl loadFromJson(String json) throws IOException, TransformationException {
public static RepositoryDocumentInterfaceImpl loadFromJson(String json) throws IOException {
return genson.deserialize(json, RepositoryDocumentInterfaceImpl.class);
}
 
public JSONObject toJsonObject() throws IOException, TransformationException, JSONException {
public JSONObject toJsonObject() throws IOException, JSONException {
return new JSONObject(toJson());
}
 
public static JSONArray toJsonArray(List<RepositoryDocumentInterfaceImpl> collections) throws IOException, TransformationException, JSONException {
public static JSONArray toJsonArray(List<RepositoryDocumentInterfaceImpl> collections) throws IOException, JSONException {
return new JSONArray(genson.serialize(collections));
}
 
/branches/v3/impl/src/java/pt/estgp/estgweb/domain/RepositoryDocumentImpl.java
1,7 → 1,6
package pt.estgp.estgweb.domain;
 
import com.owlike.genson.Genson;
import com.owlike.genson.TransformationException;
import jomm.dao.impl.AbstractDao;
import org.json.JSONArray;
import org.json.JSONException;
108,24 → 107,24
 
 
 
public String toJson() throws IOException, TransformationException
public String toJson() throws IOException
{
return gensonSerialize.serialize(this);
}
 
public static JSONArray toJsonArray(List<RepositoryDocumentImpl> docs) throws IOException, TransformationException, JSONException {
public static JSONArray toJsonArray(List<RepositoryDocumentImpl> docs) throws IOException, JSONException {
return new JSONArray(gensonSerialize.serialize(docs));
}
 
public static RepositoryDocumentImpl loadFromJson(String json) throws IOException, TransformationException {
public static RepositoryDocumentImpl loadFromJson(String json) throws IOException {
return gensonDeserialize.deserialize(json, RepositoryDocumentImpl.class);
}
 
public JSONObject toJsonObject() throws IOException, TransformationException, JSONException {
public JSONObject toJsonObject() throws IOException, JSONException {
return new JSONObject(toJson());
}
 
public static void main(String[] args) throws IOException, TransformationException {
public static void main(String[] args) throws IOException {
AbstractDao.getCurrentSession().beginTransaction();
DocumentPerson p = new DocumentPerson();
p.setFirstNames("jorge");
/branches/v3/impl/src/java/pt/estgp/estgweb/domain/BpmnActorPoolImpl.java
1,6 → 1,6
package pt.estgp.estgweb.domain;
 
import pt.estgp.estgweb.services.bpmnprocess.types.DomainRoleProxy;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
 
/**
* Created by jorgemachado on 03/02/17.
9,6 → 9,7
{
public boolean hasRole(String r)
{
/*
if (r == null || getSelectorRole() == null || getSelectorRole().getRoles() == null || getSelectorRole().getRoles().size() == 0)
return false;
for (DomainRoleProxy role : getSelectorRole().getRoles())
17,10 → 18,13
return true;
}
return false;
*/
throw new NotImplementedException();
}
 
public void replaceRole(String oldRole,String newRole)
{
/*
if (oldRole == null || newRole == null || getSelectorRole() == null || getSelectorRole().getRoles() == null || getSelectorRole().getRoles().size() == 0)
return;
for (DomainRoleProxy role : getSelectorRole().getRoles())
31,6 → 35,8
break;
}
}
*/
throw new NotImplementedException();
}
 
 
/branches/v3/impl/src/java/pt/estgp/estgweb/domain/CourseSchoolImpl.java
1,7 → 1,6
package pt.estgp.estgweb.domain;
 
import com.owlike.genson.Genson;
import com.owlike.genson.TransformationException;
import org.json.JSONException;
import org.json.JSONObject;
 
48,21 → 47,21
.include("teacherRole",CourseSchoolImpl.class)
.create();
 
public String getJson() throws IOException, TransformationException
public String getJson() throws IOException
{
return courseSchoolGenson.serialize(this);
}
 
public static String getJson(ArrayList<CourseSchool> schools) throws IOException, TransformationException
public static String getJson(ArrayList<CourseSchool> schools) throws IOException
{
return courseSchoolGenson.serialize(schools);
}
 
public static CourseSchoolImpl loadFromJson(String json) throws IOException, TransformationException {
public static CourseSchoolImpl loadFromJson(String json) throws IOException {
return courseSchoolGenson.deserialize(json, CourseSchoolImpl.class);
}
 
public JSONObject getJsonObject() throws IOException, TransformationException, JSONException {
public JSONObject getJsonObject() throws IOException, JSONException {
return new JSONObject(getJson());
}
}
/branches/v3/impl/src/java/pt/estgp/estgweb/domain/test/TestCourseUnit.java
1,6 → 1,5
package pt.estgp.estgweb.domain.test;
 
import com.owlike.genson.TransformationException;
import junit.framework.TestCase;
import pt.estgp.estgweb.domain.CourseUnitImpl.Tipologia;
import pt.estgp.estgweb.domain.CourseUnitImpl.Tipologias;
108,8 → 107,6
 
} catch (IOException e) {
e.printStackTrace();
} catch (TransformationException e) {
e.printStackTrace();
}
}
 
192,8 → 189,6
 
} catch (IOException e) {
e.printStackTrace();
} catch (TransformationException e) {
e.printStackTrace();
}
}
 
357,8 → 352,6
 
} catch (IOException e) {
e.printStackTrace();
} catch (TransformationException e) {
e.printStackTrace();
}
 
 
483,8 → 476,6
 
} catch (IOException e) {
e.printStackTrace();
} catch (TransformationException e) {
e.printStackTrace();
}
 
 
610,8 → 601,6
 
} catch (IOException e) {
e.printStackTrace();
} catch (TransformationException e) {
e.printStackTrace();
}
 
 
740,8 → 729,6
 
} catch (IOException e) {
e.printStackTrace();
} catch (TransformationException e) {
e.printStackTrace();
}
 
 
915,8 → 902,6
 
} catch (IOException e) {
e.printStackTrace();
} catch (TransformationException e) {
e.printStackTrace();
}
 
 
/branches/v3/impl/src/java/pt/estgp/estgweb/domain/test/TestPageContentAclSimple.java
1,6 → 1,5
package pt.estgp.estgweb.domain.test;
 
import com.owlike.genson.TransformationException;
import junit.framework.TestCase;
import org.json.JSONException;
import pt.estgp.estgweb.Globals;
125,7 → 124,7
 
}
 
public void testAclUser() throws IOException, TransformationException, JSONException
public void testAclUser() throws IOException, JSONException
{
PageSection psAnonimousDenyAuthenticatedRead = new PageSectionImpl();
psAnonimousDenyAuthenticatedRead.setAccessPolicyClass(PageContentAccessPolicyAcl.class.getName());
/branches/v3/impl/src/java/pt/estgp/estgweb/domain/CourseDepartmentImpl.java
1,7 → 1,6
package pt.estgp.estgweb.domain;
 
import com.owlike.genson.Genson;
import com.owlike.genson.TransformationException;
import org.json.JSONException;
import org.json.JSONObject;
import pt.estgp.estgweb.utils.ConfigProperties;
39,21 → 38,21
.include("id",CourseSchoolImpl.class)
.create();
 
public String getJson() throws IOException, TransformationException
public String getJson() throws IOException
{
return courseDepartmentGenson.serialize(this);
}
public JSONObject getJsonObject() throws IOException, TransformationException, JSONException
public JSONObject getJsonObject() throws IOException, JSONException
{
return new JSONObject(courseDepartmentGenson.serialize(this));
}
 
public static String getJson(ArrayList<CourseDepartment> departments) throws IOException, TransformationException
public static String getJson(ArrayList<CourseDepartment> departments) throws IOException
{
return courseDepartmentGenson.serialize(departments);
}
 
public static CourseDepartmentImpl loadFromJson(String json) throws IOException, TransformationException
public static CourseDepartmentImpl loadFromJson(String json) throws IOException
{
return courseDepartmentGenson.deserialize(json,CourseDepartmentImpl.class);
}
/branches/v3/impl/src/java/pt/estgp/estgweb/domain/PageContentImpl.java
1,7 → 1,6
package pt.estgp.estgweb.domain;
 
import com.owlike.genson.Genson;
import com.owlike.genson.TransformationException;
import org.apache.log4j.Logger;
import org.json.JSONArray;
import org.json.JSONException;
241,7 → 240,7
* @param acls
* @throws JSONException
*/
public void setAclList(ArrayList<Acl> acls) throws JSONException, IOException, TransformationException {
public void setAclList(ArrayList<Acl> acls) throws JSONException, IOException {
if(acls == null || acls.size() == 0)
{
setAcl(null);
255,7 → 254,7
* @return allays a list if no acls return empty list
* @throws JSONException
*/
public ArrayList<Acl> getAclList() throws JSONException, IOException, TransformationException {
public ArrayList<Acl> getAclList() throws JSONException, IOException {
ArrayList<Acl> acls = new ArrayList<Acl>();
if(getAcl() == null || getAcl().trim().length() == 0)
return acls;
277,10 → 276,9
* Add a acl to String json at the end
* @param acl
* @throws IOException
* @throws TransformationException
* @throws JSONException
*/
public void addAcl(Acl acl) throws IOException, TransformationException, JSONException {
public void addAcl(Acl acl) throws IOException, JSONException {
if(acl == null)
return;
ArrayList<Acl> acls = getAclList();
304,10 → 302,9
* @param aclList
* @return
* @throws IOException
* @throws TransformationException
* @throws JSONException
*/
public static JSONArray getAclJson(ArrayList<Acl> aclList) throws IOException, TransformationException, JSONException {
public static JSONArray getAclJson(ArrayList<Acl> aclList) throws IOException, JSONException {
if(aclList == null)
return new JSONArray();
Genson genson = getGenson();
337,10 → 334,9
* Metodo de testes
* @param args
* @throws IOException
* @throws TransformationException
* @throws JSONException
*/
public static void main(String [] args) throws IOException, TransformationException, JSONException {
public static void main(String [] args) throws IOException, JSONException {
 
 
 
/branches/v3/impl/src/java/pt/estgp/estgweb/web/controllers/utils/MultiUploadServlet.java
1,6 → 1,5
package pt.estgp.estgweb.web.controllers.utils;
 
import com.owlike.genson.TransformationException;
import jomm.utils.BytesUtils;
import jomm.utils.FilesUtils;
import org.apache.commons.fileupload.FileItem;
80,20 → 79,14
}
}
 
try {
result.setService("ok");
String json = FilesUploadResult.serializeJson(result);
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
PrintWriter pw = response.getWriter();
pw.write(json);
} catch (TransformationException e) {
try {
sendError(e,request,response);
} catch (JSONException e1) {
logger.error(e,e);
}
}
 
result.setService("ok");
String json = FilesUploadResult.serializeJson(result);
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
PrintWriter pw = response.getWriter();
pw.write(json);
 
}
 
}
/branches/v3/impl/src/java/pt/estgp/estgweb/web/controllers/utils/FilesUploadResult.java
2,7 → 2,6
 
 
import com.owlike.genson.Genson;
import com.owlike.genson.TransformationException;
import org.json.JSONException;
import org.json.JSONObject;
 
43,20 → 42,20
.create();
}
public static FilesUploadResult parse(String json)
throws IOException, TransformationException {
throws IOException {
return getGenson().deserialize(json, FilesUploadResult.class);
}
 
public JSONObject toJsonObj() throws IOException, TransformationException, JSONException
public JSONObject toJsonObj() throws IOException, JSONException
{
return new JSONObject(getGenson().serialize(this));
}
 
public String toJson() throws IOException, TransformationException
public String toJson() throws IOException
{
return getGenson().serialize(this);
}
public static String serializeJson(FilesUploadResult result) throws IOException, TransformationException
public static String serializeJson(FilesUploadResult result) throws IOException
{
String json = getGenson().serialize(result);
return json;
/branches/v3/impl/src/java/pt/estgp/estgweb/web/controllers/utils/FilesUploadForm.java
1,6 → 1,5
package pt.estgp.estgweb.web.controllers.utils;
 
import com.owlike.genson.TransformationException;
import pt.estgp.estgweb.web.form.ApplicationForm;
 
import java.io.IOException;
22,7 → 21,7
this.uploadedFiles = uploadedFiles;
}
 
public FilesUploadResult getFilesUploadResult() throws IOException, TransformationException
public FilesUploadResult getFilesUploadResult() throws IOException
{
return FilesUploadResult.parse(uploadedFiles);
}
/branches/v3/impl/src/java/pt/estgp/estgweb/web/controllers/utils/FileUploaded.java
1,7 → 1,6
package pt.estgp.estgweb.web.controllers.utils;
 
import com.owlike.genson.Genson;
import com.owlike.genson.TransformationException;
 
import java.io.IOException;
import java.io.Serializable;
115,11 → 114,11
.create();
}
public static FileUploaded parse(String json)
throws IOException, TransformationException {
throws IOException {
return getGenson().deserialize(json, FileUploaded.class);
}
 
public static String serializeJson(FileUploaded result) throws IOException, TransformationException
public static String serializeJson(FileUploaded result) throws IOException
{
String json = getGenson().serialize(result);
return json;
/branches/v3/impl/src/java/pt/estgp/estgweb/web/controllers/examples/jsonwidget/WidgetFileUploadExampleController.java
1,6 → 1,5
package pt.estgp.estgweb.web.controllers.examples.jsonwidget;
 
import com.owlike.genson.TransformationException;
import org.apache.struts.action.ActionForm;
import org.json.JSONArray;
import org.json.JSONException;
28,11 → 27,10
* @param response
* @return
* @throws IOException
* @throws TransformationException
*/
public Boolean uploadFilesSimple(ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws IOException, TransformationException
HttpServletResponse response) throws IOException
{
JsonWidgetFileUploadExampleForm filesUploadForm = (JsonWidgetFileUploadExampleForm) form;
FilesUploadResult result = filesUploadForm.getFilesUploadResult();
61,12 → 59,11
* @param response
* @return
* @throws IOException
* @throws TransformationException
* @throws JSONException
*/
public JSONObject uploadFilesFeedback(ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws IOException, TransformationException, JSONException {
HttpServletResponse response) throws IOException, JSONException {
JsonWidgetFileUploadExampleForm filesUploadForm = (JsonWidgetFileUploadExampleForm) form;
FilesUploadResult result = filesUploadForm.getFilesUploadResult();
 
/branches/v3/impl/src/java/pt/estgp/estgweb/web/json/JsonHandler.java
1,6 → 1,5
package pt.estgp.estgweb.web.json;
 
import com.owlike.genson.TransformationException;
import org.apache.log4j.Logger;
import org.json.JSONArray;
import org.json.JSONException;
17,7 → 16,6
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import java.io.IOException;
54,22 → 52,11
response.setContentType("application/json");
try {
processRequest(request, response);
} catch (TransformationException e)
 
}catch (JSONException e)
{
response.getWriter().print(e);
response.getWriter().print("See log for details:");
logger.error(e,e);
}
catch (JAXBException e)
{
response.getWriter().print(e);
response.getWriter().print("See log for details:");
logger.error(e,e);
}
catch (JSONException e)
{
response.getWriter().print(e);
response.getWriter().print("See log for details:");
logger.error(e, e);
} catch (Throwable throwable) {
response.getWriter().print(throwable);
/branches/v3/impl/libs.xml
98,8 → 98,8
</fileset>
<fileset dir="${common.lib.dir}/json">
<include name="**/*.jar"/>
<exclude name="genson-1.4.jar"/>
<!--<exclude name="genson-0.97.jar"/>-->
<!--<exclude name="genson-1.4.jar"/>-->
<exclude name="genson-0.97.jar"/>
</fileset>
<fileset dir="${common.lib.dir}/jsoup">
<include name="**/*.jar"/>
/branches/v3/impl/build.xml
295,8 → 295,8
</fileset>
<fileset dir="${common.lib.dir}/json">
<include name="**/*.jar"/>
<!--<exclude name="genson-0.97.jar"/>-->
<exclude name="genson-1.4.jar"/>
<exclude name="genson-0.97.jar"/>
<!--<exclude name="genson-1.4.jar"/>-->
</fileset>
<fileset dir="${common.lib.dir}/jsoup">
<include name="**/*.jar"/>
/branches/v3/impl/etc/jsonComGensonAvisos/notasDeUsoGenson
90,16 → 90,16
 
Exemplos de SerializaĆ§Ć£o no RepositoryInterface
 
public String toJson() throws IOException, TransformationException
public String toJson() throws IOException
{
return genson.serialize(this);
}
 
public static RepositoryInterface loadFromJson(String json) throws IOException, TransformationException {
public static RepositoryInterface loadFromJson(String json) throws IOException {
return genson.deserialize(json, RepositoryInterface.class);
}
 
public JSONObject toJsonObject() throws IOException, TransformationException, JSONException {
public JSONObject toJsonObject() throws IOException, JSONException {
return new JSONObject(toJson());
}