Skip to content

Commit

Permalink
Feature #8329:
Browse files Browse the repository at this point in the history
- counting only component instance documents
- counting all files
- adding coherency verifications about administration services
- cleaning some code
- fixing the error logging about pdf2swf tool detection at server starting
- fixing wrong class package definition of two implementations of ContentPeas
  • Loading branch information
SilverYoCha committed Oct 17, 2018
1 parent 5861f32 commit cef3d76
Show file tree
Hide file tree
Showing 33 changed files with 472 additions and 478 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ GML.admin = Gestionnaire
GML.administrateur = Administrateur
GML.allMP = Tous
GML.allFP = Toutes
GML.files = Fichiers
GML.attachments = Fichiers joints
GML.permalink = Permalien
GML.permalink.copy=Copier le lien
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ GML.permalink.copy=Copy link
GML.permalink.copy.ok=Link successfully copied
GML.permalink.help=To copy the link, right click > 'Copy shortcut'
GML.noLockedFile = Keine reservierte Datei!
GML.files = Files
GML.attachments = Beigef\u00fcgte Dateien
GML.author = Author
GML.publisher = Herausgeber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ GML.admin = Manager
GML.administrateur = Administrator
GML.allMP = All
GML.allFP = All
GML.files = Files
GML.attachments = Attachments
GML.permalink = Permalink
GML.permalink.copy=Copy link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ GML.admin = Gestionnaire
GML.administrateur = Administrateur
GML.allMP = Tous
GML.allFP = Toutes
GML.files = Fichiers
GML.attachments = Fichiers joints
GML.permalink = Permalien
GML.permalink.copy=Copier le lien
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ silverStatisticsPeas.JobPeas = Applications
silverStatisticsPeas.ServicesNumber = R\u00e9partition par type d'applications
silverStatisticsPeas.InstancesNumber = Nombre d'instances
silverStatisticsPeas.VolumeNumber = R\u00e9partition des contributions
silverStatisticsPeas.VolumeDocsNumber = R\u00e9partition des fichiers joints
silverStatisticsPeas.VolumeDocsNumber=R\u00e9partition des fichiers
silverStatisticsPeas.FromSpace = de l'espace
silverStatisticsPeas.AttachmentsNumber = Nombre de fichiers joints
silverStatisticsPeas.AttachmentsSize = Taille des fichiers joints
silverStatisticsPeas.VolumeDocsSize = Taille occup\u00e9e par les fichiers joints
silverStatisticsPeas.AttachmentsNumber=Nombre de fichiers
silverStatisticsPeas.AttachmentsSize=Espace disque occup\u00e9 par les fichiers
silverStatisticsPeas.VolumeDocsSize=Espace disque occup\u00e9 par les fichiers
silverStatisticsPeas.Frequence = Type de fr\u00e9quence
silverStatisticsPeas.AttachmentsTotalSize = Evolution de la taille des fichiers joints
silverStatisticsPeas.EvolutionAttachmentsTotalSize = Evolution de la taille occup\u00e9e par les fichiers joints
silverStatisticsPeas.AttachmentsTotalSize=Evolution de l'espace disque occup\u00e9 par toutes les donn\u00e9es
silverStatisticsPeas.EvolutionAttachmentsTotalSize=Evolution de l'espace disque occup\u00e9 par toutes les donn\u00e9es
silverStatisticsPeas.Historique = Historique \u00e9volution
silverStatisticsPeas.Access = Acc\u00e8s
silverStatisticsPeas.EvolutionAccessDeb = Historique \u00e9volution des acc\u00e8s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ silverStatisticsPeas.JobPeas = Anwendung
silverStatisticsPeas.ServicesNumber = Verteilung nach Anwendungs-Art
silverStatisticsPeas.InstancesNumber = Anzahl Instanzen
silverStatisticsPeas.VolumeNumber = Verteilung der Zuf\u00fchrungen
silverStatisticsPeas.VolumeDocsNumber = Verteilung der Dateien
silverStatisticsPeas.VolumeDocsNumber=File distribution
silverStatisticsPeas.FromSpace = des Bereichs
silverStatisticsPeas.AttachmentsNumber = Anzahl der beigef\u00fcgten Dateien
silverStatisticsPeas.AttachmentsSize = Gr\u00f6sse der beigef\u00fcgten Dateien
silverStatisticsPeas.VolumeDocsSize = Von den beigef\u00fcgten Dateien eingenommene Gr\u00f6sse
silverStatisticsPeas.AttachmentsNumber=Number of files
silverStatisticsPeas.AttachmentsSize=Disk space used by files
silverStatisticsPeas.VolumeDocsSize=Disk space used by files
silverStatisticsPeas.Frequence = H\u00e4ufigkeits-Art
silverStatisticsPeas.AttachmentsTotalSize = Entwicklung der Gr\u00f6sse der beigef\u00fcgten Dateien
silverStatisticsPeas.EvolutionAttachmentsTotalSize = Entwicklung der von den beigef\u00fcgten Dateien eingenommene Gr\u00f6sse
silverStatisticsPeas.AttachmentsTotalSize=Evolution of the disk space used by all data
silverStatisticsPeas.EvolutionAttachmentsTotalSize=History of disk space used by all data
silverStatisticsPeas.Historique = Vorgeschichte
silverStatisticsPeas.Access = Zugriff
silverStatisticsPeas.EvolutionAccessDeb = Vorgeschichte der Zugriffe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ silverStatisticsPeas.JobPeas = Applications
silverStatisticsPeas.ServicesNumber = Type of application distribution
silverStatisticsPeas.InstancesNumber = Application number
silverStatisticsPeas.VolumeNumber = Contributions distribution
silverStatisticsPeas.VolumeDocsNumber = Attachments distribution
silverStatisticsPeas.VolumeDocsNumber=File distribution
silverStatisticsPeas.FromSpace = from the space
silverStatisticsPeas.AttachmentsNumber = Attachments number
silverStatisticsPeas.AttachmentsSize = Attachments size
silverStatisticsPeas.VolumeDocsSize = Attachments size distribution
silverStatisticsPeas.AttachmentsNumber=Number of files
silverStatisticsPeas.AttachmentsSize=Disk space used by files
silverStatisticsPeas.VolumeDocsSize=Disk space used by files
silverStatisticsPeas.Frequence = Frequency
silverStatisticsPeas.AttachmentsTotalSize = Evolution of the size of attachments
silverStatisticsPeas.EvolutionAttachmentsTotalSize = Attachments size history
silverStatisticsPeas.AttachmentsTotalSize=Evolution of the disk space used by all data
silverStatisticsPeas.EvolutionAttachmentsTotalSize=History of disk space used by all data
silverStatisticsPeas.Historique = History
silverStatisticsPeas.Access = Access
silverStatisticsPeas.EvolutionAccessDeb = Access history
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ silverStatisticsPeas.JobPeas = Applications
silverStatisticsPeas.ServicesNumber = R\u00e9partition par type d'applications
silverStatisticsPeas.InstancesNumber = Nombre d'instances
silverStatisticsPeas.VolumeNumber = R\u00e9partition des contributions
silverStatisticsPeas.VolumeDocsNumber = R\u00e9partition des fichiers joints
silverStatisticsPeas.VolumeDocsNumber=R\u00e9partition des fichiers
silverStatisticsPeas.FromSpace = de l'espace
silverStatisticsPeas.AttachmentsNumber = Nombre de fichiers joints
silverStatisticsPeas.AttachmentsSize = Taille des fichiers joints
silverStatisticsPeas.VolumeDocsSize = Taille occup\u00e9e par les fichiers joints
silverStatisticsPeas.AttachmentsNumber=Nombre de fichiers
silverStatisticsPeas.AttachmentsSize=Espace disque occup\u00e9 par les fichiers
silverStatisticsPeas.VolumeDocsSize=Espace disque occup\u00e9 par les fichiers
silverStatisticsPeas.Frequence = Type de fr\u00e9quence
silverStatisticsPeas.AttachmentsTotalSize = Evolution de la taille des fichiers joints
silverStatisticsPeas.EvolutionAttachmentsTotalSize = Evolution de la taille occup\u00e9e par les fichiers joints
silverStatisticsPeas.AttachmentsTotalSize=Evolution de l'espace disque occup\u00e9 par toutes les donn\u00e9es
silverStatisticsPeas.EvolutionAttachmentsTotalSize=Evolution de l'espace disque occup\u00e9 par toutes les donn\u00e9es
silverStatisticsPeas.Historique = Historique \u00e9volution
silverStatisticsPeas.Access = Acc\u00e8s
silverStatisticsPeas.EvolutionAccessDeb = Historique \u00e9volution des acc\u00e8s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,34 +94,8 @@ StatsAsynchronVolume = True
# standard component name not feed
connecteurJDBC = connecteurJDBCStatistics

