first message shown twice for new user issue solved
This commit is contained in:
parent
08f0160d8d
commit
7f88e20a88
|
@ -87,7 +87,7 @@ public class MessageManager extends Impersonable{
|
|||
@Inject Item2NodeConverter item2Node;
|
||||
|
||||
@Inject TrashHandler trashHandler;
|
||||
|
||||
|
||||
@GET
|
||||
@Path("{id}")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -127,7 +127,7 @@ public class MessageManager extends Impersonable{
|
|||
Node messageNode = ses.getNodeByIdentifier(id);
|
||||
Message message = node2Item.getMessageItem(messageNode);
|
||||
Node personalNode = checkRights(currentUser, message);
|
||||
|
||||
|
||||
if (countSharedSet(messageNode)>1)
|
||||
personalNode.removeShare();
|
||||
else {
|
||||
|
@ -279,7 +279,7 @@ public class MessageManager extends Impersonable{
|
|||
throw new InvalidCallParameters();
|
||||
|
||||
log.debug("attachments send are {}",attachments);
|
||||
|
||||
|
||||
ses = (JackrabbitSession) repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
|
||||
|
||||
Message message = new MessageSharable();
|
||||
|
@ -323,11 +323,11 @@ public class MessageManager extends Impersonable{
|
|||
return messageId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private Node saveAttachments(Session ses, Node messageNode , List<String> attachments) throws RepositoryException, BackendGenericError{
|
||||
Node attachmentNode = messageNode.getNode(Constants.ATTACHMENTNODE_NAME);
|
||||
|
||||
|
||||
for (String itemId: attachments) {
|
||||
Node node = ses.getNodeByIdentifier(itemId);
|
||||
Item item = node2Item.getItem(node, Excludes.GET_ONLY_CONTENT);
|
||||
|
@ -351,7 +351,7 @@ public class MessageManager extends Impersonable{
|
|||
log.info("message discarded");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (reduceBody != null && reduceBody>0 && message.getBody().length()>reduceBody )
|
||||
message.setBody(message.getBody().substring(0, reduceBody));
|
||||
insertOrdered(messages, message);
|
||||
|
@ -360,12 +360,15 @@ public class MessageManager extends Impersonable{
|
|||
}
|
||||
|
||||
private void insertOrdered(List<Message> messages, Message toInsert) {
|
||||
if (messages.isEmpty()) messages.add(toInsert);
|
||||
int i;
|
||||
for ( i=0 ; i<messages.size(); i++)
|
||||
if (messages.get(i).getCreationTime().getTimeInMillis()<=toInsert.getCreationTime().getTimeInMillis())
|
||||
break;
|
||||
messages.add(i, toInsert);
|
||||
if (messages.isEmpty())
|
||||
messages.add(toInsert);
|
||||
else {
|
||||
int i;
|
||||
for ( i=0 ; i<messages.size(); i++)
|
||||
if (messages.get(i).getCreationTime().getTimeInMillis()<=toInsert.getCreationTime().getTimeInMillis())
|
||||
break;
|
||||
messages.add(i, toInsert);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -373,8 +376,8 @@ public class MessageManager extends Impersonable{
|
|||
Node personalNode = null;
|
||||
Node messageNode = (Node) messageItem.getRelatedNode();
|
||||
if (messageNode.getPath().startsWith(pathUtil.getWorkspacePath(currentUser).toPath()))
|
||||
return messageNode;
|
||||
|
||||
return messageNode;
|
||||
|
||||
NodeIterator nodeIt = messageNode.getSharedSet();
|
||||
while (nodeIt.hasNext()) {
|
||||
Node node = nodeIt.nextNode();
|
||||
|
@ -397,7 +400,7 @@ public class MessageManager extends Impersonable{
|
|||
String newPath= String.format("%s/%s", destination.getPath(), uniqueName);
|
||||
session.getWorkspace().copy(nodeToCopy.getPath(), newPath);
|
||||
Node newNode = session.getNode(newPath);
|
||||
|
||||
|
||||
if (itemToCopy instanceof AbstractFileItem) {
|
||||
AbstractFileItem newNodeItem = node2Item.getItem(newNode, Excludes.EXCLUDE_ACCOUNTING);
|
||||
newNodeItem.getContent().setRemotePath(newPath);
|
||||
|
@ -412,7 +415,7 @@ public class MessageManager extends Impersonable{
|
|||
newNode.setProperty(NodeProperty.TITLE.toString(), uniqueName);
|
||||
return newNode;
|
||||
}
|
||||
|
||||
|
||||
private int countSharedSet(Node node) throws RepositoryException{
|
||||
int count =0;
|
||||
NodeIterator it = node.getSharedSet();
|
||||
|
|
Loading…
Reference in New Issue