Search in sources :

Example 1 with VersionInfo

use of org.vcell.util.document.VersionInfo in project vcell by virtualcell.

the class ClientRequestManager method accessPermissions.

public void accessPermissions(Component requester, VCDocument vcDoc) {
    VersionInfo selectedVersionInfo = null;
    switch(vcDoc.getDocumentType()) {
        case BIOMODEL_DOC:
            BioModelInfo[] bioModelInfos = getDocumentManager().getBioModelInfos();
            for (BioModelInfo bioModelInfo : bioModelInfos) {
                if (bioModelInfo.getVersion().getVersionKey().equals(vcDoc.getVersion().getVersionKey())) {
                    selectedVersionInfo = bioModelInfo;
                    break;
                }
            }
            break;
        case MATHMODEL_DOC:
            MathModelInfo[] mathModelInfos = getDocumentManager().getMathModelInfos();
            for (MathModelInfo mathModelInfo : mathModelInfos) {
                if (mathModelInfo.getVersion().getVersionKey().equals(vcDoc.getVersion().getVersionKey())) {
                    selectedVersionInfo = mathModelInfo;
                    break;
                }
            }
            break;
        case GEOMETRY_DOC:
            GeometryInfo[] geoInfos = getDocumentManager().getGeometryInfos();
            for (GeometryInfo geoInfo : geoInfos) {
                if (geoInfo.getVersion().getVersionKey().equals(vcDoc.getVersion().getVersionKey())) {
                    selectedVersionInfo = geoInfo;
                    break;
                }
            }
            break;
    }
    getMdiManager().getDatabaseWindowManager().accessPermissions(requester, selectedVersionInfo);
}
Also used : VersionInfo(org.vcell.util.document.VersionInfo) BioModelInfo(org.vcell.util.document.BioModelInfo) GeometryInfo(cbit.vcell.geometry.GeometryInfo) MathModelInfo(org.vcell.util.document.MathModelInfo)

Example 2 with VersionInfo

use of org.vcell.util.document.VersionInfo in project vcell by virtualcell.

the class LocalUserMetaDbServerMessaging method groupSetPublic.

/**
 * This method was created in VisualAge.
 * @return void
 * @param key KeyValue
 * @exception DataAccessException The exception description.
 * @exception java.rmi.RemoteException The exception description.
 */
public org.vcell.util.document.VersionInfo groupSetPublic(org.vcell.util.document.VersionableType vType, org.vcell.util.document.KeyValue key) throws DataAccessException, ObjectNotFoundException {
    try {
        log.print("LocalUserMetaDbServerMessaging.groupSetPublic(vType=" + vType.getTypeName() + ", Key=" + key + ")");
        VersionInfo newVersionInfo = dbServerProxy.groupSetPublic(vType, key);
        return newVersionInfo;
    } catch (DataAccessException e) {
        log.exception(e);
        throw e;
    } catch (Throwable e) {
        log.exception(e);
        throw new DataAccessException(e.getMessage());
    }
}
Also used : VersionInfo(org.vcell.util.document.VersionInfo) DataAccessException(org.vcell.util.DataAccessException)

Example 3 with VersionInfo

use of org.vcell.util.document.VersionInfo in project vcell by virtualcell.

the class LocalUserMetaDbServerMessaging method groupAddUser.

/**
 * This method was created in VisualAge.
 * @return void
 * @param key KeyValue
 * @exception DataAccessException The exception description.
 * @exception java.rmi.RemoteException The exception description.
 */
public org.vcell.util.document.VersionInfo groupAddUser(org.vcell.util.document.VersionableType vType, org.vcell.util.document.KeyValue key, String addUserToGroup, boolean isHidden) throws DataAccessException, ObjectNotFoundException {
    try {
        log.print("LocalUserMetaDbServerMessaging.groupAddUser(vType=" + vType.getTypeName() + ", Key=" + key + ", userToAdd=" + addUserToGroup + ", isHidden=" + isHidden + ")");
        VersionInfo newVersionInfo = dbServerProxy.groupAddUser(vType, key, addUserToGroup, isHidden);
        return newVersionInfo;
    } catch (DataAccessException e) {
        log.exception(e);
        throw e;
    } catch (Throwable e) {
        log.exception(e);
        throw new DataAccessException(e.getMessage());
    }
}
Also used : VersionInfo(org.vcell.util.document.VersionInfo) DataAccessException(org.vcell.util.DataAccessException)

Example 4 with VersionInfo

use of org.vcell.util.document.VersionInfo in project vcell by virtualcell.

the class LocalUserMetaDbServerMessaging method groupRemoveUser.

/**
 * This method was created in VisualAge.
 * @return void
 * @param key KeyValue
 * @exception DataAccessException The exception description.
 * @exception java.rmi.RemoteException The exception description.
 */