# standard component name for volume feed
almanach = almanachStatistics
# special component name for volume feed
# others by convention are named: [component name]Statistics
bookmark = webSitesStatistics
chat = chatStatistics
formManager = formManagerStatistics
forums = forumsStatistics
hyperlink = hyperlinkStatistics
infoLetter = infoLetterStatistics
kmax = kmaxStatistics
kmelia = kmeliaStatistics
pollingStation = surveyStatistics
processManager = processManagerStatistics
quickinfo = quickinfoStatistics
quizz = quizzStatistics
survey = surveyStatistics
toolbox = kmeliaStatistics
webSites = webSitesStatistics
yellowpages = yellowpagesStatistics
blog = blogStatistics
gallery = galleryStatistics
projectManager = projectManagerStatistics
rssAgregator = rssAgregatorStatistics
webPages = webPagesStatistics
mailinglist = mailingListStatistics
resourcesManager = resourcesManagerStatistics
classifieds = classifiedsStatistics
spaceMembers = spaceMembersStatistics

# pdc component name for volume feed
questionReply = questionReplyStatistics
whitePages = whitePagesStatistics
toolbox = kmeliaStatistics
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@
import java.sql.Connection;
import java.sql.SQLException;
import java.util.*;
import java.util.function.Supplier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import static org.silverpeas.core.SilverpeasExceptionMessages.*;
import static org.silverpeas.core.admin.domain.DomainDriver.ActionConstants.ACTION_MASK_MIXED_GROUPS;
import static org.silverpeas.core.util.StringUtil.isLong;

