use of org.xmldb.api.base.XMLDBException in project exist by eXist-db.
the class DocumentView method viewDocument.
public void viewDocument() {
try {
if (// $NON-NLS-1$
"XMLResource".equals(resource.getResourceType())) {
setText((String) resource.getContent());
} else {
setText(new String((byte[]) resource.getContent()));
}
// lock the resource for editing
final UserManagementService service = (UserManagementService) // $NON-NLS-1$ //$NON-NLS-2$
client.current.getService("UserManagementService", "1.0");
// $NON-NLS-1$
final Account user = service.getAccount(properties.getProperty("user"));
final String lockOwner = service.hasUserLock(resource);
if (lockOwner != null) {
if (JOptionPane.showConfirmDialog(this, // $NON-NLS-1$
Messages.getString("DocumentView.6") + lockOwner + // $NON-NLS-1$
Messages.getString("DocumentView.7"), // $NON-NLS-1$
Messages.getString("DocumentView.8"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
dispose();
this.setCursor(Cursor.getDefaultCursor());
return;
}
}
try {
service.lockResource(resource, user);
} catch (final XMLDBException ex) {
System.out.println(ex.getMessage());
JOptionPane.showMessageDialog(this, // $NON-NLS-1$
Messages.getString("DocumentView.9"));
setReadOnly();
}
setVisible(true);
} catch (final XMLDBException ex) {
// $NON-NLS-1$
showErrorMessage(Messages.getString("DocumentView.10") + ex.getMessage(), ex);
}
}
use of org.xmldb.api.base.XMLDBException in project exist by eXist-db.
the class AddGroupTask method execute.
/* (non-Javadoc)
* @see org.apache.tools.ant.Task#execute()
*/
public void execute() throws BuildException {
super.execute();
if (name == null) {
throw (new BuildException("Must specify a group name"));
}
try {
final GroupAider group = new GroupAider(name);
log("Adding group " + name, Project.MSG_INFO);
service.addGroup(group);
} catch (final XMLDBException e) {
final String msg = "XMLDB exception caught: " + e.getMessage();
if (failonerror) {
throw (new BuildException(msg, e));
} else {
log(msg, e, Project.MSG_ERR);
}
}
}
use of org.xmldb.api.base.XMLDBException in project exist by eXist-db.
the class ChownTask method execute.
/* (non-Javadoc)
* @see org.apache.tools.ant.Task#execute()
*/
public void execute() throws BuildException {
super.execute();
if ((name == null) || (group == null)) {
throw (new BuildException("Must specify user and group"));
}
try {
final Account usr = service.getAccount(name);
if (resource != null) {
final Resource res = base.getResource(resource);
service.chown(res, usr, group);
} else {
service.chown(usr, group);
}
} catch (final XMLDBException e) {
final String msg = "XMLDB exception caught: " + e.getMessage();
if (failonerror) {
throw (new BuildException(msg, e));
} else {
log(msg, e, Project.MSG_ERR);
}
}
}
use of org.xmldb.api.base.XMLDBException in project exist by eXist-db.
the class RemoveGroupTask method execute.
/* (non-Javadoc)
* @see org.apache.tools.ant.Task#execute()
*/
public void execute() throws BuildException {
super.execute();
if (name == null) {
throw (new BuildException("You have to specify a name"));
}
log("Removing group " + name, Project.MSG_INFO);
try {
final Group group = service.getGroup(name);
if (group != null) {
service.removeGroup(group);
} else {
log("Group " + name + " does not exist.", Project.MSG_INFO);
}
} catch (final XMLDBException e) {
final String msg = "XMLDB exception caught: " + e.getMessage();
if (failonerror) {
throw (new BuildException(msg, e));
} else {
log(msg, e, Project.MSG_ERR);
}
}
}
use of org.xmldb.api.base.XMLDBException in project exist by eXist-db.
the class UserPasswordTask method execute.
@Override
public void execute() throws BuildException {
super.execute();
if (name == null) {
throw (new BuildException("Must specify at least a user name"));
}
try {
log("Looking up user " + name, Project.MSG_INFO);
final Account usr = service.getAccount(name);
if (usr != null) {
log("Setting password for user " + name, Project.MSG_INFO);
if (secret != null) {
usr.setCredential(new Password(usr, secret));
this.service.updateAccount(usr);
}
} else {
final String msg = "user " + name + " not found";
if (failonerror) {
throw (new BuildException(msg));
} else {
log(msg, Project.MSG_ERR);
}
}
} catch (final XMLDBException e) {
final String msg = "XMLDB exception caught: " + e.getMessage();
if (failonerror) {
throw (new BuildException(msg, e));
} else {
log(msg, e, Project.MSG_ERR);
}
}
}
Aggregations