// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) nocasts braces package com.stf.workflow.web.controller.impl; import com.stf.workflow.core.controller.*; import com.stf.workflow.model.BlockException; import com.stf.workflow.model.entity.*; import com.stf.workflow.model.entity.registrationCard.*; import com.stf.workflow.model.security.helper.EntityAccessHelper; import com.stf.workflow.model.service.ContentService; import com.stf.workflow.model.service.ReferenceService; import com.stf.workflow.model.service.helper.HibernateHelper; import com.stf.workflow.web.controller.DocumentController; import com.stf.workflow.web.form.DocumentForm; import com.stf.workflow.web.service.RouterService; import java.io.*; import java.util.*; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartRequest; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.Controller; // Referenced classes of package com.stf.workflow.web.controller.impl: // LoginController public class DocumentControllerImpl extends MultiFormController implements Controller, DocumentController { public DocumentControllerImpl() { C3 = new EntityAccessHelper(); } public synchronized Object createForm() { return new DocumentForm(); } protected synchronized void initForm(Object obj, Map map) { DocumentForm documentform = (DocumentForm)obj; Document document = null; User user = C4.getCurrentUser(); if(map.get("documentId") == null && map.get("delegationId") == null) { document = (Document)EntityCreator.createEntity(com/stf/workflow/model/entity/Document, user); Block block = new Block(); block.setUser(user); block.setTarget(document); document.setBlock(block); C8.assignRegistrator(document, C4.getCurrentUser()); documentform.setDocument(document); return; } if(map.get("delegationId") != null) { long l1 = ((Integer)map.get("delegationId")).longValue(); DelegationItem delegationitem; for(delegationitem = C5.getDelegation(Long.valueOf(l1), C4.getCurrentUser()); delegationitem.getParentDelegation() != null; delegationitem = delegationitem.getParentDelegation()) { } document = delegationitem.getParentDocument(); } else if(map.get("documentId") != null) { long l = ((Integer)map.get("documentId")).longValue(); document = C5.getDocument(Long.valueOf(l), user); } if(document != null) { hibernateHelper.initializeAll(document); Flow flow = document.getFlow(); com.stf.workflow.model.entity.registrationCard.RegistrationCard.RegistrationCardType registrationcardtype = flow.getRegCardType(); if(registrationcardtype == com.stf.workflow.model.entity.registrationCard.RegistrationCard.RegistrationCardType.IN) { documentform.setInRegCard((InRegistrationCard)document.getRegistrationCard()); } else if(registrationcardtype == com.stf.workflow.model.entity.registrationCard.RegistrationCard.RegistrationCardType.OUT) { documentform.setOutRegCard((OutRegistrationCard)document.getRegistrationCard()); } else if(registrationcardtype == com.stf.workflow.model.entity.registrationCard.RegistrationCard.RegistrationCardType.INNER) { documentform.setInnerRegCard((InnerRegistrationCard)document.getRegistrationCard()); } documentform.setFlowIdAndCardType((new StringBuilder()).append(flow.getId().toString()).append("_").append(flow.getRegCardType().toString()).toString()); documentform.setDocument(document); } } protected synchronized Map referenceData(Object obj) { Map map = C7.getVocabularyReferenceData(C4.getCurrentUser()); List list = C7.getFlowTypesReferenceData(C4.getCurrentUser(), Boolean.valueOf(true)); map.put("flowTypes", list); ArrayList arraylist = new ArrayList(); arraylist.add(new String[] { localizator.getString("controlcard.hour"), com.stf.workflow.model.entity.DeadLine.DeadLineTerm.HOUR.toString() }); arraylist.add(new String[] { localizator.getString("controlcard.day"), com.stf.workflow.model.entity.DeadLine.DeadLineTerm.DAY.toString() }); arraylist.add(new String[] { localizator.getString("controlcard.month"), com.stf.workflow.model.entity.DeadLine.DeadLineTerm.MONTH.toString() }); map.put("terms", arraylist); return map; } public Set getFiles(int i) { Set set = ((DocumentForm)form.get(Integer.valueOf(i))).getDocument().getAttachedDocFiles(); return DocFile.getDocFileList(set); } public Deligator getResolutor(int i) { return ((DocumentForm)form.get(Integer.valueOf(i))).getDocument().getResolutor(); } public void startFlow(int i, Set set, Deligator deligator) { putKKToDocument(i, set, deligator); Document document = ((DocumentForm)form.get(Integer.valueOf(i))).getDocument(); C8.startFlow(document, C4.getCurrentUser()); } public synchronized void sendOnResolution(int i, Deligator deligator) { saveResolutor(i, deligator); Document document = ((DocumentForm)form.get(Integer.valueOf(i))).getDocument(); C8.sendToResolution(document, C4.getCurrentUser()); } public synchronized void returnResolution(int i) { Document document = ((DocumentForm)form.get(Integer.valueOf(i))).getDocument(); C8.returnResolution(document, C4.getCurrentUser()); } public void saveResolutor(int i, Deligator deligator) { ((DocumentForm)form.get(Integer.valueOf(i))).getDocument().setResolutor(deligator); } public synchronized void acceptDelegation(int i, String s, String s1) { Document document = ((DocumentForm)form.get(Integer.valueOf(i))).getDocument(); Long long1 = Long.valueOf(s1); C8.acceptDelegation(document, long1, s, C4.getCurrentUser()); } public synchronized void declineDelegation(int i, String s, String s1) { Document document = ((DocumentForm)form.get(Integer.valueOf(i))).getDocument(); Long long1 = Long.valueOf(s1); C8.declineDelegation(document, long1, s, C4.getCurrentUser()); } public synchronized void reportDelegation(int i, String s, String s1) { Document document = ((DocumentForm)form.get(Integer.valueOf(i))).getDocument(); Long long1 = Long.valueOf(s1); C8.reportDelegation(document, long1, s, C4.getCurrentUser()); } public synchronized void acceptResolution(int i, String s, String s1) { Document document = ((DocumentForm)form.get(Integer.valueOf(i))).getDocument(); Long long1 = Long.valueOf(s1); C8.acceptResolution(document, long1, s, C4.getCurrentUser()); DocFile.signFiles(document.getAttachedDocFiles(), C4.getCurrentUser()); } public synchronized void declineResolution(int i, String s, String s1) { Document document = ((DocumentForm)form.get(Integer.valueOf(i))).getDocument(); Long long1 = Long.valueOf(s1); C8.declineResolution(document, long1, s, C4.getCurrentUser()); } public synchronized void takeDelegationFromControl(int i, String s, String s1) { Document document = ((DocumentForm)form.get(Integer.valueOf(i))).getDocument(); Long long1 = Long.valueOf(s1); C8.takeDelegationFromControl(document, long1, s, C4.getCurrentUser()); } public synchronized void returnDelegation(int i, String s, String s1) { Document document = ((DocumentForm)form.get(Integer.valueOf(i))).getDocument(); Long long1 = Long.valueOf(s1); C8.returnDelegation(document, long1, s, C4.getCurrentUser()); } public synchronized void forwardDelegation(int i, String s, String s1, Set set, Deligator deligator) { if(s1.equals("NaN")) { throw new Error(localizator.getString("error.controlcard.delegationnotsaved")); } else { putKKToDocument(i, set, deligator); Document document = ((DocumentForm)form.get(Integer.valueOf(i))).getDocument(); Long long1 = Long.valueOf(s1); C8.forwardDelegation(document, long1, s, C4.getCurrentUser()); return; } } public synchronized void cancelDelegation(int i, String s, String s1) { Document document = ((DocumentForm)form.get(Integer.valueOf(i))).getDocument(); Long long1 = Long.valueOf(s1); C8.cancelDelegation(document, long1, s, C4.getCurrentUser()); } public synchronized void takeDocumentFromControl(int i, String s) { Document document = ((DocumentForm)form.get(Integer.valueOf(i))).getDocument(); C8.takeDocumentFromControl(document, s, C4.getCurrentUser()); } public synchronized void cancelDocument(int i, String s) { Document document = ((DocumentForm)form.get(Integer.valueOf(i))).getDocument(); C8.cancelDocument(document, s, C4.getCurrentUser()); } public void onSave(DocumentForm documentform, Map map) throws SecurityException { documentform.getDocument().getDelegationHistory(); Long long1 = Long.valueOf(documentform.getFlowIdAndCardType().split("_")[0]); Flow flow = C7.getFlow(long1, C4.getCurrentUser()); Document document = documentform.getDocument(); document.setFlow(flow); com.stf.workflow.model.entity.registrationCard.RegistrationCard.RegistrationCardType registrationcardtype = flow.getRegCardType(); if(registrationcardtype == com.stf.workflow.model.entity.registrationCard.RegistrationCard.RegistrationCardType.IN) { document.setRegistrationCard(documentform.getInRegCard()); } else if(registrationcardtype == com.stf.workflow.model.entity.registrationCard.RegistrationCard.RegistrationCardType.OUT) { document.setRegistrationCard(documentform.getOutRegCard()); } else if(registrationcardtype == com.stf.workflow.model.entity.registrationCard.RegistrationCard.RegistrationCardType.INNER) { document.setRegistrationCard(documentform.getInnerRegCard()); } if(document.getId() == null) { Long long2 = flow.getCounter(); Long long3 = long2; Long long4 = long2 = Long.valueOf(long2.longValue() + 1L); Long _tmp = long3; flow.setCounter(long2); C7.saveFlow(flow, C4.getCurrentUser()); document.getRegistrationCard().getRegistrationNumber().setDocNr(long2); documentform.getInnerRegCard().getRegistrationNumber().setDocNr(long2); documentform.getInRegCard().getRegistrationNumber().setDocNr(long2); documentform.getOutRegCard().getRegistrationNumber().setDocNr(long2); } Block block = document.getBlock(); if(block != null && block.getId() != null && (block == null || !block.getUser().equals(block.getUser()))) { throw new BlockException(localizator.getString("sequrity.objectNotBlocked")); } else { B(documentform); System.out.println("Document saved -------------"); return; } } private void B(DocumentForm documentform) { Document document = documentform.getDocument(); User user = C4.getCurrentUser(); DelegationHistoryItem delegationhistoryitem; for(Iterator iterator = document.getDelegationHistory().iterator(); iterator.hasNext(); C5.saveNotifier(delegationhistoryitem.getNotify(), C4.getCurrentUser())) { delegationhistoryitem = (DelegationHistoryItem)iterator.next(); Notifier notifier; if(delegationhistoryitem.getNotify() == null) { notifier = (Notifier)EntityCreator.createEntity(com/stf/workflow/model/entity/Notifier, C4.getCurrentUser()); } else if(delegationhistoryitem.getNotify().getId() == null) { notifier = delegationhistoryitem.getNotify(); } else { notifier = C5.getNotifier(delegationhistoryitem.getNotify().getId(), C4.getCurrentUser()); notifier.getUsers().clear(); notifier.getUsers().addAll(delegationhistoryitem.getNotify().getUsers()); } delegationhistoryitem.setNotify(notifier); } Set set = document.getControlCard().getDeligations(); A(set); DelegationHistoryItem delegationhistoryitem1; for(Iterator iterator1 = document.getDelegationHistory().iterator(); iterator1.hasNext(); delegationhistoryitem1.setNotify(C5.mergeNotifier(delegationhistoryitem1.getNotify(), C4.getCurrentUser()))) { delegationhistoryitem1 = (DelegationHistoryItem)iterator1.next(); } Iterator iterator2 = document.getControlCard().getDeligations().iterator(); do { if(!iterator2.hasNext()) { break; } DelegationItem delegationitem = (DelegationItem)iterator2.next(); if(delegationitem.getDelegationHistory() != null) { Iterator iterator3 = delegationitem.getDelegationHistory().iterator(); while(iterator3.hasNext()) { DelegationHistoryItem delegationhistoryitem2 = (DelegationHistoryItem)iterator3.next(); delegationhistoryitem2.setNotify(C5.mergeNotifier(delegationhistoryitem2.getNotify(), C4.getCurrentUser())); } } } while(true); C5.saveDocument(document, C4.getCurrentUser()); } private void A(Set set) { Iterator iterator = set.iterator(); do { if(!iterator.hasNext()) { break; } DelegationItem delegationitem = (DelegationItem)iterator.next(); if(delegationitem.getChildren() != null) { A(delegationitem.getChildren()); } if(delegationitem.getDelegationHistory() != null) { Iterator iterator1 = delegationitem.getDelegationHistory().iterator(); while(iterator1.hasNext()) { DelegationHistoryItem delegationhistoryitem = (DelegationHistoryItem)iterator1.next(); Notifier notifier; if(delegationhistoryitem.getNotify() == null) { notifier = (Notifier)EntityCreator.createEntity(com/stf/workflow/model/entity/Notifier, C4.getCurrentUser()); } else if(delegationhistoryitem.getNotify().getId() == null) { notifier = delegationhistoryitem.getNotify(); } else { notifier = C5.getNotifier(delegationhistoryitem.getNotify().getId(), C4.getCurrentUser()); notifier.getUsers().clear(); notifier.getUsers().addAll(delegationhistoryitem.getNotify().getUsers()); } delegationhistoryitem.setNotify(notifier); C5.saveNotifier(delegationhistoryitem.getNotify(), C4.getCurrentUser()); } } } while(true); } private void A(DocumentForm documentform) { File file; File file1; for(Iterator iterator = documentform.getDocument().getAttachedDocFiles().iterator(); iterator.hasNext(); file.renameTo(file1)) { DocFile docfile = (DocFile)iterator.next(); String s = C6.getDocumentDirectory(documentform.getDocument().getId()); file = new File((new StringBuilder()).append(s).append('/').append(docfile.getName()).toString()); file1 = new File((new StringBuilder()).append(s).append('/').append(docfile.getId()).toString()); } } public void setContentService(ContentService contentservice) { C5 = contentservice; } public void setFileSaver(FileReceiverController filereceivercontroller) { C6 = filereceivercontroller; } public synchronized void putKKToDocument(int i, Set set, Deligator deligator) { DocumentForm documentform = (DocumentForm)form.get(Integer.valueOf(i)); B(set); Set set1 = documentform.getDocument().getControlCard().getDeligations(); set1.clear(); set1.addAll(set); if(deligator != null) { deligator.setAccountId(C4.getCurrentUser().getAccountId()); } documentform.getDocument().getControlCard().setController(deligator); } private void B(Set set) { Iterator iterator = set.iterator(); do { if(!iterator.hasNext()) { break; } DelegationItem delegationitem = (DelegationItem)iterator.next(); delegationitem.setAccountId(C4.getCurrentUser().getAccountId()); if(delegationitem.getCreationDate() == null) { delegationitem.setCreationDate(new Date()); } delegationitem.setAccountId(C4.getCurrentUser().getAccountId()); if(delegationitem.getDelegatorsArray() != null) { Deligator deligator; for(Iterator iterator1 = delegationitem.getDelegatorsArray().iterator(); iterator1.hasNext(); deligator.setAccountId(C4.getCurrentUser().getAccountId())) { deligator = (Deligator)iterator1.next(); } } if(delegationitem.getChildren() != null) { B(delegationitem.getChildren()); } } while(true); } public synchronized Deligator getController(int i) { DocumentForm documentform = (DocumentForm)form.get(Integer.valueOf(i)); if(documentform != null) { return documentform.getDocument().getControlCard().getController(); } else { return null; } } public synchronized ModelAndView handleRequestInternal(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse) throws Exception { InputStream inputstream; Integer integer2; String s3; Long long3; Object obj; String s11; FileOutputStream fileoutputstream; if(!(httpservletrequest instanceof MultipartRequest)) { break MISSING_BLOCK_LABEL_330; } MultipartRequest multipartrequest = (MultipartRequest)httpservletrequest; MultipartFile multipartfile = multipartrequest.getFile("file"); inputstream = multipartfile.getInputStream(); if(inputstream == null) { break MISSING_BLOCK_LABEL_330; } integer2 = Integer.valueOf(httpservletrequest.getParameter("windowId")); s3 = httpservletrequest.getParameter("version"); long3 = Long.valueOf(httpservletrequest.getParameter("parentDocumentId")); Long long4 = ((DocumentForm)form.get(integer2)).getDocument().getId(); obj = multipartfile.getOriginalFilename(); String s9 = C6.getDocumentDirectory(long4); s11 = (new StringBuilder()).append(s9).append('/').append(obj).toString(); fileoutputstream = new FileOutputStream(s11); byte abyte1[] = new byte[1000]; int j; while((j = inputstream.read(abyte1)) != -1) { fileoutputstream.write(abyte1, 0, j); } fileoutputstream.flush(); fileoutputstream.close(); break MISSING_BLOCK_LABEL_224; Exception exception1; exception1; exception1.printStackTrace(); fileoutputstream.close(); break MISSING_BLOCK_LABEL_224; Exception exception2; exception2; fileoutputstream.close(); throw exception2; File file2 = new File(s11); DocFile docfile1 = (DocFile)EntityCreator.createEntity(com/stf/workflow/model/entity/DocFile, C4.getCurrentUser()); docfile1.setProperties(obj, file2.length(), s3); DocFile.addNewDocument(((DocumentForm)form.get(integer2)).getDocument().getAttachedDocFiles(), docfile1, long3); B((DocumentForm)form.get(integer2)); A((DocumentForm)form.get(integer2)); FileInputStream fileinputstream; String s7; String s = httpservletrequest.getParameter("action"); if(s == null || !s.equals("downloadFile")) { break MISSING_BLOCK_LABEL_661; } fileinputstream = null; Integer integer = Integer.valueOf(httpservletrequest.getParameter("formId")); String s2 = httpservletrequest.getParameter("fileId"); Long long2 = Long.valueOf(s2); String s5 = C6.getDocumentDirectory(((DocumentForm)form.get(integer)).getDocument().getId()); s7 = (new StringBuilder()).append(s5).append('/').append(s2).toString(); obj = DocFile.getDocFile(((DocumentForm)form.get(integer)).getDocument().getAttachedDocFiles(), long2); httpservletresponse.setContentType("application/octet-stream"); String s10 = (new StringBuilder()).append("Attachment;Filename=").append(obj.getName().replaceAll(" ", "%20")).toString(); httpservletresponse.setHeader("Content-Disposition", s10); File file1 = new File(s7); fileinputstream = new FileInputStream(file1); byte abyte0[] = new byte[1000]; int i; while((i = fileinputstream.read(abyte0)) != -1) { httpservletresponse.getOutputStream().write(abyte0, 0, i); } httpservletresponse.getOutputStream().flush(); httpservletresponse.getOutputStream().close(); fileinputstream.close(); httpservletresponse.getOutputStream().close(); fileinputstream.close(); break MISSING_BLOCK_LABEL_661; Exception exception; exception; exception.printStackTrace(); httpservletresponse.getOutputStream().close(); fileinputstream.close(); break MISSING_BLOCK_LABEL_661; Exception exception3; exception3; httpservletresponse.getOutputStream().close(); fileinputstream.close(); throw exception3; String s1 = httpservletrequest.getHeader("operation"); if(s1 != null && s1.equals("scanner")) { Integer integer1 = Integer.valueOf(httpservletrequest.getHeader("num")); Long long1 = ((DocumentForm)form.get(integer1)).getDocument().getId(); String s4 = C6.getDocumentDirectory(long1); String s6 = "Scanned document.pdf"; String s8 = (new StringBuilder()).append(s4).append('/').append(s6).toString(); try { C6.savePDFDocument(httpservletrequest.getInputStream(), s8); httpservletresponse.getWriter().print("success"); } catch(IOException ioexception) { ioexception.printStackTrace(); httpservletresponse.getWriter().print("failed"); } File file = new File(s8); DocFile docfile = (DocFile)EntityCreator.createEntity(com/stf/workflow/model/entity/DocFile, C4.getCurrentUser()); docfile.setProperties(s6, file.length(), "1.0"); DocFile.addNewDocument(((DocumentForm)form.get(integer1)).getDocument().getAttachedDocFiles(), docfile, Long.valueOf(-1L)); B((DocumentForm)form.get(integer1)); A((DocumentForm)form.get(integer1)); } return null; } public synchronized void removeFiles(int i, List list) { File file; for(Iterator iterator = list.iterator(); iterator.hasNext(); file.delete()) { String s = (String)iterator.next(); long l = Long.valueOf(s).longValue(); DocFile.removeFile(((DocumentForm)form.get(Integer.valueOf(i))).getDocument().getAttachedDocFiles(), Long.valueOf(l)); String s1 = C6.getDocumentDirectory(((DocumentForm)form.get(Integer.valueOf(i))).getDocument().getId()); file = new File((new StringBuilder()).append(s1).append('/').append(l).toString()); } B((DocumentForm)form.get(Integer.valueOf(i))); } public synchronized void renameFile(int i, Long long1, String s) { DocFile.renameFile(((DocumentForm)form.get(Integer.valueOf(i))).getDocument().getAttachedDocFiles(), long1, s); B((DocumentForm)form.get(Integer.valueOf(i))); } public synchronized Map getTemporaryACL(int i) { HashMap hashmap = new HashMap(); DocumentForm documentform = (DocumentForm)form.get(Integer.valueOf(i)); if(documentform != null) { hashmap.put("temporaryACL", documentform.getDocument().getTemporaryACL()); hashmap.put("block", documentform.getDocument().getBlock()); hashmap.put("run", documentform.getDocument().getRun()); hashmap.put("onRegistration", documentform.getDocument().getOnRegistration()); } return hashmap; } public synchronized Document getDeligationsAndDocumentHistory(int i) { try { DocumentForm documentform = (DocumentForm)form.get(Integer.valueOf(i)); if(documentform != null && documentform.getDocument().getControlCard().getDeligations() == null) { documentform.getDocument().getControlCard().setDeligations(new HashSet()); } return documentform.getDocument(); } catch(Exception exception) { exception.printStackTrace(); } return null; } public synchronized ACL getDocumentACL(int i) { DocumentForm documentform = (DocumentForm)form.get(Integer.valueOf(i)); return documentform.getDocument().getAcl(); } public synchronized void setDocumentACL(int i, ACL acl) { DocumentForm documentform = (DocumentForm)form.get(Integer.valueOf(i)); C3.checkAccess(documentform.getDocument(), C4.getCurrentUser(), com.stf.workflow.model.security.helper.EntityAccessHelper.Access.WRITE); documentform.getDocument().setAcl(acl); } public synchronized Block blockDocument(int i) { DocumentForm documentform = (DocumentForm)form.get(Integer.valueOf(i)); C5.evictDocument(documentform.getDocument()); Document document = C5.getDocument(documentform.getDocument().getId(), C4.getCurrentUser()); hibernateHelper.initializeAll(document); documentform.setDocument(document); C5.createDocumentBlock(document, C4.getCurrentUser()); return document.getBlock(); } public synchronized void removeForm(int i) { DocumentForm documentform = (DocumentForm)form.get(Integer.valueOf(i)); if(documentform.getDocument().getId() != null) { C5.removeDocumentBlock(documentform.getDocument(), C4.getCurrentUser()); } super.removeForm(i); } public void setLoginController(LoginController logincontroller) { C4 = logincontroller; } public LoginController getLoginController() { return C4; } public void setReferenceService(ReferenceService referenceservice) { C7 = referenceservice; } public void setRouterService(RouterService routerservice) { C8 = routerservice; } public Set superGetR() { DocumentForm documentform = (DocumentForm)form.get(Integer.valueOf(1)); return documentform.getDocument().getDelegationHistory(); } private ContentService C5; private ReferenceService C7; private FileReceiverController C6; private LoginController C4; private RouterService C8; private EntityAccessHelper C3; private static final String C1 = "documentId"; private static final String C2 = "delegationId"; }