mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-25 23:44:54 +01:00
Add compress fix.
This commit is contained in:
parent
3696e126e3
commit
4d46864388
@ -20,8 +20,8 @@ package com.wisemapping.dao;
|
|||||||
|
|
||||||
import com.wisemapping.model.*;
|
import com.wisemapping.model.*;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface MindmapManager {
|
public interface MindmapManager {
|
||||||
@ -67,5 +67,5 @@ public interface MindmapManager {
|
|||||||
|
|
||||||
void updateCollaboration(@NotNull Collaboration collaboration);
|
void updateCollaboration(@NotNull Collaboration collaboration);
|
||||||
|
|
||||||
void purgeHistory(int mapId);
|
void purgeHistory(int mapId) throws IOException;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
package com.wisemapping.dao;
|
package com.wisemapping.dao;
|
||||||
|
|
||||||
import com.wisemapping.model.*;
|
import com.wisemapping.model.*;
|
||||||
|
import com.wisemapping.util.ZipUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||||
import org.hibernate.criterion.Restrictions;
|
import org.hibernate.criterion.Restrictions;
|
||||||
@ -75,7 +76,7 @@ public class MindmapManagerImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void purgeHistory(int mapId) {
|
public void purgeHistory(int mapId) throws IOException {
|
||||||
final Criteria hibernateCriteria = getSession().createCriteria(MindMapHistory.class);
|
final Criteria hibernateCriteria = getSession().createCriteria(MindMapHistory.class);
|
||||||
hibernateCriteria.add(Restrictions.eq("mindmapId", mapId));
|
hibernateCriteria.add(Restrictions.eq("mindmapId", mapId));
|
||||||
hibernateCriteria.addOrder(Order.desc("creationTime"));
|
hibernateCriteria.addOrder(Order.desc("creationTime"));
|
||||||
@ -89,6 +90,14 @@ public class MindmapManagerImpl
|
|||||||
// If the map has not been modified in the last months, it means that I don't need to keep all the history ...
|
// If the map has not been modified in the last months, it means that I don't need to keep all the history ...
|
||||||
int max = mindmapById.getLastModificationTime().before(yearAgo) ? 10 : 25;
|
int max = mindmapById.getLastModificationTime().before(yearAgo) ? 10 : 25;
|
||||||
|
|
||||||
|
for (MindMapHistory history : historyList) {
|
||||||
|
byte[] zippedXml = history.getZippedXml();
|
||||||
|
if(new String(zippedXml).startsWith("<map")){
|
||||||
|
history.setZippedXml(ZipUtils.bytesToZip(zippedXml));
|
||||||
|
getHibernateTemplate().update(history);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (historyList.size() > max) {
|
if (historyList.size() > max) {
|
||||||
for (int i = max; i < historyList.size(); i++) {
|
for (int i = max; i < historyList.size(); i++) {
|
||||||
getHibernateTemplate().delete(historyList.get(i));
|
getHibernateTemplate().delete(historyList.get(i));
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
package com.wisemapping.model;
|
package com.wisemapping.model;
|
||||||
|
|
||||||
import com.wisemapping.util.ZipUtils;
|
import com.wisemapping.util.ZipUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -52,6 +53,7 @@ public class MindMapHistory {
|
|||||||
this.mindmapId = id;
|
this.mindmapId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public Calendar getCreationTime() {
|
public Calendar getCreationTime() {
|
||||||
return creationTime;
|
return creationTime;
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,7 @@
|
|||||||
package com.wisemapping.rest;
|
package com.wisemapping.rest;
|
||||||
|
|
||||||
import com.wisemapping.exceptions.WiseMappingException;
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
import com.wisemapping.model.AuthenticationType;
|
import com.wisemapping.model.*;
|
||||||
import com.wisemapping.model.Collaboration;
|
|
||||||
import com.wisemapping.model.Mindmap;
|
|
||||||
import com.wisemapping.model.User;
|
|
||||||
import com.wisemapping.rest.model.RestUser;
|
import com.wisemapping.rest.model.RestUser;
|
||||||
import com.wisemapping.service.MindmapService;
|
import com.wisemapping.service.MindmapService;
|
||||||
import com.wisemapping.service.UserService;
|
import com.wisemapping.service.UserService;
|
||||||
@ -176,13 +173,15 @@ public class AdminController extends BaseController {
|
|||||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "admin/database/purge/history")
|
@RequestMapping(method = RequestMethod.GET, value = "admin/database/purge/history")
|
||||||
public void purgeHistory(@RequestParam(required = true) Integer mapId) throws WiseMappingException, UnsupportedEncodingException {
|
public void purgeHistory(@RequestParam(required = true) Integer mapId) throws WiseMappingException, IOException {
|
||||||
|
|
||||||
mindmapService.purgeHistory(mapId);
|
mindmapService.purgeHistory(mapId);
|
||||||
}
|
}
|
||||||
|
@ -68,5 +68,5 @@ public interface MindmapService {
|
|||||||
|
|
||||||
boolean isAdmin(@Nullable User user);
|
boolean isAdmin(@Nullable User user);
|
||||||
|
|
||||||
void purgeHistory(int mapId);
|
void purgeHistory(int mapId) throws IOException;
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ public class MindmapServiceImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void purgeHistory(int mapId) {
|
public void purgeHistory(int mapId) throws IOException {
|
||||||
mindmapManager.purgeHistory(mapId);
|
mindmapManager.purgeHistory(mapId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
</id>
|
</id>
|
||||||
|
|
||||||
<property name="mindmapId" column="mindmap_id"/>
|
<property name="mindmapId" column="mindmap_id"/>
|
||||||
<property name="zippedXml" column="xml"/>
|
<property name="zippedXml" column="xml" lazy="true"/>
|
||||||
<property name="creationTime" column="creation_date"/>
|
<property name="creationTime" column="creation_date"/>
|
||||||
<many-to-one name="editor" column="editor_id" unique="false" not-null="false" lazy="proxy"/>
|
<many-to-one name="editor" column="editor_id" unique="false" not-null="false" lazy="proxy"/>
|
||||||
</class>
|
</class>
|
||||||
|
Loading…
Reference in New Issue
Block a user