Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errores varios y cuota por defecto al crear site(portal-ext.properties) #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docroot/WEB-INF/liferay-hook.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@
<struts-action-path>/document_library/upload_multiple_file_entries</struts-action-path>
<struts-action-impl>org.lsug.quota.QuotaEditFileEntryAction</struts-action-impl>
</struts-action>
<struts-action>
<struts-action-path>/document_library/view_file_entry</struts-action-path>
<struts-action-impl>org.lsug.quota.QuotaEditFileEntryAction</struts-action-impl>
</struts-action>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hola @acoronadoc. Estoy a punto de acabar el portlet para Liferay 7 y quería mirar lo que puedo añadir de esta pull request. ¿Por qué es necesario añadir el view_file_entry si no influye en la modificación de la cuota, y la nueva excepcion que lanza?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Es necesario para que la cuota se actualice cuando utilizas la funcionalidad de arrastrar ficheros.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¿Te refieres a arrastrar ficheros desde el ordenador a la pagina inicial de la document library?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si.

Copy link
Member

@juangon juangon Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hola de nuevo. He estado haciendo pruebas y en caso de cualquier error al arrastrar un fichero desde una carpeta del sistema operativo, no muestra ninguno (he abierto https://issues.liferay.com/browse/LPS-75051 por ello).

He probado a añadir este cambio y el comportamiento sigue igual (no muestra el mensaje personalizado de cuota por ningún sitio).

¿Puedes describir los pasos a reproducir? He probado tanto Liferay 7 GA4 como 6.2 GA5

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hola Juan, diría que para arreglar esto solo hice este cambio(También hace varios meses de esto y arreglé otras cosas también). No me suena haber tocado nada mas.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vaya, pues en mi caso no soluciona nada. En tal caso no añadiré este cambio. Por ahora sólo añadiría la mejora de las propiedades por defecto y la traducción al catalán.

</hook>
2 changes: 1 addition & 1 deletion docroot/WEB-INF/liferay-plugin-package.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ change-log=
page-url=http://www.liferay.com/community/user-groups/spain/welcome
author=LSUG
licenses=LGPL
liferay-versions=6.2.5+,6.2.10
liferay-versions=6.2+
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Se puso explicitamente esta versión ya que creo que se usa API a partir de esta linea base. Esto no se cambiara.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, pues por lo menos, pon la versión 6.2.16(Que es la que estamos usando :( , te confirmo que funciona bien)


portal-dependency-jars=\
jstl-api.jar,\
Expand Down
2 changes: 1 addition & 1 deletion docroot/WEB-INF/liferay-portlet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<icon>/html/server-quota/icon.png</icon>
<user-notification-definitions>/org/lsug/quota/portlet/notification/quota-server-user-notification-definition.xml</user-notification-definitions>
<user-notification-handler-class>org.lsug.quota.portlet.notification.QuotaServerNotificationHandler</user-notification-handler-class>
<control-panel-entry-category>server</control-panel-entry-category>
<control-panel-entry-category>configuration</control-panel-entry-category>
<control-panel-entry-weight>2.5</control-panel-entry-weight>
<instanceable>false</instanceable>
<requires-namespaced-parameters>false</requires-namespaced-parameters>
Expand Down
68 changes: 34 additions & 34 deletions docroot/WEB-INF/src/content/Language_ca.properties
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
alerts-enabled=Alerts Enabled
allocated-space=Allocated Space
enable-alerts=Enable Alerts
enable-quota=Enable Quota
free-space=Free Space
quota-alert=Quota Alerts (%)
quota-assigned=Allocated Quota (MB)
quota-control=Quota Control
quota-enabled=Quota Enabled
quota-status=Quota Status
quota-used=Used Quota
quota-unlimited=Cuota ilimitada
send-alert-when-reach=Send alert when reach
server-capacity=Server Capacity (Hard Disk)
server-description=Quota Control Portlet allows to enable the management of space quota usage.\nIf quota control is enabled, you'll be able to manage quota control for each instance. When you add quota control you can enable if you want to send mail alerts to portal and instance administrators, quota space assigned to the site (in Gb) and at what percentage the alerts have to be sent.
server-quota-title=Server Quota Management
site-name=Site Name
sites-quota-description=Sites Quota Management
total-quota=Total Quota
used-space=Used Space
user-sites=User sites
server-current-used-size-diagram-title=Current used size (by instance)
user-site-current-used-size-diagram-title=User quota
user-site-no-quota-enabled=There is no disk quota enabled for this user
sites-quota-enabled-sites-used-diagram-title=Current used size (enabled quota sites)
assigned-quota-less-than-current=Assigned quota is less than current used quota.
unused-space=Free space
quota-from-instance-x-above-the-alert=The instance {0} is above the quota alert
quota-from-site-x-above-the-alert=The site {0} is above the quota alert
quota-from-user-x-above-the-alert={0} user site has reached the quota alert threshold
javax.portlet.title.serverquotaportlet_WAR_quotacontrolportlet=Server quota
javax.portlet.title.sitesquotaportlet_WAR_quotacontrolportlet=Sites quota
javax.portlet.title.myquotaportlet_WAR_quotacontrolportlet=My user quota
javax.portlet.title.siteconfigurationquotaportlet_WAR_quotacontrolportlet=Site quota
alerts-enabled=Alertes activades
allocated-space=Espai assignat
enable-alerts=Activar alertes
enable-quota=Activar quota
free-space=Espai lliure
quota-alert=Alerta de quota (%)
quota-assigned=Quota assignada (MB)
quota-control=Control de quota
quota-enabled=Quota activada
quota-status=Estat de quota
quota-used=Quota utilitzada
quota-unlimited=Quota il.limitada
send-alert-when-reach=Enviar una alerta quan s'arribi
server-capacity=Capacitat del servidor(Hard Disk)
server-description=Control de quota permet habilitar la gesti� de l'�s que es fa de l'espai per fitxers.\nSi s'activa, podr�s gestionar quotes per cada instancia i lloc web. En afegir una quota podr�s habilitar l'enviament de mails i alertes al portal i administradors i configurar l'espai assignat a un lloc web(en Gb) i a partir de quin percentatge s'enviar� l'alerta.
server-quota-title=Gesti� de quotes al servidor
site-name=Nom del lloc
sites-quota-description=Gesti� de quotes al servidor
total-quota=Quota total
used-space=Espai utilitzat
user-sites=Llocs web d'usuaris
server-current-used-size-diagram-title=Espai utilitzat(per inst�ncia)
user-site-current-used-size-diagram-title=Quota d'usuari
user-site-no-quota-enabled=No hi ha quota de disc per aquest usuari
sites-quota-enabled-sites-used-diagram-title=Espai utilitzat(habilitat per llocs web)
assigned-quota-less-than-current=La quota assignada es inferior a la quota utilitzada.
unused-space=Espai lliure
quota-from-instance-x-above-the-alert=La inst�ncia {0} est�per sobre l'alerta assignada
quota-from-site-x-above-the-alert=El lloc web {0} est� per sobre la quota assignada
quota-from-user-x-above-the-alert={0} lloc web ha arribat a l'alerta de quota
javax.portlet.title.serverquotaportlet_WAR_quotacontrolportlet=Quota de servidor
javax.portlet.title.sitesquotaportlet_WAR_quotacontrolportlet=Quota de lloc web
javax.portlet.title.myquotaportlet_WAR_quotacontrolportlet=La meva quota d'usuari
javax.portlet.title.siteconfigurationquotaportlet_WAR_quotacontrolportlet=Quota de lloc web
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ protected void doRun(long companyId) throws Exception {

if (quota == null) {
long quotaUsed = QuotaLocalServiceUtil.calculateSiteUsedQuota(classPK);
QuotaLocalServiceUtil.addQuota(companyId, classNameId, classPK, 0, 0, quotaUsed, Constants.QUOTA_INACTIVE);

QuotaLocalServiceUtil.createDefaultQuota(companyId, classNameId, group.getClassPK());
QuotaLocalServiceUtil.decrementQuota(classNameId, group.getClassPK(), quotaUsed);

Copy link
Member

@juangon juangon Jun 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¿Por que es necesario decrementar la Quota aqui?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Porque si tienes un site que ya usa recursos y instalas el portlet con una cuota por defecto, al inicializarse la cuota del site por defecto ya debe decrementar el uso que ya se esta haciendo de recursos. Sino, te encontrarías que al instalar el portlet cuota con una cuota por defecto, el uso de recursos hasta la fecha no se contabilizaría.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Para eso ya esta la llamada a addQuota con la variable quotaUsed :-).

Has visto que esto no funcionaba bien?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El método addQuota no tiene en cuenta la inicialización por defecto, si se cambia hay que cambiar el método. Por otro lado, entiendo que el método createDefaultQuota esta para eso, como mucho añadirle el parámetro para hacer en un solo paso. Como quieras...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si que tiene en cuenta la inicializacion por defecto. Como dije antes, para eso esta la variable quotaUsed en dicho método.
Es decir, los dos métodos que has puesto equivalen a la linea que ya existía.
Este cambio no es necesario ya que no cambia nada del comportamiento anterior.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Juan no nos estamos entendiendo. El método addQuota no tiene en cuenta la configuración por defecto que AHORA puedes poner en el fichero portal-ext.properties. Esta modificación es muy necesaria. Mírate la definición de los métodos en la classe QuotaLocalServiceImpl:

public Quota createDefaultQuota(long companyId, long classNameId,
		long classPK) throws SystemException {

	Quota quota = quotaLocalService.fetchQuotaByClassNameIdClassPK(classNameId, classPK);
	
	if (quota ==  null) {
		int quotaAlert = 0;
		long quotaAssigned = 0;
		long quotaUsed = 0;
		int quotaStatus = 0;
		
		if ( PropsUtil.get("lsug.quota.portlet.default.alert")!=null ) if ( !PropsUtil.get("lsug.quota.portlet.default.alert").equals("") ) quotaAlert=Integer.parseInt( PropsUtil.get("lsug.quota.portlet.default.alert") );
		if ( PropsUtil.get("lsug.quota.portlet.default.assigned")!=null ) if ( !PropsUtil.get("lsug.quota.portlet.default.assigned").equals("") ) quotaAssigned=Integer.parseInt( PropsUtil.get("lsug.quota.portlet.default.assigned") );
		if ( PropsUtil.get("lsug.quota.portlet.default.status")!=null ) if ( !PropsUtil.get("lsug.quota.portlet.default.status").equals("") ) quotaStatus=Integer.parseInt( PropsUtil.get("lsug.quota.portlet.default.status") );		

		quota = quotaLocalService.addQuota(companyId, classNameId, classPK, quotaAlert,
			quotaAssigned, quotaUsed, quotaStatus);
	}
	
	return quota;
}

Si quieres lo comentamos por teléfono.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, entendido! Pensare si ese es el mejor sitio.

Gracias.

sitesQuotaAdded++;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected String getBody(UserNotificationEvent userNotificationEvent,
String body = jsonObject.getString("body");
String webId = CompanyLocalServiceUtil.getCompany(classPK).getWebId();

String title = QuotaUtil.getResource(serviceContext.getLiferayPortletRequest(),
String title = QuotaUtil.getResource(serviceContext.getLocale(),
"quota-from-instance-x-above-the-alert", HtmlUtil.escape(webId));

return StringUtil.replace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.liferay.portal.kernel.notifications.NotificationEventFactoryUtil;
import com.liferay.portal.kernel.notifications.UserNotificationManagerUtil;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.model.Company;
Expand All @@ -31,6 +32,7 @@
import com.liferay.portal.model.UserGroupRole;
import com.liferay.portal.model.UserNotificationDeliveryConstants;
import com.liferay.portal.service.UserNotificationEventLocalServiceUtil;
import com.liferay.portal.service.persistence.PortalPreferencesUtil;
import com.liferay.portlet.documentlibrary.model.DLFileEntry;
import com.liferay.portlet.documentlibrary.model.DLFileVersion;
import com.liferay.util.portlet.PortletProps;
Expand Down Expand Up @@ -82,6 +84,10 @@ public Quota createDefaultQuota(long companyId, long classNameId,
long quotaAssigned = 0;
long quotaUsed = 0;
int quotaStatus = 0;

if ( PropsUtil.get("lsug.quota.portlet.default.alert")!=null ) if ( !PropsUtil.get("lsug.quota.portlet.default.alert").equals("") ) quotaAlert=Integer.parseInt( PropsUtil.get("lsug.quota.portlet.default.alert") );
if ( PropsUtil.get("lsug.quota.portlet.default.assigned")!=null ) if ( !PropsUtil.get("lsug.quota.portlet.default.assigned").equals("") ) quotaAssigned=Integer.parseInt( PropsUtil.get("lsug.quota.portlet.default.assigned") );
if ( PropsUtil.get("lsug.quota.portlet.default.status")!=null ) if ( !PropsUtil.get("lsug.quota.portlet.default.status").equals("") ) quotaStatus=Integer.parseInt( PropsUtil.get("lsug.quota.portlet.default.status") );

quota = quotaLocalService.addQuota(companyId, classNameId, classPK, quotaAlert,
quotaAssigned, quotaUsed, quotaStatus);
Expand Down
6 changes: 3 additions & 3 deletions docroot/html/sites-quota/view.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
modelVar="quota" escapedModel="<%= true %>">

<liferay-ui:search-container-column-text name="site-name">

<%= GroupLocalServiceUtil.getGroup(quota.getClassPK()).getDescriptiveName(locale) %>

<a target="_blank" href="/group/control_panel?doAsGroupId=${quota.getClassPK()}&p_p_id=156">
<%= GroupLocalServiceUtil.getGroup(quota.getClassPK()).getDescriptiveName(locale) %>
</a>
</liferay-ui:search-container-column-text>

<liferay-ui:search-container-column-text name="quota-enabled">
Expand Down