public org.vcell.util.document.VersionInfo groupRemoveUser(org.vcell.util.document.VersionableType vType, org.vcell.util.document.KeyValue key, String userRemoveFromGroup, boolean isHiddenFromOwner) throws DataAccessException, ObjectNotFoundException {
    try {
        log.print("LocalUserMetaDbServerMessaging.groupRemoveUser(vType=" + vType.getTypeName() + ", Key=" + key + ", userRemoveFromGroup=" + userRemoveFromGroup + ")");
        VersionInfo newVersionInfo = dbServerProxy.groupRemoveUser(vType, key, userRemoveFromGroup, isHiddenFromOwner);
        return newVersionInfo;
    } catch (DataAccessException e) {
        log.exception(e);
        throw e;
    } catch (Throwable e) {
        log.exception(e);
        throw new DataAccessException(e.getMessage());
    }
}
Also used : VersionInfo(org.vcell.util.document.VersionInfo) DataAccessException(org.vcell.util.DataAccessException)

Example 5 with VersionInfo

use of org.vcell.util.document.VersionInfo in project vcell by virtualcell.

the class DatabaseWindowManager method accessPermissions.

/**
 * Insert the method's description here.
 * Creation date: (5/14/2004 5:35:55 PM)
 */
public void accessPermissions(final Component requester, final VersionInfo selectedVersionInfo) {
    final GroupAccess groupAccess = selectedVersionInfo.getVersion().getGroupAccess();
    final DocumentManager docManager = getRequestManager().getDocumentManager();
    AsynchClientTask task1 = new AsynchClientTask("show dialog", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            getAclEditor().clearACLList();
            getAclEditor().setACLState(new ACLEditor.ACLState(groupAccess));
            Object choice = showAccessPermissionDialog(getAclEditor(), requester);
            if (choice != null) {
                hashTable.put("choice", choice);
            }
        }
    };
    AsynchClientTask task2 = new AsynchClientTask("access permission", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            Object choice = hashTable.get("choice");
            if (choice != null && choice.equals("OK")) {
                ACLEditor.ACLState aclState = getAclEditor().getACLState();
                if (aclState != null) {
                    if (aclState.isAccessPrivate() || (aclState.getAccessList() != null && aclState.getAccessList().length == 0)) {
                        VersionInfo vInfo = null;
                        if (selectedVersionInfo instanceof BioModelInfo) {
                            vInfo = docManager.setGroupPrivate((BioModelInfo) selectedVersionInfo);
                        } else if (selectedVersionInfo instanceof MathModelInfo) {
                            vInfo = docManager.setGroupPrivate((MathModelInfo) selectedVersionInfo);
                        } else if (selectedVersionInfo instanceof GeometryInfo) {
                            vInfo = docManager.setGroupPrivate((GeometryInfo) selectedVersionInfo);
                        } else if (selectedVersionInfo instanceof VCImageInfo) {
                            vInfo = docManager.setGroupPrivate((VCImageInfo) selectedVersionInfo);
                        }
                    } else if (aclState.isAccessPublic()) {
                        VersionInfo vInfo = null;
                        if (selectedVersionInfo instanceof BioModelInfo) {
                            vInfo = docManager.setGroupPublic((BioModelInfo) selectedVersionInfo);
                        } else if (selectedVersionInfo instanceof MathModelInfo) {
                            vInfo = docManager.setGroupPublic((MathModelInfo) selectedVersionInfo);
                        } else if (selectedVersionInfo instanceof GeometryInfo) {
                            vInfo = docManager.setGroupPublic((GeometryInfo) selectedVersionInfo);
                        } else if (selectedVersionInfo instanceof VCImageInfo) {
                            vInfo = docManager.setGroupPublic((VCImageInfo) selectedVersionInfo);
                        }
                    } else {
                        String[] aclUserNames = aclState.getAccessList();
                        String[] originalGroupAccesNames = new String[0];
                        // Turn User[] into String[]
                        if (groupAccess instanceof GroupAccessSome) {
                            GroupAccessSome gas = (GroupAccessSome) groupAccess;
                            User[] originalUsers = gas.getNormalGroupMembers();
                            for (int i = 0; i < originalUsers.length; i += 1) {
                                originalGroupAccesNames = (String[]) BeanUtils.addElement(originalGroupAccesNames, originalUsers[i].getName());
                            }
                        }
                        // Determine users needing adding
                        String[] needToAddUsers = new String[0];
                        for (int i = 0; i < aclUserNames.length; i += 1) {
                            if (!BeanUtils.arrayContains(originalGroupAccesNames, aclUserNames[i])) {
                                System.out.println("Added user=" + aclUserNames[i]);
                                needToAddUsers = (String[]) BeanUtils.addElement(needToAddUsers, aclUserNames[i]);
                            }
                        }
                        // Determine users needing removing
                        String[] needToRemoveUsers = new String[0];
                        for (int i = 0; i < originalGroupAccesNames.length; i += 1) {
                            if (!BeanUtils.arrayContains(aclUserNames, originalGroupAccesNames[i])) {
                                System.out.println("Removed user=" + originalGroupAccesNames[i]);
                                needToRemoveUsers = (String[]) BeanUtils.addElement(needToRemoveUsers, originalGroupAccesNames[i]);
                            }
                        }
                        VersionInfo vInfo = null;
                        String errorNames = "";
                        // Add Users to Group Access List
                        for (int i = 0; i < needToAddUsers.length; i++) {
                            try {
                                if (selectedVersionInfo instanceof BioModelInfo) {
                                    vInfo = docManager.addUserToGroup((BioModelInfo) selectedVersionInfo, needToAddUsers[i]);
                                } else if (selectedVersionInfo instanceof MathModelInfo) {
                                    vInfo = docManager.addUserToGroup((MathModelInfo) selectedVersionInfo, needToAddUsers[i]);
                                } else if (selectedVersionInfo instanceof GeometryInfo) {
                                    vInfo = docManager.addUserToGroup((GeometryInfo) selectedVersionInfo, needToAddUsers[i]);
                                } else if (selectedVersionInfo instanceof VCImageInfo) {
                                    vInfo = docManager.addUserToGroup((VCImageInfo) selectedVersionInfo, needToAddUsers[i]);
                                }
                            } catch (ObjectNotFoundException e) {
                                errorNames += "Error changing permissions.\n" + selectedVersionInfo.getVersionType().getTypeName() + " \"" + selectedVersionInfo.getVersion().getName() + "\" edition (" + selectedVersionInfo.getVersion().getDate() + ")\nnot found, " + "your model list may be out of date, please go to menu Server->Reconnect to refresh the model list" + "\n";
                                break;
                            } catch (DataAccessException e) {
                                errorNames += "Error adding user '" + needToAddUsers[i] + "' : " + e.getMessage() + "\n";
                            }
                        }
                        // Remove users from Group Access List
                        for (int i = 0; i < needToRemoveUsers.length; i++) {
                            try {
                                if (selectedVersionInfo instanceof BioModelInfo) {
                                    vInfo = docManager.removeUserFromGroup((BioModelInfo) selectedVersionInfo, needToRemoveUsers[i]);
                                } else if (selectedVersionInfo instanceof MathModelInfo) {
                                    vInfo = docManager.removeUserFromGroup((MathModelInfo) selectedVersionInfo, needToRemoveUsers[i]);
                                } else if (selectedVersionInfo instanceof GeometryInfo) {
                                    vInfo = docManager.removeUserFromGroup((GeometryInfo) selectedVersionInfo, needToRemoveUsers[i]);
                                } else if (selectedVersionInfo instanceof VCImageInfo) {
                                    vInfo = docManager.removeUserFromGroup((VCImageInfo) selectedVersionInfo, needToRemoveUsers[i]);
                                }
                            } catch (DataAccessException e) {
                                errorNames += "Error Removing user '" + needToRemoveUsers[i] + "'\n  -----" + e.getMessage() + "\n";
                            }
                        }
                        if (errorNames.length() > 0) {
                            if (DatabaseWindowManager.this.getComponent() != null) {
                                PopupGenerator.showErrorDialog(DatabaseWindowManager.this, errorNames);
                            } else {
                                DialogUtils.showErrorDialog(requester, errorNames);
                            }
                            accessPermissions(requester, selectedVersionInfo);
                        }
                    }
                }
            }
        }
    };
    ClientTaskDispatcher.dispatch(requester, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) DocumentManager(cbit.vcell.clientdb.DocumentManager) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) ACLEditor(cbit.vcell.client.desktop.ACLEditor) VersionInfo(org.vcell.util.document.VersionInfo) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) GeometryInfo(cbit.vcell.geometry.GeometryInfo) GroupAccessSome(org.vcell.util.document.GroupAccessSome) GroupAccess(org.vcell.util.document.GroupAccess) VCImageInfo(cbit.image.VCImageInfo) DataAccessException(org.vcell.util.DataAccessException)

Aggregations

VersionInfo (org.vcell.util.document.VersionInfo)28 DataAccessException (org.vcell.util.DataAccessException)18 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)10 SQLException (java.sql.SQLException)6 BigDecimal (java.math.BigDecimal)5 VersionableTypeVersion (org.vcell.util.document.VersionableTypeVersion)5 ResultSet (java.sql.ResultSet)4 Statement (java.sql.Statement)4 Hashtable (java.util.Hashtable)4 MathModelInfo (org.vcell.util.document.MathModelInfo)4 Version (org.vcell.util.document.Version)4 VCImageInfo (cbit.image.VCImageInfo)3 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)3 GeometryInfo (cbit.vcell.geometry.GeometryInfo)3 Connection (java.sql.Connection)3 Vector (java.util.Vector)3 TreePath (javax.swing.tree.TreePath)3 BioModelInfo (org.vcell.util.document.BioModelInfo)3 VCDocumentInfoNode (cbit.vcell.desktop.VCellBasicCellRenderer.VCDocumentInfoNode)2 SimulationInfo (cbit.vcell.solver.SimulationInfo)2