/**
* The class Admin is the main class of the Administrator.
Expand Down Expand Up @@ -788,6 +790,9 @@ public ComponentInst getComponentInst(String sClientComponentId) throws AdminExc
try {
ComponentInst componentInst = getComponentInst(getDriverComponentId(sClientComponentId),
null);
componentInst = checkComponentInstanceById(componentInst, sClientComponentId,
nullComponentInstSupplier);
Objects.requireNonNull(componentInst);
componentInst.setDomainFatherId(getClientSpaceId(componentInst.getDomainFatherId()));
return componentInst;
} catch (Exception e) {
Expand All @@ -798,13 +803,39 @@ public ComponentInst getComponentInst(String sClientComponentId) throws AdminExc
@Override
public ComponentInstLight getComponentInstLight(String componentId) throws AdminException {
try {
int driverComponentId = getDriverComponentId(componentId);
return componentManager.getComponentInstLight(driverComponentId);
final int driverComponentId = getDriverComponentId(componentId);
final ComponentInstLight instance = componentManager.getComponentInstLight(driverComponentId);
return checkComponentInstanceById(instance, componentId, null);
} catch (Exception e) {
throw new AdminException(failureOnGetting(COMPONENT, componentId), e);
}
}

private <T extends SilverpeasComponentInstance> T checkComponentInstanceById(
final T componentInstance, final String componentId,
final Supplier<T> nullComponentInstance) {
if (componentInstance != null) {
if (componentInstance.getId().equals(componentId)
|| "-1".equals(componentInstance.getId())
|| isLong(componentId)) {
return componentInstance;
}
SilverLogger.getLogger(this).error("{0}. Wrong component {1} has been found!!",
failureOnGetting(COMPONENT, componentId), componentInstance.getId());
return nullComponentInstance != null ? nullComponentInstance.get() : null;
}
return null;
}

private final Supplier<ComponentInst> nullComponentInstSupplier = () -> {
try {
return getComponentInst(-1, -1);
} catch (AdminException e) {
SilverLogger.getLogger(this).error(e);
return null;
}
};

/**
* Return the component Inst corresponding to the given ID.
*
Expand Down Expand Up @@ -1008,6 +1039,9 @@ public String deleteComponentInst(String userId, String componentId, boolean def

// Get the component to delete
ComponentInst componentInst = getComponentInst(sDriverComponentId, null);
componentInst = checkComponentInstanceById(componentInst, componentId,
nullComponentInstSupplier);
Objects.requireNonNull(componentInst);

// Get the father id
String sFatherClientId = componentInst.getDomainFatherId();
Expand Down Expand Up @@ -1580,12 +1614,16 @@ public String addProfileInst(ProfileInst profileInst) throws AdminException {
public String addProfileInst(ProfileInst profileInst, String userId)
throws AdminException {
try {
int driverFatherId = getDriverComponentId(profileInst.getComponentFatherId());
final String componentFatherId = profileInst.getComponentFatherId();
int driverFatherId = getDriverComponentId(componentFatherId);
String sProfileId = profileManager.createProfileInst(profileInst, driverFatherId);
profileInst.setId(sProfileId);

if (profileInst.getObjectId() == -1 || profileInst.getObjectId() == 0) {
ComponentInst componentInstFather = getComponentInst(driverFatherId, null);
componentInstFather = checkComponentInstanceById(componentInstFather, componentFatherId,
nullComponentInstSupplier);
Objects.requireNonNull(componentInstFather);
componentInstFather.addProfileInst(profileInst);
if (StringUtil.isDefined(userId)) {
componentInstFather.setUpdaterUserId(userId);
Expand Down Expand Up @@ -1621,10 +1659,14 @@ public String deleteProfileInst(String profileId, String userId)
ProfileInst profile = profileManager.getProfileInst(profileId);
try {
profileManager.deleteProfileInst(profile);
if (StringUtil.isDefined(
userId) && (profile.getObjectId() == -1 || profile.getObjectId() == 0)) {
int driverFatherId = getDriverComponentId(profile.getComponentFatherId());
if (StringUtil.isDefined(userId)
&& (profile.getObjectId() == -1 || profile.getObjectId() == 0)) {
final String componentFatherId = profile.getComponentFatherId();
int driverFatherId = getDriverComponentId(componentFatherId);
ComponentInst component = getComponentInst(driverFatherId, null);
component = checkComponentInstanceById(component, componentFatherId,
nullComponentInstSupplier);
Objects.requireNonNull(component);

component.setUpdaterUserId(userId);
updateComponentInst(component);
Expand Down Expand Up @@ -1668,8 +1710,12 @@ private String updateProfileInst(ProfileInst newProfile, String userId,
profileManager.updateProfileInst(newProfile);
if (StringUtil.isDefined(
userId) && (newProfile.getObjectId() == -1 || newProfile.getObjectId() == 0)) {
int driverFatherId = getDriverComponentId(newProfile.getComponentFatherId());
final String componentFatherId = newProfile.getComponentFatherId();
int driverFatherId = getDriverComponentId(componentFatherId);
ComponentInst component = getComponentInst(driverFatherId, null);
component = checkComponentInstanceById(component, componentFatherId,
nullComponentInstSupplier);
Objects.requireNonNull(component);
component.setUpdaterUserId(userId);
updateComponentInst(component);
}
Expand Down Expand Up @@ -3719,6 +3765,9 @@ public UserDetail[] getUsers(boolean bAllProfiles, String sProfile, String sClie
try {
ComponentInst componentInst = getComponentInst(
getDriverComponentId(sClientComponentId), getDriverSpaceId(sClientSpaceId));
componentInst = checkComponentInstanceById(componentInst, sClientComponentId,
nullComponentInstSupplier);
Objects.requireNonNull(componentInst);

for (ProfileInst profile : componentInst.getAllProfilesInst()) {
if (profile != null && (profile.getName().equals(sProfile) || bAllProfiles)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public ContentPeas(String sContentDescriptorPath) {
} else if ("kmelia".equals(sContentDescriptorPath)) {
this.init("kmelia", "org.silverpeas.components.kmelia.KmeliaContentManager");
} else if ("survey".equals(sContentDescriptorPath)) {
this.init("survey", "com.stratelia.webactiv.survey.SurveyContentManager");
this.init("survey", "org.silverpeas.components.survey.SurveyContentManager");
} else if ("toolbox".equals(sContentDescriptorPath)) {
this.init("toolbox", "org.silverpeas.components.kmelia.KmeliaContentManager");
} else if ("quickinfo".equals(sContentDescriptorPath)) {
Expand All @@ -64,7 +64,7 @@ public ContentPeas(String sContentDescriptorPath) {
} else if ("forums".equals(sContentDescriptorPath)) {
this.init("forums", "org.silverpeas.components.forums.ForumsContentManager");
} else if ("pollingStation".equals(sContentDescriptorPath)) {
this.init("pollingStation", "com.stratelia.webactiv.survey.SurveyContentManager");
this.init("pollingStation", "org.silverpeas.components.survey.SurveyContentManager");
} else if ("bookmark".equals(sContentDescriptorPath)) {
this.init("bookmark", "org.silverpeas.components.websites.WebSitesContentManager");
} else if ("infoLetter".equals(sContentDescriptorPath)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,42 +23,35 @@
*/
package org.silverpeas.core.silverstatistics.volume.model;

