package pt.estgp.estgweb.domain;
import pt.estgp.estgweb.domain.ManagedIdentifierCollection;
import pt.estgp.estgweb.domain.views.ManagedIdentifierCollectionView;
import pt.estgp.estgweb.domain.views.UserView;
import pt.utl.ist.berserk.logic.serviceManager.IServiceManager;
import pt.utl.ist.berserk.logic.serviceManager.ServiceManager;
import java.util.List;
import java.util.ArrayList;
import java.io.Serializable;
import org.apache.log4j.Logger;
/**
* @author Jorge Machado
* @date 4/Jul/2008
* @see pt.estgp.estgweb.domain.dao.impl
*/
public class ManagedIdentifierCollectionImpl
extends ManagedIdentifierCollection
implements IAddContents
{
private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger =
1.5.0/docs/api/java/util/logging/Logger.html">Logger.
getLogger(ManagedIdentifierCollectionImpl.
class);
public List
<String
> getOwnerRoles
()
{
return null;
}
public 1.5.0/docs/api/java/lang/String.html">String getChoosedOwnerRole
()
{
return null;
}
public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable
()
{
return getId
();
}
public boolean canAddContent
(GenericUserImpl u
)
{
return canAddContent
(u,
false);
}
private ManagedIdentifierCollectionView managedIdentifierCollectionView =
null;
private boolean initView =
false;
private void initView
()
{
if(!initView
)
{
try{
IServiceManager sm = ServiceManager.
getInstance();
1.5.0/docs/api/java/lang/String.html">String[] names =
new 1.5.0/docs/api/java/lang/String.html">String[]{"serializable"};
5+0%2Fdocs%2Fapi+Object">Object[] args =
new 5+0%2Fdocs%2Fapi+Object">Object[]{getId
()};
managedIdentifierCollectionView =
(ManagedIdentifierCollectionView
) sm.
execute(null,
"managedIdentiferLoadCollection", args, names
);
initView =
true;
}
catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e
)
{
logger.
error(e,e
);
}
}
}
public boolean canAddContent
(GenericUserImpl u,
boolean transaction
)
{
if(transaction
)
{
return isOwnedBy
(u
) || getManagers
().
contains(u
);
}
else
{
initView
();
if(managedIdentifierCollectionView ==
null)
return false;
else
{
for(UserView user: managedIdentifierCollectionView.
getManagers())
{
if(user.
getId() == u.
getId())
return true;
}
return false;
}
}
}
}