String path = origCursorFilePath;
ContentRepositoryRegistry registry = ContentRepositoryRegistry.getInstance();
ContentRepository repo = registry.getRepository(LoginManager.getPrimary());
try {
ContentCollection c = repo.getUserRoot();
ContentResource r = (ContentResource) c.getChild(cursorFile.getName());
if(r!=null) {
//file is already exist
Object[] options = {
BUNDLE.getString("Replace"),
BUNDLE.getString("Use_Existing"),
BUNDLE.getString("Cancel")
};
String msg = MessageFormat.format(
BUNDLE.getString("Replace_Question"), file.getName());
String title = BUNDLE.getString("Replace_Title");
int result = JOptionPane.showOptionDialog(this, msg, title,
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
// If the user hits Cancel or a "closed" action (e.g. Escape key)
// then just return
if ((result == JOptionPane.CANCEL_OPTION)
|| (result == JOptionPane.CLOSED_OPTION)) {
path = origCursorFilePath;
}
// If the content exists and we do not want to upload a new version,
// then simply create it and return.
if (result == JOptionPane.NO_OPTION) {
path = "wlcontent:/"+r.getPath();
}
if(result == JOptionPane.YES_OPTION) {
try {
r.put(temp);
path = "wlcontent:/"+r.getPath();
} catch (IOException ex) {
Logger.getLogger(BasicJPanel.class.getName()).log(Level.SEVERE, null, ex);
}
}
} else {
//create a new file
r = (ContentResource) c.createChild(cursorFile.getName()
, ContentNode.Type.RESOURCE);
try {
r.put(temp);
path = "wlcontent:/"+r.getPath();
} catch (IOException ex) {
Logger.getLogger(BasicJPanel.class.getName()).log(Level.SEVERE, null, ex);
}
}
} catch (Exception ex) {