import org.silverpeas.core.util.UnitUtil;
import org.silverpeas.core.util.memory.MemoryUnit;

/**
* Statistics of a directory.
*/
public class DirectoryStats {
private final String directoryName;
private Long directorySize;
private Long numberOfFiles;
private long directorySize = 0L;
private long numberOfFiles = 0L;

public DirectoryStats(String name, long sizeOfDirectory, long numberOfFiles) {
this.numberOfFiles = numberOfFiles;
public DirectoryStats(String name) {
this.directoryName = name;
this.directorySize = sizeOfDirectory;
}

public String getDirectoryName() {
return directoryName;
}

public Long getDirectorySize() {
public long getDirectorySize() {
return directorySize;
}

public String getFormattedDirectorySize() {
return UnitUtil.formatValue(directorySize, MemoryUnit.B, MemoryUnit.MB);
}

public Long getNumberOfFiles() {
public long getNumberOfFiles() {
return numberOfFiles;
}

public void addFile(long size) {
numberOfFiles++;
directorySize = directorySize + size;
public void addDirectorySize(final long directorySize) {
this.directorySize += directorySize;
}

public void addFileNumber(final long numberOfFiles) {
this.numberOfFiles += numberOfFiles;
}
}

0 comments on commit cef3d76

Please sign in to comment.